-
Couldn't load subscription status.
- Fork 614
[JDBC-V2] Fix Parser Issues #2579
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
Client V2 CoverageCoverage Report
Class Coverage
|
JDBC V2 CoverageCoverage Report
Class Coverage
|
JDBC V1 CoverageCoverage Report
Class Coverage
|
Client V1 CoverageCoverage Report
Class Coverage
|
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.
Other comments (3)
- jdbc-v2/src/main/antlr4/com/clickhouse/jdbc/internal/parser/ClickHouseParser.g4 (490-490) There's a commented-out alternative in the cteUnboundCol rule (`// | LPAREN cteStmt? selectStmt RPAREN AS identifier # CteUnboundNestedSelect`). This suggests there might be an unresolved issue with handling nested selects in CTEs. Either implement this properly or remove the comment to avoid confusion.
- client-v2/src/test/java/com/clickhouse/client/datatypes/DataTypeTests.java (543-545) Consider using RoundingMode.HALF_UP or RoundingMode.HALF_EVEN instead of FLOOR for decimal comparisons. FLOOR always rounds down which might not be appropriate for all test cases, especially when dealing with financial data.
- jdbc-v2/src/test/java/com/clickhouse/jdbc/internal/SqlParserTest.java (240-240) The error message doesn't match the assertion. Consider changing to `Assert.assertFalse(stmt.isHasErrors(), "Statement has parsing errors")` for clarity.
💡 To request another review, post a new comment with "/windsurf-review".
jdbc-v2/src/test/java/com/clickhouse/jdbc/internal/SqlParserTest.java
Outdated
Show resolved
Hide resolved
jdbc-v2/src/main/antlr4/com/clickhouse/jdbc/internal/parser/antlr4/ClickHouseParser.g4
Show resolved
Hide resolved
jdbc-v2/src/main/antlr4/com/clickhouse/jdbc/internal/parser/antlr4/ClickHouseParser.g4
Show resolved
Hide resolved
jdbc-v2/src/test/java/com/clickhouse/jdbc/internal/BaseSqlParserFacadeTest.java
Show resolved
Hide resolved
jdbc-v2/src/main/antlr4/com/clickhouse/jdbc/internal/parser/ClickHouseParser.g4
Outdated
Show resolved
Hide resolved
|
| | SYSTEM DROP UNCOMPRESSED CACHE | ||
| | SYSTEM DROP COMPILED EXPRESSION CACHE | ||
| | SYSTEM DROP QUERY CONDITION CACHE | ||
| | SYSTEM DROP QUERY CACHE (TAG literal)? |
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.
QUERY_SQL or QUERY ?
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.
Hello,
In ClickHouseLexer.g4, two distinct tokens are defined:
QUERY : '?';
QUERY_SQL : Q U E R Y;
However, in ClickHouseParser.g4, the rule for SYSTEM DROP ... CACHE uses the QUERY token:
SYSTEM DROP QUERY CACHE
The parser rule should be updated to use the QUERY_SQL token, which correctly represents the literal keyword.
The line should be changed from:
SYSTEM DROP QUERY CACHE
To:
SYSTEM DROP QUERY_SQL CACHE
This will ensure the grammar correctly parses the valid ClickHouse SQL syntax.
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.
Yes, you are right.
Thank you!
Seems I need to rename query to JDBC_PARAM
…RAM_PLACEHOLDER to avoid mistakes
|
Hello. To help identify and address any remaining gaps, I would like to propose leveraging the extensive suite of test queries directly from the official ClickHouse repository. These queries are used to test the native ClickHouse parser and represent a massive collection of valid (and invalid) SQL statements. The official test suite can be found here: https://github.com/ClickHouse/ClickHouse/tree/master/tests/queries |
|
Good day, @EastLord ! Many thanks to your help and suggestions! yes, we have already run tests from this suite. However it requires porting tests to Java, there are no JDBC parameter tests what adds another dimension for tests. |
| * </ul> | ||
| */ | ||
| // SQL_PARSER("jdbc_sql_parser", "JAVACC", List.of("ANTLR4", "ANTLR4_PARAMS_PARSER", "JAVACC")), | ||
| SQL_PARSER("jdbc_sql_parser", "ANTLR4", List.of("ANTLR4", "ANTLR4_PARAMS_PARSER", "JAVACC")), |
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.
Setting to ANTLR4 means that we are using ANTLR4 as the default one?
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.
Thank you for catching it!
Yes, we need to use JAVACC by default.
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.
There are 2 failing tests
- com.clickhouse.client.ParameterizedQueryTest.testParamsWithInstant
- PreparedStatementTest.testMetabaseBug01
|
@mzitnik |
|



Summary
This PR introduces option to select old JavaCC parser that is proven to work and has more relaxed rules. Parameter parsing code is ported from older version as most stable logic. And this PR will make old parser as choice by default so it will work almost like JDBC V1.
And:
Closes #2574
Closes #2568
Closes #2537
Closes #2595
Closes #2617
Closes #2569
Closes #2570
Closes #2571
Closes #2572
Closes #2573
Closes #2609
Checklist
Delete items not relevant to your PR: