Repository navigation
[jdbc-v2] Add SEGMENTS, SHARDS keywords for ClickHouse 26.11; accept shards in the ANTLR4 grammar - #3446
Open
polyglotAI-bot wants to merge 1 commit into
Open
[jdbc-v2] Add SEGMENTS, SHARDS keywords for ClickHouse 26.11; accept shards in the ANTLR4 grammar#3446polyglotAI-bot wants to merge 1 commit into
polyglotAI-bot wants to merge 1 commit into
Conversation
Add the SEGMENTS and SHARDS keywords of ClickHouse 26.11 to ALLOWED_KEYWORD_ALIASES, and add the existing SHARDS lexer token to the ANTLR4 parser rules keyword and keywordForAlias, so the ANTLR4 parsers accept `shards` as an identifier or alias. Fixes: #3428 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Auto-approved by the AI review gate on 86e1d19. Details in the approver's comment on this pull request.
AI review gate — auto-approved
History (latest 5 heads, newest first)
|
Client V2 CoverageCoverage Report
Class Coverage
|
JDBC V2 CoverageCoverage Report
Class Coverage
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #3428
ClickHouse 26.11 adds the non-reserved keywords
SEGMENTSandSHARDStosystem.keywords, soStatementSQLTest.testAllowedKeywordAliasesMatchSystemKeywordsfails until they are inALLOWED_KEYWORD_ALIASES. Adding them to the list alone breakstestKeywordAliasesAsTableNamesfor the ANTLR4 parsers:ClickHouseLexer.g4already has aSHARDStoken, but the parser ruleskeywordandkeywordForAliasdo not list it. SoANTLR4andANTLR4_PARAMS_PARSERmarkSELECT 1 AS shardsorINSERT INTO shards VALUES (?)as unparsed (the insert target becomesVALUES).ClickHouseSqlUtils: addSEGMENTSandSHARDSas a dated block (.cursor/skills/update-keyword-engine-lists).ClickHouseParser.g4: addSHARDSafterSHARDinkeywordandkeywordForAlias. No other rule uses an identifier whereSHARDScan occur.GRANT MOVE PARTITION BETWEEN SHARDSstill parses.SEGMENTShas no grammar token in either parser. JavaCC has no token for either word, so the default parser does not change.Compatibility
No API change. With
ANTLR4orANTLR4_PARAMS_PARSER, a statement that usesshardsas a name is now parsed:execute()of such anINSERT/CREATEreturns an update count, and withbeta.row_binary_for_simple_insert=truean insert intoshardsuses the RowBinary writer. Changelog:history/latest/3428.md.Test
BaseSqlParserFacadeTest(runs for all three parsers), new rows:testInsertPlainTableTargetKeepsTableNameandtestInsertTargetTableFunctionIsReportedAsFunction(INSERT INTO shards ..., table nameshards, no function),testMiscStatements(shards/segmentsas alias, column, table, a nested implicit alias, and theGRANT ... BETWEEN SHARDScontrast).testKeywordAliasesAsTableNames). The nested implicit aliasSELECT * FROM (SELECT * FROM t shards) WHERE x = ?is the only row that pinskeywordForAlias: a trailing alias at the end of a statement is dropped without an error.JavaCCParserTest+Antlr4ParserTest+Antlr4ParamsParserTest+ClickHouseSqlParserLoggingTest1888/1888; on ClickHouse 26.11.2.4testAllowedKeywordAliasesMatchSystemKeywordspasses, andStatementSQLTest+StatementTest+PreparedStatementTest+PreparedStatementSQLTest+DatabaseMetaDataTestpass (264/264).Checklist
shardsas an identifier #3428history/latest/3428.md)docs/changes_checklist.md: parser change with focused regression tests; no logging, configuration, default or API change; nodocs/features.mdchange🤖 Generated with Claude Code
Note
Low Risk
Parser and keyword-list updates with no API changes; targeted regression tests cover ANTLR4 parsing and insert classification.
Overview
Adds ClickHouse 26.11 keywords
SEGMENTSandSHARDSto the JDBC v2 allowed keyword alias list inClickHouseSqlUtils, so driver keyword checks align withsystem.keywords.For ANTLR4 parsers,
SHARDSis registered inClickHouseParser.g4underkeywordandkeywordForAlias. Statements that useshardsas a table name, column, or alias (e.g.INSERT INTO shards VALUES (?),SELECT 1 AS shards) now parse correctly instead of failing or mis-identifying the insert target—restoring proper update counts and RowBinary insert behavior whenbeta.row_binary_for_simple_insertis enabled.SEGMENTSis keyword-list only; the default JavaCC parser is unchanged.Tests in
BaseSqlParserFacadeTestcover insert targets, aliases, nested table aliases, DDL with columnsegments, andGRANT ... MOVE PARTITION BETWEEN SHARDS. Changelog:history/latest/3428.md.Reviewed by Cursor Bugbot for commit 86e1d19. Bugbot is set up for automated code reviews on this repo. Configure here.