You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Error handling the CTE INSERT command: Failed to parse SQL. #3279
bugjdbcModule: the JDBC driver (jdbc-v2; with legacy: the v1 driver)queriesArea: how the client builds and runs statements (parameters, quoting, batches)sql-parserDetail: the SQL parser of the JDBC driver (v1 and v2)
High Level Area Labels:
- jdbc-v2
Specific Area Labels:
- jdbc-insert
- client-insert
Description
Steps to reproduce
for examples , create table test123
CREATETABLEIF NOT EXISTS test123
(
`timestamp` DateTime64(9, 'UTC'),
`eid` UInt64,
) ENGINE = MergeTree()
PARTITION BY toYYYYMMDD(timestamp)
ORDER BY (timestamp);
execute this sql
with a as (
SELECTtimestamp,eid
FROM test123
),
b as ( SELECTtimestamp,eid
FROM test123 )
insert into test123(`timestamp`,eid)
SELECT a.`timestamp`,b.eidFROM a left join b ona.eid=b.eid ;
The SQL server executed successfully, but the client-side parsing failed,Maybe this is a bug in the JavaCC parser
Error Log or Exception StackTrace
WARN c.c.j.i.p.j.ClickHouseSqlParser [76] - Failed to parse SQL. If you believe the SQL is valid, please feel free to open an issue on GitHub with this warning. Enable DEBUG logging for details.
This is a logging issue because client may not follow ClickHouse in syntax parsing and we just use parser to get needed information.
Fix in parser may break someone`s case.
Recommendation: Keep open — fix needed
Only the log is wrong: the statement runs and gives the correct update count. Open PR #3300 removes this WARN (its parser change alone makes the run below print none), but it has merge conflicts with main and a change request.
Status on main: Reproduced on main — the issue's statement logs the WARN for each run; execute() and executeUpdate() give the same results as an INSERT without WITH.
Breaking change: No — the removal of the WARN changes only the log output.
Duplicates / related: No others
Analysis: The default JavaCC grammar accepts WITH only in front of SELECT (selectStmt, ClickHouseSqlParser.jj:668), and insertStmt starts with INSERT INTO (:594). So the parse fails, ClickHouseSqlParser.jj:101 logs the WARN, and the statement stays UNKNOWN; the run shows that this does not change the execute() result or the update count.
Reproduction: complete program and output
Changed from the issue's steps: one row in the table, executeUpdate(), and an INSERT without WITH as a contrast. Run with slf4j-simple on the classpath, so that the WARN prints.
WARN ClickHouseSqlParser - Failed to parse SQL. If you believe the SQL is valid, …
CTE INSERT execute(): false, getUpdateCount(): 1, rows now: 2
WARN ClickHouseSqlParser - Failed to parse SQL. If you believe the SQL is valid, …
CTE INSERT executeUpdate(): 4, rows now: 6
INSERT without WITH execute(): false, getUpdateCount(): 6, rows now: 12
Output with the ClickHouseSqlParser.jj change of PR #3300 (the full diff does not apply to main):
bugjdbcModule: the JDBC driver (jdbc-v2; with legacy: the v1 driver)queriesArea: how the client builds and runs statements (parameters, quoting, batches)sql-parserDetail: the SQL parser of the JDBC driver (v1 and v2)
Activity
fiend19961 commentedon Nov 12, 2026
ClickHouse/ClickHouse#85368
ClickHouse/ClickHouse#87789
same issues @chernser
chernser commentedon Nov 17, 2026
@fiend19961
Thank you for reporting!
Will be fixed as part of #3300
This is a logging issue because client may not follow ClickHouse in syntax parsing and we just use parser to get needed information.
Fix in parser may break someone`s case.
polyglotAI-bot commentedon Nov 27, 2026
Recommendation: Keep open — fix needed
Only the log is wrong: the statement runs and gives the correct update count. Open PR #3300 removes this WARN (its parser change alone makes the run below print none), but it has merge conflicts with
mainand a change request.main: Reproduced on main — the issue's statement logs the WARN for each run;execute()andexecuteUpdate()give the same results as an INSERT withoutWITH.Analysis: The default JavaCC grammar accepts
WITHonly in front ofSELECT(selectStmt,ClickHouseSqlParser.jj:668), andinsertStmtstarts withINSERT INTO(:594). So the parse fails,ClickHouseSqlParser.jj:101logs the WARN, and the statement staysUNKNOWN; the run shows that this does not change theexecute()result or the update count.Reproduction: complete program and output
Changed from the issue's steps: one row in the table,
executeUpdate(), and an INSERT withoutWITHas a contrast. Run withslf4j-simpleon the classpath, so that the WARN prints.Output on
main(8480ca001), ClickHouse 26.11.2.4:Output with the
ClickHouseSqlParser.jjchange of PR #3300 (the full diff does not apply tomain):Automated triage by Polyglot AI. A maintainer makes the final decision.