Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
d1703cc
fixes CTE parsing issue and using table as alias
chernser Sep 10, 2025
1f30b73
Merge branch 'main' into jdbc_fix_cte_parse
chernser Sep 25, 2025
e9fe471
Merge branch 'main' into jdbc_fix_cte_parse
chernser Sep 28, 2025
9f4aa7a
Added more tests
chernser Oct 1, 2025
2113b87
filled test statements
chernser Oct 3, 2025
3a96804
moved parser to separate package to track coverage
chernser Oct 3, 2025
25cca50
fixed show statement tests
chernser Oct 6, 2025
6f7e415
Fixed statements with result set and several other
chernser Oct 7, 2025
b2d2399
fixed GRANT stmts and added REVOKE statements
chernser Oct 7, 2025
dfc938c
fixed more statement tests
chernser Oct 7, 2025
aefc7c9
added MOVE and UNDROP statements
chernser Oct 7, 2025
4efa2c1
Fixed quota statements
chernser Oct 7, 2025
25549e7
Fixed insert statements
chernser Oct 7, 2025
f9dd217
Fixed CTE and some minor bugs
chernser Oct 9, 2025
8db01eb
fixed CTE arguments positioning and fixed add column expression
chernser Oct 14, 2025
07eac76
fixed more statements
chernser Oct 14, 2025
0f04adf
fixed column position in alter statement and renamed QUERY to JDBC_PA…
chernser Oct 15, 2025
3e18522
created a SQL parser facade to implement SQL parser selection
chernser Oct 16, 2025
9cb7738
implemented antlr4 two variants
chernser Oct 17, 2025
0cbf958
Fixed issue with # comments
chernser Oct 17, 2025
505272d
Added javaCC parser implementation. not a default. some tests failing
chernser Oct 20, 2025
fdfc35b
Fixed javacc to support single line comments and some new statements
chernser Oct 22, 2025
f02382f
Fixed some keyword issues
chernser Oct 24, 2025
6372e4e
Fixed some more antlr4 issues
chernser Oct 25, 2025
cf863d4
Merge branch 'main' into jdbc_fix_cte_parse
chernser Oct 27, 2025
4f45dc8
Added a few SQL tests fro Statement/PreparedStatement. Addded more te…
chernser Oct 27, 2025
b930ca2
Fixed javaCC for set roles statements and getting correct table name
chernser Oct 27, 2025
24c8e81
Added new statements to javacc. fixed some existing statements
chernser Oct 27, 2025
5f172d2
fixed alter table - type is not required.
chernser Oct 27, 2025
967e7dc
added tests with lambda
chernser Oct 28, 2025
8b2406e
fixed ANTLR4 for expressions with IP keyword
chernser Oct 29, 2025
2b108b0
fixed in statement with multiple arguments
chernser Oct 29, 2025
b773b7e
fixed problem with detecting function in insert statement
chernser Oct 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixed more statement tests
  • Loading branch information
chernser committed Oct 7, 2025
commit dfc938ca62e0fc6a04892e8f447ef712b3fb1145
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ ENGINES : E N G I N E S;
ESTIMATE : E S T I M A T E;
EVENTS : E V E N T S;
EXCEPT : E X C E P T;
EXCHANGE : E X C H A N G E;
EXISTS : E X I S T S;
EXPLAIN : E X P L A I N;
EXPRESSION : E X P R E S S I O N;
Expand Down Expand Up @@ -241,6 +242,7 @@ REVOKE : R E V O K E;
QUARTER : Q U A R T E R;
QUEUE : Q U E U E ;
QUEUES : Q U E U E S ;
QUERY_SQL : Q U E R Y; // conflicts with '?'
QUOTA : Q U O T A;
QUOTAS : Q U O T A S ;
RABBITMQ : R A B B I T M Q;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ query
| ctes? selectStmt
| grantStmt
| revokeStmt
| exchangeStmt
;

// CTE statement
Expand Down Expand Up @@ -368,10 +369,12 @@ describeStmt
// DROP statement

dropStmt
: (DETACH | DROP) DATABASE (IF EXISTS)? databaseIdentifier clusterClause? # DropDatabaseStmt
| (DETACH | DROP) (DICTIONARY | TEMPORARY? TABLE | VIEW | ROLE | USER) (IF EXISTS)? tableIdentifier clusterClause? (
NO DELAY
)? # DropTableStmt
: (DETACH | DROP) DATABASE (IF EXISTS)? databaseIdentifier clusterClause? SYNC?
| (DETACH | DROP) (DICTIONARY | TEMPORARY? TABLE | VIEW) (IF EXISTS)? tableIdentifier clusterClause?
(NO DELAY)? SYNC?
| (DETACH | DROP) (USER | ROLE | QUOTA | SETTINGS? PROFILE) (IF EXISTS)? identifier clusterClause? (FROM identifier)?
| (DETACH | DROP) ROW? POLICY (IF EXISTS)? identifier ON grantTableIdentifier (COMMA grantTableIdentifier)* clusterClause? (FROM identifier)?
| (DETACH | DROP) (FUNCTION | NAMED COLLECTION) (IF EXISTS)? identifier clusterClause?
;

