Repository navigation
Add a regression test for the declared type of identity for Variant - #112469
Conversation
identity(), __scalarSubqueryResult() and __actionName() return the argument
column verbatim from executeImpl, so the declared result type has to be exactly
the argument type. They were still routed through FunctionBaseVariantAdaptor,
which decomposes a function per Variant alternative and reassembles a declared
type: it strips nested LowCardinality from each alternative, re-sorts and
squashes the alternative list, and collapses the whole thing to Nullable(T) when
all alternatives agree. The passed-through column keeps the original Variant, so
the declared type and the column disagree.
Aggregating over such an expression propagates the declared type into the block
header while the column is unchanged, and writing that block over the native
protocol pairs the declared per-alternative serializations against the actual
column variants in SerializationVariant::serializeBinaryBulkStatePrefix. The
mismatched pair fails its assert_cast, so a valid query returns an error on a
release build and aborts a debug or sanitizer build.
Opt out of the Variant adaptor, matching the LowCardinality override that is
already there for the same reason. Reported from the AST fuzzer with
Variant(BFloat16, DateTime64(5, 'UTC'), Int128, LowCardinality(BFloat16), Point,
String); the type rewrite needs no LowCardinality at all, since
identity(CAST('x', 'Variant(String)')) declared Nullable(String).
Co-Authored-By: Claude Fable 5 <[email protected]>
Internal second-model review (click to expand)An independent model reviewed this change cold, without the implementation notes, and a second
1. Correct against 2. The 3. Not a gap. 4. Both correct and applied. The pull request template asks for full GitHub URLs, and No blockers or major findings were raised on the final diff. Session id: cron:clickhouse-review-slot-52:20260729-165000 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-41:20260729-153500 |
|
cc @rschu1ze @KochetovNicolai, could you review this? |
|
Workflow [PR], commit [159a6a9] Summary: ❌
AI ReviewSummaryThis PR is now test-only: it adds a focused regression test for Final Verdict✅ No new findings. |
CI finish ledger - 2ef16d9Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
This PR's own test Session id: cron:our-pr-ci-monitor:20260729-220000 |
The one-line `useDefaultImplementationForVariant` override this branch added landed on master independently through ClickHouse#110694 (which needed the same override to keep the `Geometry` custom type name on the passthrough column). Master's wording of the accompanying comment is kept verbatim, so `src/Functions/identity.h` is now byte-identical to master and this branch contributes only the regression test.
identity equal to its argument for Variantidentity for Variant
|
Merged master and resolved the conflict. This PR is now test-only. The one-line The test is still load-bearing rather than redundant. Removing master's override and rebuilding makes I also changed the changelog category from bug fix to CI. That is mechanically required now, not cosmetic: Session id: cron:clickhouse-maint-slot-13:20260730-232400 |
CI finish ledger - ae66f68Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
Session id: cron:our-pr-ci-monitor:20260731-155315 |
|
Fixing PR for the Session id: cron:our-pr-ci-monitor:20260801-120000 |
| @@ -0,0 +1,50 @@ | |||
| -- `identity` returns its argument column verbatim, so its declared type must stay the argument | |||
There was a problem hiding this comment.
@groeneai Also remove the SQL comments, they are more confusing than helpful for future readers.
There was a problem hiding this comment.
Done in 23d96ee. The test is now one query and the comments are gone.
I measured what each part actually detected by building master with useDefaultImplementationForVariant() removed from FunctionIdentityBase and diffing the two arms. Most of the file detected nothing: the GROUP BY and native round-trip queries (including the six-alternative list from the fuzzer report) produce identical output either way, the Point/Ring cases differ only through the same nested-LowCardinality strip that the remaining assertion already pins, and the allow_suspicious_* settings were not needed. __scalarSubqueryResult is the same FunctionIdentityBase object, only the JIT flag differs at registration, so it was a duplicate too.
What is left fails on the arm without the override and passes on master, verified through clickhouse-test with randomized settings. I moved the reasoning into the commit message and updated the PR description, which still described the old test.
Reduce the test to the single query that actually detects the regression, and drop the SQL comments per review feedback. identity returns its argument column verbatim, so its declared type must stay the argument type. Routing it through the Variant adaptor rewrote the declared type (stripping nested LowCardinality) while the column kept the original Variant. One query pinning toTypeName and variantType of a Variant(LowCardinality(String), UInt64) argument covers that. Everything else was measured redundant against the fix: the Point/Ring cases differ from the fix arm only through the same LowCardinality strip; the suspicious-type SET lines are unnecessary because _CAST does not require them here; and the reported GROUP BY / MergeTree round-trip queries produce identical output with and without the override, so they detected nothing. Verified in the real harness under randomized settings, both directions: the reduced test passes on master and fails on a build with useDefaultImplementationForVariant() removed from FunctionIdentityBase.
CI finish ledger - 23d96eeEvery failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
Notes on the two owners that are not a PR link:
Session id: cron:our-pr-ci-monitor:20260810-163000 |
CI finish ledger - bb21b59Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
No PR-caused failure. This is a test-only PR adding Session id: cron:our-pr-ci-monitor:20260810-220000 |
…riant-passthrough-type
|
Fixing PR for the hung |
CI finish ledger - df3284fCI is fully finished on this head: 38 success, 134 skipped, 3 failure. The praktika report shows 0 dropped jobs. This is a test-only PR (two files under
Session id: cron:our-pr-ci-monitor:20260811-170000 |
…riant-passthrough-type
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 units6 translation units recompiled, 5 s compile time in total, 6 of them have a recent master baseline. |
CI finish ledger for 159a6a9CI is fully finished on this head (176 leaves, 0 dropped jobs). Every failure below has an owner.
The targeted job selected Session id: cron:our-pr-ci-monitor:20260812-163000 |
6bd0d20
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Related: #96844
Related: #110694
Test-only PR. It pins the declared result type of
identityfor aVariantargument.identityreturns its argument column verbatim, but was still routed through theVariantfunction adaptor, which rebuilds the declared type per alternative and strips nested
LowCardinality. The declared type then no longer matched the passed-through column, andserializing such a block over the native protocol hit a bad cast. The AST fuzzer on #96844
reported a cast to
ColumnTuple, because itsVariantalso had aPointalternative.The one-line fix (
FunctionIdentityBaseopting out of the adaptor) landed on master through my#110694, which needed the same override to keep the
Geometrycustom type name, so this branchno longer changes any source file.
The test is a single query asserting
toTypeNameandvariantTypeofidentity(CAST('x', 'Variant(LowCardinality(String), UInt64)')). I verified both directions inthe harness under randomized settings: it passes on master and fails on a build with
useDefaultImplementationForVariant()removed fromFunctionIdentityBase.__scalarSubqueryResultis the same
FunctionIdentityBaseobject (only the JIT flag differs), so it needs no separate case.Category is CI, since the user-visible entry for this behaviour belongs to #110694.
Version info
26.8.1.1274(included in26.8and later)