Repository navigation
Replace two internal error messages for plain SQL mistakes - #116812
Conversation
Both come from the survey of the error messages that ClickHouse produces
for damaged benchmark queries (ClickBench, TPC-H, TPC-DS, the Join Order
Benchmark). They are rare in that corpus but each of them answers an
ordinary mistake with a message about ClickHouse internals.
Comparing a numeric column with an empty string reported an EOF error:
SELECT toInt32(1) = ''
Code: 32. Attempt to read after eof: while converting '' to Int32
`convertFieldToType` parses the literal with `deserializeWholeText`,
which reports a value that ends before it expected as an attempt to read
after eof. That reads like a problem with the data, not with the query,
and the very similar `= 'abc'` already gets a proper message. Give the
empty and truncated cases the same one:
Code: 53. Cannot convert string '' to type Int32
Dropping `EXISTS` from `NOT EXISTS (SELECT * FROM t WHERE t.a = o.b)` -
which is what removing one token from TPC-H Q22 does - leaves a
correlated subquery of several columns where a single value is expected,
and that was reported as
Code: 1. Method getResultType is supported only for correlated query
node with 1 column, but got 9
The method is an implementation detail; the user needs to know what is
wrong with the query:
Code: 20. A correlated subquery used as an expression must return
exactly one column, but it returns 9
`01311_comparison_with_constant_string` asserted the old error code for
`SELECT 0 = ''` and is updated. The other tests that expect
`ATTEMPT_TO_READ_AFTER_EOF` go through the conversion functions or
aggregate-state deserialization rather than `convertFieldToType`, and
still pass.
|
Workflow [PR], commit [47bf54d] Summary: ✅
AI ReviewSummaryThis PR replaces two internal exceptions with query-facing diagnostics: empty or truncated string literals compared to numeric values now report Missing context / blind spots
Final Verdict✅ No new findings. LLVM Coverage ReportMeasured on commit 47bf54d.
Changed lines: Changed C/C++ lines covered: 8/9 (88.89%) · Uncovered code |
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 units8 translation units recompiled, 13 s compile time in total, 8 of them have a recent master baseline. |
The messages it asserts are produced by the analyzer; with `enable_analyzer = 0` the same errors come from a different code path and are worded differently, so the test failed in the `old analyzer` CI configuration.
`_cleanup_database` in `clickhouse-test` asks tests numbered from 02800 on to leave no tables behind.
The test showed the `Date` path as a contrast to the integer one, and did it by pinning the whole message - which couples it to #116817, where the reason part of `Cannot parse date` changes. Normalise the reason away: what this test is about is that the `Date` path has a message of its own, not what that message says.
Related: #116806
Related: #116809
Two more findings from the survey of the error messages ClickHouse produces for mistakes in SQL queries (the queries of ClickBench, TPC-H, TPC-DS and the Join Order Benchmark, damaged at random). Both are rare in the corpus, but each answers an ordinary mistake with a message about ClickHouse internals rather than about the query.
Comparing a number with an empty string reported an EOF error.
WHERE numeric_column <> ''is a common way to write "is not empty" for someone coming from another database, and it produced:convertFieldToTypeparses the string literal withdeserializeWholeText, and a value that ends before the deserializer expected surfaces asAttempt to read after eof— which reads like a problem with the stored data, not with the query. The almost identical= 'abc'already gets a proper message, so the empty and truncated cases now get the same one:A correlated subquery of several columns named a C++ method. Dropping
EXISTSfromNOT EXISTS (SELECT * FROM orders WHERE o_custkey = c_custkey), which is what removing a single token from TPC-H Q22 does, leaves a correlated subquery of several columns where a single value is expected:getResultTypeis an implementation detail, andUNSUPPORTED_METHODis not what went wrong — the query is invalid:The other
getResultTypethrow inQueryNode(for a non-correlated node) is left alone: it is an internal invariant, and the way it is reached from SQL is a separate bug (#115835).01311_comparison_with_constant_stringassertedATTEMPT_TO_READ_AFTER_EOFforSELECT 0 = ''and is updated toTYPE_MISMATCH. The other tests that expectATTEMPT_TO_READ_AFTER_EOF(01888_read_int_safe,00700_to_decimal_or_something_1,02477_invalid_reads,03716_topk_bad_data,03927_sumcount_compatibility) go through the conversion functions or aggregate-state deserialization rather thanconvertFieldToTypeand are unaffected — they were run and pass.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Comparing a number with an empty or truncated string literal, such as
WHERE numeric_column <> '', now reportsCannot convert string '' to type Int32instead ofAttempt to read after eof. A correlated subquery returning several columns where a single value is expected now says so, instead of reporting that thegetResultTypemethod is not supported.Workflow [PR]
Sync PR [sync-upstream/pr/116812]
Version info
26.9.1.328(included in26.9and later)