// EXISTS statement
Expand Down Expand Up @@ -419,7 +422,8 @@ assignmentValue
// KILL statement

killStmt
: KILL MUTATION clusterClause? whereClause (SYNC | ASYNC | TEST)? # KillMutationStmt
: KILL MUTATION clusterClause? whereClause (SYNC | ASYNC | TEST)? (FORMAT identifier)? # KillMutationStmt
| KILL QUERY_SQL clusterClause? whereClause (SYNC | ASYNC | TEST)? (FORMAT identifier)? # KillQueryStmt
;

// OPTIMIZE statement
Expand All @@ -432,6 +436,7 @@ optimizeStmt

renameStmt
: RENAME TABLE tableIdentifier TO tableIdentifier (COMMA tableIdentifier TO tableIdentifier)* clusterClause?
| RENAME
;

// PROJECTION SELECT statement
Expand Down Expand Up @@ -608,6 +613,12 @@ winFrameBound

//rangeClause: RANGE LPAREN (MIN identifier MAX identifier | MAX identifier MIN identifier) RPAREN;

// EXCHANGE statement
exchangeStmt
: EXCHANGE (TABLES|DICTIONARIES) tableIdentifier AND tableIdentifier clusterClause?
;


// SET statement

setStmt
Expand All @@ -627,11 +638,9 @@ setRolesList
// GRANT statements

grantStmt
: GRANT clusterClause? identifier (COMMA identifier)* TO (CURRENT_USER | identifier (COMMA identifier)*)
(WITH ADMIN OPTION)? (WITH REPLACE OPTION)?
| GRANT clusterClause? privelegeList ON grantTableIdentifier
: GRANT clusterClause? ((identifier (COMMA identifier)*) | (privelegeList ON grantTableIdentifier))
TO (CURRENT_USER | identifier) (COMMA identifier)*
(WITH GRANT OPTION)? (WITH REPLACE OPTION)?
(WITH ADMIN OPTION)? (WITH GRANT OPTION)? (WITH REPLACE OPTION)?
| GRANT CURRENT GRANTS (LPAREN ((privelegeList ON grantTableIdentifier) | (identifier (COMMA identifier)*)) RPAREN)?
TO (CURRENT_USER | identifier (COMMA identifier)*)
(WITH GRANT OPTION)? (WITH REPLACE OPTION)?
Expand Down Expand Up @@ -1250,6 +1259,7 @@ keyword
| PRECEDING
| PREWHERE
| PRIMARY
| PROFILE
| RANGE
| RELOAD
| REMOVE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,8 @@ public static Object[][] testStatementWithoutResultSetDP() {
{"GRANT SELECT ON db.* TO john", 0, false},
{"GRANT ON CLUSTER `default` SELECT(a, b) ON db1.tableA TO `user` WITH GRANT OPTION WITH REPLACE OPTION", 0, false},
{"GRANT SELECT ON db.* TO user01 WITH REPLACE OPTION", 0, false},
{"GRANT ON CLUSTER role1, role2 TO `user01` WITH ADMIN OPTION WITH REPLACE OPTION", 0, false},
{"GRANT ON CLUSTER `default` role1, role2 TO `user01` WITH ADMIN OPTION WITH REPLACE OPTION", 0, false},
{"GRANT role1, role2 TO `user01` WITH ADMIN OPTION WITH REPLACE OPTION", 0, false},
{"GRANT CURRENT GRANTS TO user01", 0, false},
{"REVOKE SELECT(a,b) ON db1.tableA FROM `user01`", 0, false},
{"REVOKE SELECT ON db1.* FROM ALL", 0, false},
Expand All @@ -577,7 +578,9 @@ public static Object[][] testStatementWithoutResultSetDP() {
{"DROP TABLE `db1`.`table01`", 0, false},
{"DROP DICTIONARY `dict1`", 0, false},
{"DROP ROLE IF EXISTS `role01`", 0 , false},
{"DROP POLICY IF EXISTS `pol1`", 0, false},
{"DROP POLICY IF EXISTS `pol1` ON db1.table1 ON CLUSTER `default` FROM `test`", 0, false},
{"DROP POLICY IF EXISTS `pol1` ON db1.table1 ON CLUSTER `default`", 0, false},
{"DROP POLICY IF EXISTS `pol1` ON table1", 0, false},
{"DROP QUOTA IF EXISTS q1", 0, false},
{"DROP SETTINGS PROFILE IF EXISTS `profile1` ON CLUSTER `default`", 0, false},
{"DROP VIEW view1 ON CLUSTER `default` SYNC", 0, false},
Expand Down Expand Up @@ -607,6 +610,7 @@ public static Object[][] testStatementWithoutResultSetDP() {
{"EXCHANGE DICTIONARIES dict1 AND dict2 ON CLUSTER `default`", 0, false},
{"SET profile = 'profile-name-from-the-settings-file'", 0, false},
{"SET use_some_feature_flag", 0, false},
{"SET use_some_feature_flag = 'true'", 0, false},
{"SET ROLE role1", 0, false},
{"SET DEFAULT ROLE role1 TO user", 0, false},
{"SET DEFAULT ROLE NONE TO user", 0, false},
Expand Down