Repository navigation
Conversation
…st path Every constructed `DB::Exception` is counted in `system.errors` and `system.error_log` even when it is caught and handled. The `Values` format parser used exceptions for control flow: when the fast streaming parser could not read a value (e.g. it was an expression like `1 + 1`, or the `DEFAULT` keyword prefix did not match), it threw `CANNOT_PARSE_INPUT_ASSERTION_FAILED`, caught it and fell back to the SQL expression parser. As a result, perfectly successful INSERT queries produced confusing `Cannot parse input: expected ',' before: ...` records in `system.error_log`, attributed to the query id of the insert (or of the `AsyncInsertFlush` query for async inserts). Rework `tryReadValue` in `ValuesBlockInputFormat` to use the non-throwing `tryDeserializeTextQuoted` serialization methods plus `checkDelimiterAfterValue`, so that a fast-path miss reaches the SQL expression parser without constructing any exception. This also avoids collecting a stack trace for every such value, which is much faster. Columns that nest a `Decimal` keep the old throwing code path: an overflowing decimal literal must fail the query with `ARGUMENT_OUT_OF_BOUND` instead of being passed to the expression parser, which would read it as a `Float64` literal and silently lose precision. The non-throwing parser cannot distinguish the overflow from a genuine parse failure. A new `SerializationNullable::tryDeserializeNullAsDefaultOrNestedTextQuoted` overload exposes whether the value was `NULL`, which `tryReadValue` needs to fill `BlockMissingValues`.
|
Workflow [PR], commit [996bf77] Summary: ❌
AI ReviewSummaryThis PR reworks the Findings
Final Verdict
|
There was a problem hiding this comment.
Pull request overview
This PR removes exception construction from the Values format streaming-parser fallback path so that successful INSERT ... VALUES (...) queries (that contain expressions / DEFAULT / escaped complex values) no longer produce misleading parse errors in system.errors / system.error_log, and avoids the overhead of collecting stack traces on these expected fallbacks.
Changes:
- Refactors
ValuesBlockInputFormat::tryReadValueto use non-throwingtryDeserializeTextQuoted-style parsing for fast-path attempts and cleanly fall back to the SQL expression parser without constructing exceptions. - Preserves the throwing path for columns that are (or contain)
Decimal, to ensure decimal overflows still fail withARGUMENT_OUT_OF_BOUNDinstead of silently degrading via expression parsing. - Adds a stateless query test that asserts successful fallback does not increment parse-related counters in
system.errors.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/Processors/Formats/Impl/ValuesBlockInputFormat.h |
Adds streaming helper declarations and tracks which columns nest Decimal to choose the appropriate parsing path. |
src/Processors/Formats/Impl/ValuesBlockInputFormat.cpp |
Implements the new non-throwing streaming fast path and refactors fallback logic; keeps a throwing path for Decimal overflow semantics. |
src/DataTypes/Serializations/SerializationNullable.h |
Adds an overload exposing whether a parsed value was NULL when using “NULL as default” logic. |
src/DataTypes/Serializations/SerializationNullable.cpp |
Implements the new overload and reuses it for the existing API. |
tests/queries/0_stateless/04510_values_expression_fallback_no_error_counters.sh |
New regression test exercising expression/DEFAULT/escaped complex fallbacks and validating system.errors counters don’t change. |
tests/queries/0_stateless/04510_values_expression_fallback_no_error_counters.reference |
Expected output for the new test. |
Keep throwing deserialization for Decimal overflow detection, but use the non-throwing delimiter check before falling back to the SQL expression parser. Extend the regression test so a Decimal expression cannot increment parse-error counters.
Use non-throwing `DEFAULT` detection in the Decimal-preserving streaming path. Extend the regression test with `divide` on a Decimal column so successful fallback cannot increment parse-error counters.
`SerializationDynamic::tryDeserializeTextQuoted` called the throwing field reader, so expressions such as `toDate` failed before `ValuesBlockInputFormat` could fall back to SQL expression parsing. Use `tryReadQuotedField` and share the existing inferred-field insertion logic. Extend the error-counter regression with `Dynamic` function expressions.
Use the throwing streaming parser only when Array, Map, or Tuple input starts with its literal delimiter, preserving Decimal overflow checks for raw literals. Reuse the same non-throwing streaming probe when `parseExpression` checks whether it can return to streaming mode. Cover function expressions, quoted complex values, mixed expression shapes, and nested Decimal overflow.
Keep literal retries from applying `input_format_null_as_default`, and route identifier-leading and composite Decimal expressions through non-throwing probes. Retain throwing retries only for raw Decimal failures that can represent overflow. Extend regression coverage for `Dynamic`, `Variant`, `JSON`, nested Decimal expressions, and Decimal map-key overflow.
Initialize the local result before compile-time branch selection to satisfy the `cppcoreguidelines-init-variables` check in the arm_tidy build.
Keep `Dynamic` probes non-throwing, isolate quoted complex retries from compatibility mode, and distinguish Decimal overflow from parse failures. Avoid aggregate fallback exceptions while preserving overflow diagnostics.
Bypass the `Values` aggregate probe only when a quoted token is followed by an expression. Structural delimiters still reach deserialization and retain the existing specific error.
Retry every classified `Decimal` overflow with the throwing parser to match the previous behavior before operators. Let parsed literals restore streaming mode after expressions.
| if (starts_with_aggregate_function_string) | ||
| { | ||
| String field; | ||
| bool starts_with_expression = tryReadQuotedStringWithSQLStyle(field, *buf); | ||
| if (starts_with_expression) |
|
Alternative implementation: #111141. It keeps the existing |
The `Values` streaming parser uses parse exceptions to fall back to SQL expression parsing. Those handled exceptions were recorded in `system.errors` and `system.error_log` even when the insert succeeded. Add a thread-local scope that suppresses system error accounting around the two speculative parses. Exceptions that propagate, including `Decimal` overflow, are recorded explicitly before they leave the parser. Related: ClickHouse/support-escalation#8208 Alternative to: ClickHouse#109981
The `Values` streaming parser uses parse exceptions to fall back to SQL expression parsing. Those handled exceptions were recorded in `system.errors` and `system.error_log` even when the insert succeeded. Add a thread-local scope that suppresses system error accounting around the two speculative parses. Exceptions that propagate, including `Decimal` overflow, are recorded explicitly before they leave the parser. Related: ClickHouse/support-escalation#8208 Alternative to: ClickHouse#109981
The
Valuesformat used exceptions as control flow when its fast streaming parser could not read avalue and had to fall back to the SQL expression parser. Constructing those expected exceptions
recorded errors in
system.errorsandsystem.error_log, even though the query succeeded.Use non-throwing serialization probes for the streaming attempt. A
Values-specific probe statepreserves legacy integer, temporal,
QBit, and escapedUUIDliteral behavior without changingVariantorDynamicarm selection.Decimalprobes distinguish overflow from other parse failures,so overflows retain the existing
ARGUMENT_OUT_OF_BOUNDbehavior without exception-backed retriesfor unrelated expression fallbacks.
Regression coverage verifies that successful expression fallbacks leave all parse-error counters
unchanged and that the previous literal compatibility behavior is preserved.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
The
Valuesformat no longer records parse errors insystem.errorsandsystem.error_logwhen it successfully falls back from streaming parsing to SQL expression parsing.