Skip to content
Merged
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
Added more tests
  • Loading branch information
chernser committed Oct 1, 2025
commit 9f4aa7a47bb86fbaa337126dc9c167f921745b92
Original file line number Diff line number Diff line change
Expand Up @@ -418,4 +418,67 @@ public Object[][] testMiscStmtDp() {
"WHERE\n" +
" EventDate = toDate(?) AND\n" +
" EventTime <= ts_upper_bound;";


@Test(dataProvider = "testStatementWithoutResultSetDP")
public void testStatementWithoutResultSet(String sql, int args, boolean hasResultSet) {
SqlParser parser = new SqlParser();
{
ParsedPreparedStatement stmt = parser.parsePreparedStatement(sql);
Assert.assertEquals(stmt.getArgCount(), args);
assertEquals(stmt.isHasResultSet(), hasResultSet, "Statement result set expectation does not match");
Assert.assertFalse(stmt.isHasErrors(), "Statement has errors");
}

{
ParsedStatement stmt = parser.parsedStatement(sql);
assertEquals(stmt.isHasResultSet(), hasResultSet, "Statement result set expectation does not match");
Assert.assertFalse(stmt.isHasErrors(), "Statement has errors");
}
}

@DataProvider
public static Object[][] testStatementWithoutResultSetDP() {
return new Object[][]{
{"INSERT INTO test_table VALUES (1, ?)", 1, false},
{"SELECT * FROM test_table", 0, true},
{"CREATE DATABASE `test_db`", 0, false},
{"CREATE DATABASE `test_db` COMMENT 'for tests'", 0, false},
{"CREATE DATABASE IF NOT EXISTS `test_db`", 0, false},
{"CREATE DATABASE IF NOT EXISTS `test_db` ON CLUSTER `cluster`", 0, false},
{"CREATE DATABASE IF NOT EXISTS `test_db` ON CLUSTER `cluster` ENGINE = Replicated('clickhouse1:9000', 'test_db')", 0, false},
{"CREATE TABLE `test_table` (id UInt64)", 0, false},
{"CREATE TABLE IF NOT EXISTS `test_table` (id UInt64)", 0, false},
{"CREATE TABLE `test_table` (id UInt64) ENGINE = MergeTree() ORDER BY id", 0, false},
{"CREATE TABLE `test_table` (id UInt64) ENGINE = MergeTree() ORDER BY id ON CLUSTER `cluster`", 0, false},
{"CREATE TABLE `test_table` (id UInt64) ENGINE = MergeTree() ORDER BY id ON CLUSTER `cluster` ENGINE = Replicated('clickhouse1:9000', 'test_db')", 0, false},
{"CREATE TABLE `test_table` (id UInt64) ENGINE = MergeTree() ORDER BY id ON CLUSTER `cluster` ENGINE = Replicated('clickhouse1:9000', 'test_db') COMMENT 'for tests'", 0, false},
{"CREATE VIEW `test_db`.`source_table` source AS ( SELECT * FROM source_a UNION SELECT * FROM source_b)", 0, false},
{"CREATE OR REPLACE VIEW `test_db`.`source_table` source AS ( SELECT * FROM source_a UNION SELECT * FROM source_b)", 0, false},
{"CREATE OR REPLACE VIEW `test_db`.`source_table` source ON CLUSTER `cluster` AS ( SELECT * FROM source_a UNION SELECT * FROM source_b)", 0, false},
{"CREATE VIEW `test_db`.`source_table` source AS ( SELECT * FROM source_a UNION SELECT * FROM source_b) ENGINE = MaterializedView", 0, false},
{"CREATE VIEW `test_db`.`source_table` source AS ( SELECT * FROM source_a UNION SELECT * FROM source_b) ENGINE = MaterializedView()", 0, false},
{"CREATE VIEW `test_db`.`source_table` source AS ( SELECT * FROM source_a UNION SELECT * FROM source_b) ENGINE = MaterializedView() COMMENT 'for tests'", 0, false},
{"CREATE DICTIONARY `test_db`.dict1 (k1 UInt64 EXPRESSION(k1 + 1), k2 String DEFAULT 'default', a1 Array(UInt64) DEFAULT []) PRIMARY KEY k1 SOURCE(CLICKHOUSE(db='test_db', table='dict1')) LAYOUT(FLAT()) LIFETIME(MIN 1000 MAX 2000)", 0, false},
{"CREATE DICTIONARY `test_db`.dict1 (k1 UInt64 (k1 + 1), k2 String DEFAULT 'default', a1 Array(UInt64) DEFAULT []) PRIMARY KEY k1 SOURCE(CLICKHOUSE(db='test_db', table='dict1')) LAYOUT(FLAT()) LIFETIME(MIN 1000 MAX 2000) SETTINGS cache_size = 1000 COMMENT 'for tests'", 0, false},
{"CREATE OR REPLACE DICTIONARY IF NOT EXISTS `test_db`.dict1 (k1 UInt64 (k1 + 1), k2 String DEFAULT 'default', a1 Array(UInt64) DEFAULT []) PRIMARY KEY k1 SOURCE(CLICKHOUSE(db='test_db', table='dict1')) LAYOUT(FLAT()) LIFETIME(MIN 1000 MAX 2000) SETTINGS cache_size = 1000 COMMENT 'for tests'", 0, false},
{"CREATE OR REPLACE DICTIONARY IF NOT EXISTS `dict1` (k1 UInt64 (k1 + 1), k2 String DEFAULT 'default', a1 Array(UInt64) DEFAULT []) PRIMARY KEY k1 SOURCE(CLICKHOUSE(db='test_db', table='dict1')) LAYOUT(FLAT()) LIFETIME(MIN 1000 MAX 2000) SETTINGS cache_size = 1000 COMMENT 'for tests'", 0, false},
{"CREATE FUNCTION test_func AS () -> 10", 0, false},
{"CREATE FUNCTION test_func AS (x) -> 10 * x", 0, false},
{"CREATE FUNCTION test_func AS (x, y) -> y * x", 0, false},
{"CREATE FUNCTION test_func ON CLUSTER `cluster` AS (x, y) -> y * x", 0, false},
{"CREATE USER IF NOT EXISTS `user`", 0, false},
{"CREATE USER IF NOT EXISTS `user` ON CLUSTER `cluster`", 0, false},
{"CREATE ROLE IF NOT EXISTS `role1` ON CLUSTER", 0, false},
{"CREATE ROW POLICY pol1 ON mydb.table1 USING b=1 TO mira, peter", 0, false},
{"CREATE ROW POLICY pol2 ON mydb.table1 USING c=2 TO peter, antonio", 0, false},
{"CREATE ROW POLICY pol2 ON mydb.table1 USING c=2 AS RESTRICTIVE TO peter, antonio", 0, false},
{"CREATE QUOTA qA FOR INTERVAL 15 month MAX queries = 123 TO CURRENT_USER", 0, false},
{"CREATE QUOTA qB FOR INTERVAL 30 minute MAX execution_time = 0.5, FOR INTERVAL 5 quarter MAX queries = 321, errors = 10 TO default", 0, false},
{"CREATE SETTINGS PROFILE max_memory_usage_profile SETTINGS max_memory_usage = 100000001 MIN 90000000 MAX 110000000 TO robin", 0, false},
{"CREATE NAMED COLLECTION foobar AS a = '1', b = '2' OVERRIDABLE", 0, false},


};
}
}