Related to Nullable Tuples: Fix exception in Array-to-QBit conversion with nullable source#97413
Merged
alexey-milovidov merged 2 commits intomasterfrom Feb 23, 2026
Merged
Conversation
Contributor
| @@ -0,0 +1,29 @@ | |||
| -- Regression test: casting Array(Tuple(Array(...), ...)) to Array(Tuple(QBit(...), ...)) | |||
Member
Author
There was a problem hiding this comment.
Yes, it reproduces the issue.
nihalzp
reviewed
Feb 20, 2026
src/Functions/FunctionsConversion.h
Outdated
| template <typename FloatType> | ||
| static ColumnPtr convertArrayToQBit( | ||
| ColumnsWithTypeAndName & arguments, const DataTypePtr &, const ColumnNullable * nullable_source, size_t n, size_t size) | ||
| ColumnsWithTypeAndName & arguments, const DataTypePtr &, const ColumnNullable * /* nullable_source */, size_t n, size_t size) |
Member
There was a problem hiding this comment.
Yes, the fix is on the right path.
The remaining issue is that we need nullable_source to skip rows where we have NULL. For example,
SELECT CAST(
[NULL::Nullable(Tuple(Array(Float64), String))],
'Array(Nullable(Tuple(QBit(BFloat16, 3), String)))'
);In PR, now throws with:
Code: 190. DB::Exception: Array arguments must have size 3 for QBit conversion, got 0: In scope SELECT CAST([CAST(NULL, 'Nullable(Tuple(Array(Float64), String))')], 'Array(Nullable(Tuple(QBit(BFloat16, 3), String)))'). (SIZES_OF_ARRAYS_DONT_MATCH)But it should return NULL.
We have to use nullable_source to get the null map data and only try to convert array to QBit for non-null rows in convertArrayToQBit.
We can also add the following query for proper validation of the logic:
SELECT
CAST(v, 'Array(Nullable(Tuple(QBit(BFloat16, 3), String)))') AS converted
FROM VALUES(
'v Array(Nullable(Tuple(Array(Float64), String)))',
[([1.0, 2.0, 3.0], 'hello')],
[NULL]
);It should return:
[([1,2,3],'hello')]
[NULL]
nihalzp
approved these changes
Feb 22, 2026
…ong column type The `createArrayToQBitWrapper` was incorrectly propagating the outer `nullable_source` pointer into `convertArrayToQBit`, which then replaced the properly converted `ColumnArray` with the nested column from the original `nullable_source`. When converting through a Tuple wrapper (e.g., `Nullable(Tuple(Array(Variant(...)), String))` to `Nullable(Tuple(QBit(BFloat16, N), String))`), the outer `nullable_source` wraps the entire Tuple, so `getNestedColumnPtr` returns a `ColumnTuple` instead of a `ColumnArray`, causing a `LOGICAL_ERROR` exception. Fix: stop propagating `nullable_source` in `createArrayToQBitWrapper`, matching the pattern already used by `createArrayWrapper` (line 4749). https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=58b9b010eb7d1210b0c0ec88118ab153a9db0f4d&name_0=MasterCI&name_1=BuzzHouse%20%28arm_asan%29 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When converting `Nullable(Tuple(Array(Float64), ...))` to `Nullable(Tuple(QBit(BFloat16, N), ...))`, the Nullable stripping produces default (empty) arrays for NULL rows. These empty arrays don't match the expected QBit dimension, causing a `SIZES_OF_ARRAYS_DONT_MATCH` exception. Fix: pass `nullable_source` through to `convertArrayToQBit` and use its null map to skip both the size validation and bit transposition for NULL rows. The result for those rows is masked by NULL anyway. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
abe9fa3 to
fd75b84
Compare
This was referenced Feb 23, 2026
robot-clickhouse
added a commit
that referenced
this pull request
Feb 23, 2026
Cherry pick #97413 to 25.11: Related to Nullable Tuples: Fix exception in Array-to-QBit conversion with nullable source
robot-clickhouse
added a commit
that referenced
this pull request
Feb 23, 2026
…n Array-to-QBit conversion with nullable source
robot-clickhouse
added a commit
that referenced
this pull request
Feb 23, 2026
Cherry pick #97413 to 25.12: Related to Nullable Tuples: Fix exception in Array-to-QBit conversion with nullable source
robot-clickhouse
added a commit
that referenced
this pull request
Feb 23, 2026
…n Array-to-QBit conversion with nullable source
robot-clickhouse
added a commit
that referenced
this pull request
Feb 23, 2026
Cherry pick #97413 to 26.1: Related to Nullable Tuples: Fix exception in Array-to-QBit conversion with nullable source
robot-clickhouse
added a commit
that referenced
this pull request
Feb 23, 2026
… Array-to-QBit conversion with nullable source
clickhouse-gh bot
added a commit
that referenced
this pull request
Feb 23, 2026
Backport #97413 to 26.1: Related to Nullable Tuples: Fix exception in Array-to-QBit conversion with nullable source
Algunenano
pushed a commit
to Algunenano/ClickHouse
that referenced
this pull request
Feb 24, 2026
…-source-crash Related to Nullable Tuples: Fix exception in Array-to-QBit conversion with nullable source
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
LOGICAL_ERRORexception inconvertArrayToQBitwhennullable_sourcewraps a different column type (e.g.,ColumnTupleinstead ofColumnArray)Nullable(Tuple(Array(Variant(...)), String))toNullable(Tuple(QBit(BFloat16, N), String))— the outernullable_sourcewraps the Tuple, butconvertArrayToQBitusesgetNestedColumnPtrexpecting an Arraynullable_sourceincreateArrayToQBitWrapper, matching the pattern already used bycreateArrayWrapperBuzzHouse CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=58b9b010eb7d1210b0c0ec88118ab153a9db0f4d&name_0=MasterCI&name_1=BuzzHouse%20%28arm_asan%29
Test plan
03926_qbit_cast_from_nullable_arrayexercising nullable Tuple with Array-to-QBit conversionChangelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix
LOGICAL_ERRORexception in Array-to-QBitconversion whennullable_sourcefrom an outerTuplewrapper replaces the converted array column with a mismatched column type. Closes #97389.🤖 Generated with Claude Code