Repository navigation
Report a missing delimiter in Values as a missing delimiter - #116877
Conversation
Extending the error-message survey to the data-loading path turned this
up. A row with fewer values than the table has columns was reported as if
the last value it did read were at fault:
INSERT INTO t (id UInt32, name String, d Date, e Enum8('a' = 1, 'b' = 2))
FORMAT Values (1, 'Alice')
Cannot parse expression of type String here: 'Alice')
`'Alice'` is a perfectly good String; what is missing is the comma after
it. `ValuesBlockInputFormat::parseExpression` folds two different
outcomes into one flag - the expression not parsing, and the expression
parsing but not being followed by the expected `,` or `)` - and reports
both with the message for the first. Tell them apart:
Expected ',' after the value of column `name` of type String here: 'Alice')
The same shape covers a row that lost its closing bracket (`Expected ')'
after the value of column `e` ...`), a row with a comma missing between
two values, and a row with more values than there are columns. An
expression that genuinely does not parse still gets the message it had.
|
Workflow [PR], commit [66538e8] Summary: ✅
AI ReviewSummaryThis PR teaches Final Verdict✅ No blocking issues found in the current PR state. LLVM Coverage ReportMeasured on commit 66538e8.
Changed lines: Changed C/C++ lines covered: 39/39 (100.00%) · Uncovered code |
`Fast test` produced no error lines at all for the four failing inserts, while the same inserts fail as expected locally, so the test depended on something about how the client reports an insert error under the settings that CI randomizes. The message is the whole point of the test, and the HTTP interface returns it in one piece, so use that and pin `async_insert` while at it.
`Fast test` produced no error lines at all for the four failing inserts, and the same happens locally about one run in three once `clickhouse-test` randomizes settings: with `async_insert = 1` and `wait_for_async_insert = 0` an insert returns an empty successful response and the parse error is only logged. The test is about the message a format produces, so run the format directly - `format(Values, ...)` in `clickhouse-local` uses the same reader, with no table, no server and no insert settings to depend on.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Compile time of recompiled translation units7 translation units recompiled, 9 s compile time in total, 7 of them have a recent master baseline. |
Review pointed out that `checkDelimiterAfterValue` accepts an optional
trailing comma before `)` for the last column, and
`03153_trailing_comma_in_values_list_in_insert` documents it, while this
path accepted only `)`. So
INSERT INTO t (a, b, c) VALUES (1, 2, 3,) -- works
INSERT INTO t (a, b, c) VALUES (1, 2, toDate('2020-01-02'),) -- fails
purely because the last value needs the expression parser rather than the
streaming one. Accept it here too, only when the comma is immediately
followed by `)`, so that nothing else changes.
Related: #116806
Related: #116809
Related: #116812
Related: #116815
Related: #116817
Related: #116871
Related: #116872
Extending the survey of error messages for mistakes in SQL queries to the data-loading path turned this up. A row with fewer values than the table has columns was reported as if the last value it did read were at fault:
'Alice'is a perfectly goodString— what is missing is the comma after it.ValuesBlockInputFormat::parseExpressionfolds two different outcomes into one flag:so a good value followed by the wrong delimiter gets the message written for a value that does not parse. Telling them apart:
(1, 'Alice')— too few valuesCannot parse expression of type String here: 'Alice')Expected ',' after the value of columnnameof type String here: 'Alice')(1, 'Alice', '2020-01-02', 'a'— no closing bracketCannot parse expression of type Enum8('a' = 1, 'b' = 2) here: 'a'Expected ')' after the value of columneof type Enum8('a' = 1, 'b' = 2) here: 'a'(1 'Alice', ...)— comma missingCannot parse expression of type UInt32 here: 1 'Alice', ...Expected ',' after the value of columnidof type UInt32 here: 1 'Alice', ...(1, 'Alice', '2020-01-02', 'a', 'extra')— too many valuesCannot parse expression of type Enum8(...) here: 'a', 'extra')Expected ')' after the value of columneof type Enum8(...) here: 'a', 'extra')An expression that genuinely does not parse (
notafunction(2),*) still gets exactly the message it had, and the path where the tokenizer itself fails is untouched.The 53 stateless tests that use
FORMAT ValuesorValuesBlockInputFormatwere run; the failures are unrelated environment ones (no ZooKeeper, andasync_inserton in the local setup), and no failure diff mentions either the old or the new message.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
A row in the
Valuesformat whose values are fine but whose,or)is missing or misplaced — most often a row with fewer or more values than the table has columns — now reports the missing delimiter and the column it should follow, instead of claiming that the last value could not be parsed as its own type.Workflow [PR]
Sync PR [sync-upstream/pr/116877]
Version info
26.9.1.327(included in26.9and later)