jdbc-v2: allow new ClickHouse keywords in identifier positions - #3115
Open
polyglotAI-bot wants to merge 1 commit into
Open
jdbc-v2: allow new ClickHouse keywords in identifier positions#3115polyglotAI-bot wants to merge 1 commit into
polyglotAI-bot wants to merge 1 commit into
Conversation
ClickHouse 26.8 adds the non-reserved keywords AGGREGATE, BOUNDED, EXTEND, HANDLER, PROTOCOL, UNORDERED and the multi-word keywords IDLE TIMEOUT and RECENT SAMPLES to system.keywords. None of them were listed in ALLOWED_KEYWORD_ALIASES, so StatementSQLTest#testAllowedKeywordAliasesMatchSystemKeywords failed against the latest server. The server accepts every one of them as a column or table alias, so they belong in the allowed-alias list rather than in reserved_keywords.txt. Fixes: #3113
|
Client V2 CoverageCoverage Report
Class Coverage
|
JDBC V2 CoverageCoverage Report
Class Coverage
|
JDBC V1 CoverageCoverage Report
Class Coverage
|
Client V1 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.



Description
Fixes #3113.
StatementSQLTest#testAllowedKeywordAliasesMatchSystemKeywordsis a sync guard: it readssystem.keywords, subtracts the driver'sreserved_keywords.txt, and requires every remaining(non-reserved) keyword to be listed in
ClickHouseSqlUtils.ALLOWED_KEYWORD_ALIASES— the set theJavaCC parser consults to accept a keyword in an identifier position. ClickHouse 26.8 added the
keywords
AGGREGATE,BOUNDED,EXTEND,HANDLER,PROTOCOL,UNORDEREDplus the multi-wordkeywords
IDLE TIMEOUTandRECENT SAMPLES(the test splits keywords on whitespace, which yieldsIDLE,TIMEOUTandRECENT). None of the nine were in either list, so the guard failed againstthe latest server.
Categorisation was derived from the server, not from the client: on 26.8.2.7 every one of the nine
is accepted as both an explicit (
SELECT 1 AS <kw>) and an implicit (SELECT 1 <kw>) alias, so allnine are non-reserved and belong in
ALLOWED_KEYWORD_ALIASES, not inreserved_keywords.txt.Changes
jdbc-v2/.../parser/javacc/ClickHouseSqlUtils.java: appended the nine keywords toALLOWED_KEYWORD_ALIASESas a new dated block, following the existing convention.CHANGELOG.md: bug-fix entry under0.11.0-rc1.Deliberately left alone:
reserved_keywords.txt— none of the nine is reserved (verified against the server, see above).TIMEOUTis an ANTLR lexer token, and the ANTLR4backends parse
TIMEOUTin every alias position tested (SELECT 1 AS TIMEOUT, 2 AS b FROM t,SELECT 1 TIMEOUT, 2 AS b FROM t,SELECT * FROM t TIMEOUT WHERE 1 = 1) without errors, so nogrammar change is needed.
allowed_keyword_tablenames.txt— that list is not part of the guarded invariant and previouskeyword updates did not extend it.
Test
No new test: the bug is already pinned by two existing data-driven tests that pick up the new
entries automatically, so a hand-written duplicate would only repeat their coverage (
AGENTS.md:"Don't pad coverage ... Avoid duplicating existing coverage").
StatementSQLTest#testAllowedKeywordAliasesMatchSystemKeywords(integration) — the reportedfailure. Against ClickHouse 26.8.2.7 it fails on
mainwith exactly["AGGREGATE", "BOUNDED", "EXTEND", "HANDLER", "IDLE", "PROTOCOL", "RECENT", "TIMEOUT", "UNORDERED"]and passes with this change.
BaseSqlParserFacadeTest#testKeywordAliasesAsTableNames(unit) — iterates the whole allowed-aliasset and runs for both parser backends (
JavaCCParserTest,Antlr4ParserTest), so it now alsoasserts the nine new keywords parse as aliases in both parsers.
Verified in a devbox with ClickHouse 26.8.2.7:
mvn -pl jdbc-v2 test→ 1894 tests, 0 failures.mvn -pl jdbc-v2 -DskipUTs=true -Dit.test=StatementSQLTest verify→ 6 tests, 0 failures(the guard test fails on
main, passes here).Pre-PR validation gate
mainagainst 26.8+, passes on this branch)jdbc-v2unit suite +StatementSQLTestintegration tests green)AGENTS.md(single logical change, minimal diff, no coverage padding, CHANGELOG updated)docs/features.mdchange (no feature added, removed, or changed)