Repository navigation
Conversation
accurateCastOrNull(c1, 'Int32') threw CANNOT_PARSE_NUMBER for a FixedString(12) column on true master (SQLancer arm_release at 112492e), and the silent half of the same defect is worse: a FixedString source never reached the NULL-on-error parser, so accurateCastOrNull(toFixedString('300', 12), 'Int8') returned 44 where a String source returns NULL. accurateCastOrNull resolves to Nullable(Int32), so prepareRemoveNullable passes requested_result_is_nullable = true but invokes the wrapper with the nested Int32. createWrapper's NULL-on-error branch tested checkAndGetDataType<DataTypeString> only, and can_apply_accurate_cast admits a text source only for CastType::accurate, so both guards failed and the conversion fell back to FunctionTo<T>::Type. That converter's own rescue for a text source with a Nullable target is dead here, because the adaptor received the nested type, so it selected ConvertThroughParsing<FixedString, T, ..., Throw>, whose parseImpl calls readIntText, which has no overflow check. createDecimalWrapper had the identical shape one level down. Both sites now select the parser from the error policy the caller requested rather than from which of the two text types the source is, excluding CastType::accurate, which must keep rejecting. That conjunct becomes redundant once ClickHouse#120674 lands; until then it is the only thing keeping accurateCast(FixedString, 'Nullable(T)') throwing. Routing alone is not enough for Decimal* targets. The two decimal readers disagree on digits_only: readDecimalText defaults it to false and stops at the first byte it cannot parse, so isAllRead can forgive a FixedString's zero padding afterwards, while tryReadDecimalText hard-codes it to true and fails on that byte before isAllRead ever runs. Sending a padded value down the NULL-on-error path therefore turned a correct 3.14 into NULL. ConvertThroughParsing now trims trailing NULs off string_size for the non-throwing FixedString to Decimal* case, before the read buffer is built; next_offset stays the physical stride, so the per-row iteration is unchanged. The same asymmetry was a second pre-existing defect, so this also fixes toDecimal*OrNull and toDecimal*OrZero on a zero-padded FixedString. SerializationDecimal, readDecimalText and tryReadDecimalText are untouched. The trim is scoped rather than applied to every target: FixedString(16) to UUID and to IPv6 read all 16 bytes binary, and a UUID or address ending in a zero byte would be truncated. DateTime64 and Time64 are excluded because IsDataTypeDecimal is specialized true for both, while the decimal branch is only reached after those two are handled above it. Co-Authored-By: Claude Opus 5 <[email protected]>
Drop the two clauses narrating the new predicate's own design; keep the accurate-cast policy as a one-line invariant and the decimal reader's padding semantics in two.
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 0 findings; bounded: 1 full pass + Two things I noticed myself and am not changing, listed so you do not have to find them:
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-9:20260919-171300 |
|
Workflow [PR], commit [4fa89a8] Summary: ✅
AI ReviewSummaryThis PR routes The PR-head CI binary reproduced all 67 regression output lines exactly, validated all five expected exceptions, and passed the modified Consumers checked for the newly nullable intermediate columns:
Final Verdict✅ Approve. No new inline findings to post. |
Fast test reddened 03991_set_variant_low_cardinality_in_global_in on this
branch. That test's set element is toFixedString(toLowCardinality('not a
number'), 12) and it pinned serverError CANNOT_PARSE_TEXT, which is the exact
throw this branch removes.
KeyCondition::tryPrepareSetColumnsForIndex prepares an IN set with
castColumnAccurateOrNull, whose job there is to write NULL where a set element
cannot be represented in the key type, so that the null map marks the cast
failures. For a FixedString element that call threw instead, from inside index
analysis, and the query failed. It now returns NULL, the element is dropped
from the set, index analysis completes and prunes every granule, and the query
proceeds to the Variant conversion a String element already reached on master.
That parity decides the new expectation, and it is measured rather than
argued: on unmodified master the same query with a String or
LowCardinality(String) element already fails with CANNOT_CONVERT_TYPE, and
only the FixedString element gave CANNOT_PARSE_TEXT. So the expectation moves
to CANNOT_CONVERT_TYPE and nothing else in that test changes. Its own
invariant still holds: issue ClickHouse#97854 is about a LOGICAL_ERROR bad cast, while
CANNOT_CONVERT_TYPE is an ordinary exception raised after index analysis has
run to completion, which is further than the test reached before.
Group L pins that carrier, with the String element beside it as the control.
The count alone would pass even if the primary key were never consulted, so it
also asserts through EXPLAIN indexes = 1 that the primary-key condition holds
a 0-element set: the subquery yields exactly one row, so zero elements is that
element being dropped. A non-key column yields 0 there instead of 1. The table
pins add_minmax_index_for_numeric_columns = 0, as 146 other stateless tests
already do, because the implicit index prints the same condition a second time
and would make the count 2.
Only a key column reaches this path. For a non-key column the row-level in
still fails with NOT_IMPLEMENTED, because the comparison itself does not
accept a FixedString set element; that is unchanged by this branch.
Over every stateless test that mentions a FixedString (535 of them) this
branch adds no failure base does not already have, and the only two tests that
redden on base and pass here are this one and 03991.
Co-Authored-By: Claude Opus 5 <[email protected]>
CI finish ledger - 986fda9Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
Session id: cron:our-pr-ci-monitor:20260920-110135 |
The comment claimed that unparsable text now returns NULL for every
target family. It does not. A FixedString source reaches convertToIPv4,
which accepts only ColumnString and throws ILLEGAL_COLUMN: on this head
accurateCastOrNull(toFixedString('1.2.3.4', 7), 'IPv4') is Code 44 while
the String source returns 1.2.3.4. A Tuple target rejects a FixedString
source with Code 53 where a String source parses. Both gaps are in the
description as adjacent defects left out of this change, so the comment
now claims only what the queries below it prove.
…r-null-fixedstring-source # Conflicts: # src/Functions/FunctionsConversion.h
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Slowest function optimization changes (ThinLTO)Median per-function time ratio to the master baseline:
Compile time of recompiled translation units40 translation units recompiled, 294 s compile time in total, 40 of them have a recent master baseline. |
Related: #120674
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix
accurateCastOrNull,accurateCastOrDefaultandCAST(... AS Nullable(T))throwing, or silently returning a wrapped value, when aFixedStringis converted to a number,Decimal, date/time orUUID: they now returnNULL(or the default) as they already did for aStringsource. Also fixesINwith an unparseableFixedStringset element failing primary-key analysis, andtoDecimal*OrNull/...OrZeroreturningNULL/0for a valid decimal held in a zero-paddedFixedString.Description
True-master
SQLancer (arm_release)hitaccurateCastOrNull(c1, 'Int32')throwingCANNOT_PARSE_NUMBERfor aFixedString(12)column (report). The throw is pre-existing; the silent half is worse: aFixedStringnever reached the NULL-on-error parser, soaccurateCastOrNull(toFixedString('300', 12), 'Int8')returned44where aStringreturnsNULL.createWrapperpicked that parser by testing forDataTypeString, so aFixedStringfell through to the ordinary converter, whose integer reader has no range check;createDecimalWrapperhad the same shape. Both now key off the requested error policy, excludingCastType::accurate, which must keep rejecting (redundant once #120674 lands).Routing alone is not enough for
Decimal*: the non-throwing reader hard-codesdigits_only = true, so it fails on the zero padding where the throwing one stops andisAllReadforgives it.ConvertThroughParsingnow trims trailing NULs before that read;SerializationDecimalandreadDecimalTextare untouched.KeyCondition::tryPrepareSetColumnsForIndexusescastColumnAccurateOrNullto mark set elements a key type cannot represent, so it threw there too; such an element is now dropped and index analysis completes. Hence03991_set_variant_low_cardinality_in_global_innow expectsCANNOT_CONVERT_TYPE: there, aStringelement on master already failed that way and only aFixedStringgaveCANNOT_PARSE_TEXT. A non-key column is unchanged.Validated with a 135-probe A/B matrix, a per-hunk mutation matrix, and all 535 stateless tests naming a
FixedStringdiffed against base: no new failure.Four adjacent defects measured and left out; happy to take any as a follow-up
FixedStringtoIPv4fails withILLEGAL_COLUMNeven for'1.2.3.4':convertToIPv4accepts onlyColumnString, unlikeconvertToIPv6andtoIPv4.Tupleelement conversion ignores theOrNullpolicy, forStringandFixedStringelements alike.CASTto aTuplerejects aFixedStringsource outright (Code 53), where aStringsource is parsed.FixedStringconverts to0for integer targets butNULLforFloat64;toInt32OrNullagrees with the0.Workflow [PR]
Sync PR [sync-upstream/pr/121064]