Skip to content

Commit 5b5082a

Browse files
committed
fixed parser to handle '^' in statements
1 parent f0f296a commit 5b5082a

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

jdbc-v2/src/main/javacc/ClickHouseSqlParser.jj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ void columnExpr(): { Token t; } {
831831
| (LOOKAHEAD(2) macro())+
832832
| LOOKAHEAD(2, { !(tokenIn(1, INF, NAN, NULL) && tokenIn(2, DOT)) }) literal()
833833
| LOOKAHEAD(2, { getToken(2).kind == LPAREN }) functionExpr() { token_source.funcUsed = true; }
834-
| anyIdentifier() (LOOKAHEAD(2) <DOT> anyIdentifier())*
834+
| anyIdentifier() (LOOKAHEAD(2) <DOT> (<CARET>)? anyIdentifier())*
835835
}
836836

837837
// interested parts
@@ -930,7 +930,7 @@ Token aliasExpr(): { Token t = null; } {
930930
}
931931

932932
void nestedIdentifier(): {} {
933-
(<ASTERISK> | anyIdentifier()) (LOOKAHEAD(2) <DOT> (<ASTERISK> | anyIdentifier()))*
933+
(<ASTERISK> | anyIdentifier()) (LOOKAHEAD(2) <DOT> (<CARET>)? (<ASTERISK> | anyIdentifier()))*
934934
}
935935

936936
void tableIdentifier(boolean record): { } {
@@ -1029,7 +1029,7 @@ Token numberLiteral(): { Token t = null; StringBuilder sb = new StringBuilder();
10291029
}
10301030

10311031
void operator(): {} {
1032-
(<ARROW> | <ASTERISK> | <CONCAT> | <CONVERT> | <DASH> | <EQ_DOUBLE> | <EQ_SINGLE>
1032+
(<ARROW> | <ASTERISK> | <CARET> | <CONCAT> | <CONVERT> | <DASH> | <EQ_DOUBLE> | <EQ_SINGLE>
10331033
| <GE> | <GT> | <LE> | <LT> | <NOT_EQ> | <PERCENT> | <PLUS> | <SLASH>)
10341034
}
10351035

@@ -1286,6 +1286,7 @@ TOKEN: {
12861286
| <RPAREN: ")">
12871287
| <SEMICOLON: ";">
12881288
| <SLASH: "/">
1289+
| <CARET: "^">
12891290
| <#UNDERSCORE: "_">
12901291
}
12911292

jdbc-v2/src/test/java/com/clickhouse/jdbc/internal/BaseSqlParserFacadeTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,8 @@ public static Object[][] testStatementWithoutResultSetDP() {
652652
{"CHECK GRANT SELECT(col2) ON table_2", 0, true},
653653
{"CHECK TABLE test_table", 0, true},
654654
{"CHECK TABLE t0 PARTITION ID '201003' FORMAT PrettyCompactMonoBlock SETTINGS check_query_single_value_result = 0", 0, true},
655-
655+
{"select toJSONString(data.^header_index) from database.analyzed limit 1;", 0, true},
656+
{"select toJSONString(data.^header_index), ? as text from database.analyzed limit 1;", 1, true},
656657

657658
/* no result set */
658659
{"INSERT INTO test_table VALUES (1, ?)", 1, false},

0 commit comments

Comments
 (0)