-
Notifications
You must be signed in to change notification settings - Fork 36
Add support for JSON Index creation syntax in SQL Server 2025 (TSql170) #147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: llali <17187348+llali@users.noreply.github.com>
…eneration Co-authored-by: llali <17187348+llali@users.noreply.github.com>
…orrect baseline Co-authored-by: llali <17187348+llali@users.noreply.github.com>
…sions Co-authored-by: llali <17187348+llali@users.noreply.github.com>
llali
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't add antlr-2.7.5.jar to this PR
|
remove the tmp folder from this PR |
Co-authored-by: llali <17187348+llali@users.noreply.github.com>
Removed antlr-2.7.5.jar from the PR. The file should be downloaded automatically by the build system as configured in Directory.Build.props. (commit 73a1645) |
Co-authored-by: llali <17187348+llali@users.noreply.github.com>
Removed the tmp folder from the PR and added tmp/ to .gitignore to prevent future commits of build artifacts. (commit 9de9b7f) |
Co-authored-by: llali <17187348+llali@users.noreply.github.com>
Co-authored-by: llali <17187348+llali@users.noreply.github.com>
| public void CreateJsonIndexStatementErrorTest() | ||
| { | ||
| // JSON Index syntax should not be supported in SQL Server versions prior to 2025 (TSql170) | ||
| // Test basic JSON Index syntax in older versions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove these, all tests against older parser versions are unnecessary here, they should be covered in Only170SyntaxTests already
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the ErrorTest160 calls from ParserErrorsTests.cs as they are unnecessary - older version rejection is already covered in Only170SyntaxTests. (commit b6073da)
…y TSql170 tests needed Co-authored-by: zijchen <13544267+zijchen@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
SqlScriptDom/Parser/TSql/Ast.xml
Outdated
| <Member Name="JsonColumn" Type="Identifier" Summary="The JSON column for the index."/> | ||
| <Member Name="ForJsonPaths" Type="StringLiteral" Collection="true" Summary="The JSON paths specified in the FOR clause. Optional may have zero elements."/> | ||
| <InheritedMember Name="IndexOptions" ContainerClass="IndexStatement" /> | ||
| <Member Name="OnFileGroupOrPartitionScheme" Type="FileGroupOrPartitionScheme" Summary="The filegroup or partition scheme. Might be null."/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like file group is not supported for json index. remove file group from ast.xml and from TSQL170.g and apply the same change in tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed filegroup support from JSON Index syntax as requested. The changes include:
- Removed
OnFileGroupOrPartitionSchememember from AST - Removed filegroup handling from TSql170.g grammar rule
- Updated script generator to exclude filegroup generation
- Removed filegroup test cases from test scripts and baselines
JSON indexes now support only the core syntax without ON filegroup clause. (commit eee2f48)
Co-authored-by: llali <17187348+llali@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Test/SqlDom/Only170SyntaxTests.cs
Outdated
| private static readonly ParserTest[] Only170TestInfos = | ||
| { | ||
| new ParserTest170("RegexpTVFTests170.sql", nErrors80: 1, nErrors90: 1, nErrors100: 0, nErrors110: 0, nErrors120: 0, nErrors130: 0, nErrors140: 0, nErrors150: 0, nErrors160: 0), | ||
| new ParserTest170("JsonIndexTests170.sql", nErrors80: 2, nErrors90: 10, nErrors100: 10, nErrors110: 10, nErrors120: 10, nErrors130: 10, nErrors140: 10, nErrors150: 10, nErrors160: 10), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix the number of errors after your last commit. it should be 8 errors now not 10
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed the error count from 10 to 8 errors for JSON Index tests. After removing filegroup support, there are now 8 CREATE JSON INDEX statements in the test file instead of 10, so the expected error count for older parser versions was updated accordingly. (commit 04e7f67)
…s after filegroup removal Co-authored-by: llali <17187348+llali@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
This PR implements comprehensive support for JSON Index creation syntax in SQL Server 2025 (TSql170 parser) as requested in the original issue.
Syntax Supported
CREATE JSON INDEX name ON table_name (json_column_name) [ FOR ( sql_json_path [ , ...n ] ) ] [ WITH ( json_index_option [ , ...n ] ) ]Where
json_index_optionincludes:FILLFACTOR = fillfactorDROP_EXISTING = { ON | OFF }ONLINE = OFFALLOW_ROW_LOCKS = { ON | OFF }ALLOW_PAGE_LOCKS = { ON | OFF }MAXDOP = max_degree_of_parallelismDATA_COMPRESSION = { NONE | ROW | PAGE }Implementation Details
AST Support
CreateJsonIndexStatementclass toAst.xmlwith properties:Name- Index nameOnName- Table nameJsonColumn- JSON column referenceJsonPaths- Collection of JSON path strings for FOR clauseIndexOptions- Collection of index options for WITH clauseOnFileGroupOrPartitionScheme- Filegroup specification for ON clauseParser Support
createJsonIndexStatementgrammar rule toTSql170.gNextTokenMatches(CodeGenerationSupporter.Json)Script Generation
SqlScriptGeneratorVisitor.CreateJsonIndexStatement.csTest Coverage
Added comprehensive test suite covering:
Example test cases:
Validation
All tests pass across all SQL Server versions:
The implementation correctly handles version-specific behavior where JSON indexes are only supported in SQL Server 2025 and later.
Fixes #146.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
central.sonatype.comcurl -L -o antlr/antlr-2.7.5.jar REDACTED(dns block)www.antlr2.org/usr/lib/dotnet/dotnet /usr/lib/dotnet/sdk/8.0.117/MSBuild.dll /nologo /nodemode:1 /nodeReuse:true /low:false(dns block)wget -O antlr/antlr-2.7.5.jar REDACTED(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.