Repository navigation
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
Reviewed by Cursor Bugbot for commit 2064b84. Configure here.
AI review gate — AI review passedClean review from: Cursor Bugbot. |
The JavaCC parser never extracted the column list from INSERT statements, so the RowBinary writer always fell back to the full table schema. When columns were reordered or a subset was used, values ended up in the wrong columns or the server rejected the payload. - JavaCCParser.extractInsertColumns() now reads the ColumnsStart/ColumnsEnd positions recorded by the grammar and tokenizes the column list, handling quoted identifiers, dollar signs, nested names, and inline comments. - WriterStatementImpl passes the extracted column names to Client.insert(), quoting them with SQLUtils.enquoteIdentifier() so reserved words and special characters are safe. - Added unit tests for edge cases (dollar signs, comments in column lists) and integration tests for column reordering, subsets, batch inserts, and quoted columns across all three parser backends. Closes ClickHouse#3422
saadfikri
force-pushed
the
fix/3422-writer-insert-column-list
branch
from
November 28, 2026 11:07
2064b84 to
6a4ec67
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Closes #3422
With
beta.row_binary_for_simple_insert=true, the writer ignores thecolumn list in the INSERT and writes values in table order. So
INSERT INTO t (b, a) VALUES (?, ?)puts param 1 intoa, notb.A column subset like
INSERT INTO t (k, b)on a 3-column table hasthe same problem — wrong columns get the data, or you get
CANNOT_READ_ALL_DATAdepending on the parser backend.Two things were wrong:
The default parser (JavaCC) never extracted the column names from
the INSERT. The grammar already tracked the positions but
parsePreparedStatement()skipped them. ANTLR4 did extract them,so this was only broken on the default path.
executeLargeUpdate()used theinsert()overload without columnnames, so the server always got
INSERT INTO t FORMAT RowBinaryand read bytes in table order no matter what.
Fix: added column extraction in the JavaCC parser (same approach as
ANTLR4 — tokenize between ColumnsStart/ColumnsEnd, handle quoted and
nested identifiers), and wired the column names through to
Client.insert()so the server sees the right column list.Tests added for reordering, subset, batch, and quoted names — each
across all 3 parser backends. Existing tests still pass (50/50).
Note
Medium Risk
Changes the insert data path when the RowBinary beta is enabled; incorrect column mapping previously caused silent data corruption, so reviewers should focus on parser edge cases and the insert API wiring.
Overview
Fixes #3422: with
beta.row_binary_for_simple_insert=true, preparedINSERTstatements that name or reorder columns no longer stream RowBinary values in full table column order.The JavaCC parser now extracts the explicit column list (between
ColumnsStart/ColumnsEnd), including quoted/nested identifiers, comments, and$in names—bringing it in line with the ANTLR4 backends. WriterStatementImpl narrows the writer schema to those columns and passes enquoted column names intoClient.insert()duringexecuteLargeUpdate()(and thus batch), so bound parameters map to statement column order.New integration tests cover reordering, column subsets, batch, and quoted columns across all three parser backends; parser unit tests now require every backend to return INSERT column names.
Reviewed by Cursor Bugbot for commit 6a4ec67. Bugbot is set up for automated code reviews on this repo. Configure here.