clickhouse-java icon indicating copy to clipboard operation
clickhouse-java copied to clipboard

About com.clickhouse.jdbc.internal.SqlParser Parsing error

Open livk-cloud opened this issue 8 months ago • 2 comments

Expected Behaviour

The number of parameters parsed normally should be 1, while the number of parameters currently parsed is 0

This will cause java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0 to appear when using alter

Code Example


@Test
	void test() {
		SqlParser sqlParser = new SqlParser();
		System.out.println(sqlParser.parsePreparedStatement("alter table user delete where reg_time = ?").getArgCount());
	}

Environment

  • Client version: 0.9.0

livk-cloud avatar Jun 12 '25 09:06 livk-cloud

@livk-cloud thank you for reporting! We will look into this.

chernser avatar Jun 12 '25 17:06 chernser

The same out of bounds exception happens when using the Flyway integration. The queries used to check if the database exists get parsed with zero arguments: SELECT COUNT() FROM system.databases WHERE name = ? https://github.com/flyway/flyway-community-db-support/blob/main/flyway-database-clickhouse/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseSchema.java#L41

alexkops avatar Jun 16 '25 14:06 alexkops