Commit c152271
Sync repos: Release 170.157.0 (#186)
* Merged PR 1821782: Fixing the parse issue with vector type
Parser would timeout or crash when parsing queries with VECTOR data types in deeply nested JOIN structures due to exponential complexity (O(2^n)) in ANTLR's syntactic predicate lookahead.
The `selectTableReferenceElement` grammar rule uses recursive syntactic predicates that cause exponential backtracking when VECTOR types appear in complex join hierarchies. Each additional nesting level doubles the parsing attempts.
Implemented conditional optimization using `ContainsVectorInLookahead()` helper method:
- Scans ahead up to 200 tokens to detect VECTOR keyword
- When VECTOR detected: applies `SaveGuessing` optimization to reduce complexity from O(2^n) to O(n²)
- When no VECTOR: uses standard grammar path with minimal overhead (~1-2ms)
- **TSql170.g**: Modified `selectTableReferenceElement` rule with conditional SaveGuessing
- **TSql170ParserBaseInternal.cs**: Added `ContainsVectorInLookahead()` helper method
- **ComplexQueryTests170.sql**: Added comprehensive test coverage (6 queries)
- 5 VECTOR scenarios: CAST, CONVERT, deeply nested JOINs with VECTOR types
- 1 non-VECTOR scenario: Complex 6-way nested JOIN to validate no regression
- All 1,122 tests passing (0 failures)
- VECTOR queries: Previously timeout/crash → now parse successfully
- Non-VECTOR queries: No measurable performance impact
- Cross-version validation: Appropriate error counts for TSql80-160
- **Overhead**: O(1) per table reference (200-token scan)
- **Typical queries**: <2ms additional overhead
- **VECTOR queries**: Massive improvement (timeout → completes)
- **Verdict**: Acceptable tradeoff for critical fix
Related work items: #4819213
* Merged PR 1921093: [Fabric DW] Add support for Fabric DW specific AI functions
This PR adds support for Fabric DW specific AI functions:
- `ai_analyze_sentiment(<input>)`
- `ai_classify(<input>, <class1>, <class2>[, <class 3>, ...])`
- `ai_extract(<input>, <label1>[, <label2>, ...])`
- `ai_fix_grammar(<input>)`
- `ai_generate_response(<promptPart1>[, <promptPart2>])`
- `ai_summarize(<input>)`
- `ai_translate(<input>, <lang>)`
Detailed design document is here: https://microsoft.sharepoint.com/:w:/r/teams/AzurePolaris/_layouts/15/doc2.aspx?sourcedoc=%7B75BAC667-A870-4482-8A37-F80E6EC8FCE0%7D&file=AI%20and%20Extensibiliy.docx
Before submitting your pull request, please ensure you have completed the following:
- [x] The [Common checklist](https://msdata.visualstudio.com/SQLToolsAndLibraries/_git/Common?path=/Templates/PR%20Checklist%20for%20SQLToolsAndLibraries.md&version=GBmain&_a=preview) has been reviewed and followed
- [x] Code changes are accompanied by appropriate unit tests
- [x] Identified and included SMEs needed to review code changes
- [X] Follow the [steps](https://msdata.visualstudio.com/SQLToolsAndLibraries/_wiki/wikis/SQLToolsAndLibraries.wiki/33838/Adding-or-Extending-TSql-support-in-Sql-Dom?anchor=make-the-changes-in) here to make changes in the code
- [x] Follow the [steps](https://msdata.visualstudio.com/SQLToolsAndLibraries/_wiki/wikis/SQLToolsAndLibraries.wiki/33838/Adding-or-Extending-TSql-support-in-Sql-Dom?anchor=to-extend-the-tests-do-the-following%3A) here to add new tests for your feature
- [ ] Update relevant documentation in the [wiki](https://dev.azure.com/msdata/SQLToolsAndLibraries/_wiki/wikis/SQLToolsAndLibraries.wiki) and the README.md file
----
New feature: Adding support for Fabric DW–specific AI built-in functions.
This pull request extends the SQL parser for Fabric DW by introducing new AI functions and their corresponding AST representations, script generators, and tests. Key changes include:
- **`TSqlFabricDW.g`**: Added grammar rules for AI functions (e.g., AI_ANALYZE_SENTIMENT, AI_CLASSIFY, AI_EXTRACT, AI_GENERATE_RESPONSE, AI_SUMMARIZE, AI_TRANSLATE).
- **`Ast.xml`**: Introduced new AST classes to represent the AI function calls.
- **Script Generator Files**: Created new files in `SqlScriptDom/ScriptDom/SqlServer/ScriptGenerator/` to define visitors for the AI functions.
- **`CodeGenerationSupporter.cs`**: Added new constants to support the AI function tokens.
- **Test Files**: Included multiple test scripts and negative tests under `/Test/SqlDom/` to validate the syntax and error handling for the newly added functions.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
Related work items: #4924682
* Merged PR 1921976: Fixing IIF parsing when it occurs inside a parenthesis.
# Pull Request Template for ScriptDom
## Description
Fixes: #28
The TSql160Parser.ParseExpression() was failing to parse valid T-SQL expressions where IIF with boolean operators was wrapped in parentheses:
```sql
SELECT 1 WHERE (IIF(1 > 0 AND 2 > 1, 1, 0)) = 1
```
Customers reported this issue when using IIF expressions with multiple boolean operators (AND, OR, >, <, etc.) wrapped in parentheses.
The original code used a simple counter (insideIIf) to track when inside an IIF call. The counter was decremented on the first boolean operator inside the IIF (e.g., >). When a second operator like AND was encountered, insideIIf was already 0, causing it to be misidentified as a top-level boolean operator - which incorrectly signaled that the outer parentheses contained a boolean expression instead of a scalar expression.
Replaced the simple counter with stack-based parenthesis depth tracking.
This properly tracks when we're inside an IIF by remembering the parenthesis depth where each IIF started, rather than incorrectly decrementing on boolean operators. This also correctly handles:
Nested IIF expressions: `(IIF(IIF(a > 1, b, c) > 2, 1, 0))`
Deeply nested parentheses: `((((IIF(1 > 0 AND 2 > 1, 1, 0)))) = 1`
Multiple IIF expressions: `(IIF(...)) = 1 AND (IIF(...)) = 1`
## Code Change
- [ ] The [Common checklist](https://msdata.visualstudio.com/SQLToolsAndLibraries/_git/Common?path=/Templates/PR%20Checklist%20for%20SQLToolsAndLibraries.md&version=GBmain&_a=preview) has been reviewed and followed
- [ ] Code changes are accompanied by appropriate unit tests
- [ ] Identified and included SMEs needed to review code changes
- [ ] Follow the [steps](https://msdata.visualstudio.com/SQLToolsAndLibraries/_wiki/wikis/SQLToolsAndLibraries.wiki/33838/Adding-or-Extending-TSql-support-in-Sql-Dom?anchor=make-the-changes-in) here to make changes in the code
## Testing
- [ ] Follow the [steps](https://msdata.visualstudio.com/SQLToolsAndLibraries/_wiki/wikis/SQLToolsAndLibraries.wiki/33838/Adding-or-Extending-TSql-support-in-Sql-Dom?anchor=to-extend-the-tests-do-the-following%3A) here to add new tests for your feature
## Documentation
- [ ] Update relevant documentation in the [wiki](https://dev.azure.com/msdata/SQLToolsAndLibraries/_wiki/wikis/SQLToolsAndLibraries.wiki) and the README.md file
## Additional Information
Please provide any additional information that might be helpful for the reviewers
----
#### AI description (iteration 1)
#### PR Classification
Bug fix to correct the parsing of IIF expressions when they occur inside parentheses.
#### PR Summary
This pull request fixes the incorrect handling of nested IIF expressions by replacing a simple counter with a stack-based approach and a pending flag, ensuring accurate tracking of IIF parentheses. The update enhances the SQL parser and adds regression tests to validate various scenarios.
- `SqlScriptDom/Parser/TSql/TSql80ParserBaseInternal.cs`: Refactor...
* Merged PR 1932484: Adding release notes for 170.157.0
# Pull Request Template for ScriptDom
## Description
Adding release notes for 170.157.0
Before submitting your pull request, please ensure you have completed the following:
## Code Change
- [ ] The [Common checklist](https://msdata.visualstudio.com/SQLToolsAndLibraries/_git/Common?path=/Templates/PR%20Checklist%20for%20SQLToolsAndLibraries.md&version=GBmain&_a=preview) has been reviewed and followed
- [ ] Code changes are accompanied by appropriate unit tests
- [ ] Identified and included SMEs needed to review code changes
- [ ] Follow the [steps](https://msdata.visualstudio.com/SQLToolsAndLibraries/_wiki/wikis/SQLToolsAndLibraries.wiki/33838/Adding-or-Extending-TSql-support-in-Sql-Dom?anchor=make-the-changes-in) here to make changes in the code
## Testing
- [ ] Follow the [steps](https://msdata.visualstudio.com/SQLToolsAndLibraries/_wiki/wikis/SQLToolsAndLibraries.wiki/33838/Adding-or-Extending-TSql-support-in-Sql-Dom?anchor=to-extend-the-tests-do-the-following%3A) here to add new tests for your feature
## Documentation
- [ ] Update relevant documentation in the [wiki](https://dev.azure.com/msdata/SQLToolsAndLibraries/_wiki/wikis/SQLToolsAndLibraries.wiki) and the README.md file
## Additional Information
Please provide any additional information that might be helpful for the reviewers
Adding release notes for 170.157.0
----
#### AI description (iteration 1)
#### PR Classification
Documentation update providing the release notes for version 170.157.0.
#### PR Summary
This pull request adds a new release notes file for Microsoft.SqlServer.TransactSql.ScriptDom 170.157.0, detailing supported platforms, dependency updates, new AI function support, and fixes for specific issues.
- `release-notes/170/170.157.0.md`: New file containing the release information including target platform support, updated .NET SDK dependency (8.0.415), addition of Fabric DW-specific AI functions, and fixes for issues #161 and #28.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
---------
Co-authored-by: Maksim Vlasov <maksimvlasov@microsoft.com>
Co-authored-by: Aasim Khan <Aasim.Khan@microsoft.com>1 parent ab77781 commit c152271
File tree
40 files changed
+1651
-105
lines changed- .github/instructions
- SqlScriptDom
- Parser/TSql
- ScriptDom/SqlServer/ScriptGenerator
- Test/SqlDom
- Baselines160
- Baselines170
- BaselinesFabricDW
- TestScripts
- release-notes/170
40 files changed
+1651
-105
lines changedLines changed: 21 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
93 | 114 | | |
94 | 115 | | |
95 | 116 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
76 | 89 | | |
77 | 90 | | |
| 91 | + | |
| 92 | + | |
78 | 93 | | |
79 | 94 | | |
80 | 95 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
63 | | - | |
64 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
65 | 73 | | |
66 | 74 | | |
| 75 | + | |
| 76 | + | |
67 | 77 | | |
68 | 78 | | |
69 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
16 | 53 | | |
17 | 54 | | |
18 | 55 | | |
| |||
29 | 66 | | |
30 | 67 | | |
31 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
32 | 93 | | |
33 | 94 | | |
34 | 95 | | |
| |||
639 | 700 | | |
640 | 701 | | |
641 | 702 | | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
642 | 749 | | |
643 | 750 | | |
644 | 751 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4769 | 4769 | | |
4770 | 4770 | | |
4771 | 4771 | | |
| 4772 | + | |
| 4773 | + | |
| 4774 | + | |
| 4775 | + | |
| 4776 | + | |
| 4777 | + | |
| 4778 | + | |
| 4779 | + | |
| 4780 | + | |
| 4781 | + | |
| 4782 | + | |
| 4783 | + | |
| 4784 | + | |
| 4785 | + | |
| 4786 | + | |
| 4787 | + | |
| 4788 | + | |
| 4789 | + | |
| 4790 | + | |
| 4791 | + | |
| 4792 | + | |
| 4793 | + | |
| 4794 | + | |
| 4795 | + | |
| 4796 | + | |
| 4797 | + | |
| 4798 | + | |
| 4799 | + | |
| 4800 | + | |
| 4801 | + | |
| 4802 | + | |
| 4803 | + | |
4772 | 4804 | | |
4773 | 4805 | | |
4774 | 4806 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
104 | 111 | | |
105 | 112 | | |
106 | 113 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19142 | 19142 | | |
19143 | 19143 | | |
19144 | 19144 | | |
| 19145 | + | |
| 19146 | + | |
| 19147 | + | |
19145 | 19148 | | |
| 19149 | + | |
| 19150 | + | |
| 19151 | + | |
| 19152 | + | |
| 19153 | + | |
| 19154 | + | |
| 19155 | + | |
| 19156 | + | |
| 19157 | + | |
19146 | 19158 | | |
19147 | | - | |
| 19159 | + | |
19148 | 19160 | | |
19149 | 19161 | | |
19150 | 19162 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
73 | 112 | | |
74 | 113 | | |
0 commit comments