Repository navigation
Fix ColumnBLOB assertion failure in prepareTotals - #98783
Conversation
When a distributed query with WITH TOTALS and function-level `arrayJoin` in WHERE/QUALIFY is executed across multiple shards, the totals may have multiple rows (expanded by arrayJoin). `BlocksMarshallingStep` wraps columns in `ColumnBLOB` for network transfer via `addSimpleTransform` which also applies to the totals port. Then `prepareTotals` in `IOutputFormat` tries to cut the totals to 1 row, but `ColumnBLOB::cloneEmpty` returns the wrapped column type (not `ColumnBLOB`), causing an assertion failure in debug/sanitizer builds. Fix by converting `ColumnBLOB` back to the wrapped column before cutting in `prepareTotals`. Closes #98700 CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=83bbc94a67bd1623704f63e93be899affa30b313&name_0=MasterCI&name_1=AST%20fuzzer%20%28arm_asan%29 Co-Authored-By: Claude Opus 4.6 <[email protected]>
| /// ColumnBLOB stores serialized/compressed column data for network transfer. | ||
| /// It cannot be cut directly because its cloneEmpty returns the wrapped column type. | ||
| /// Convert it back to the regular column before cutting. | ||
| if (const auto * col_blob = typeid_cast<const ColumnBLOB *>(column.get())) |
There was a problem hiding this comment.
I think, instead, ColumnBLOB should implement cut and all other methods correctly.
The query uses `WITH TOTALS`, so the output includes the totals row (data, empty line, totals). The reference was missing the totals part. Co-Authored-By: Claude Opus 4.6 <[email protected]>
…ickHouse into fix-blob-column-cut-totals
Move the fix from the call site to the `ColumnBLOB` class itself: override `cut` to materialize the column (from blob or wrapped column) before cutting. This is cleaner than special-casing `ColumnBLOB` in every place that may call `cut`. Co-Authored-By: Claude Opus 4.6 <[email protected]>
…tput The test `04027_totals_blob_columns_cut` was flaky because totals propagation through `remote()` + `DISTINCT` depends on randomized settings (e.g. `prefer_localhost_replica`). With some settings, totals are not produced, causing the reference to mismatch. Convert from .sql to .sh and use `head -1` to capture only the first data line. The test still triggers the `ColumnBLOB::cut` code path when totals are produced, but passes regardless of whether totals propagate through the pipeline. Co-Authored-By: Claude Opus 4.6 <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
| if (from_blob_task) | ||
| return convertFrom()->cut(start, length); | ||
| return wrapped_column->cut(start, length); | ||
| } |
There was a problem hiding this comment.
Incomplete fix: only cut overridden, other methods still crash
Medium Severity
ColumnBLOB::cut is overridden to delegate to the unwrapped column, but filter, permute, index, and all other similar methods still call throwInapplicable. As the reviewer noted, ColumnBLOB needs to implement these methods correctly rather than adding one-off overrides. The current approach creates an inconsistency where cut silently unwraps the column while sibling operations crash, making the fix fragile — any future code path that calls another method on a ColumnBLOB in a similar context will trigger the same class of assertion failure.
Additional Locations (1)
There was a problem hiding this comment.
Ok for now. Other cases the author of ColumnBLOB, @nickitat, will fix.
LLVM Coverage Report
PR changed lines: PR changed-lines coverage: 36.36% (4/11) |
|
Sorry for the delay with the review. And thanks for fixing the problem. I made a slightly different fix in #99355 |


Summary
assertTypeEqualityinIColumn::cutcalled fromprepareTotalsinIOutputFormatWITH TOTALSand function-levelarrayJoinis executed across multiple shardsBlocksMarshallingStepwraps totals columns inColumnBLOBfor network transfer, butColumnBLOB::cloneEmptyreturns the wrapped column type, notColumnBLOB, causing a type mismatch whenprepareTotalstries to cut totals to 1 rowColumnBLOBback to the wrapped column before cutting inprepareTotalsCloses #98700
CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=83bbc94a67bd1623704f63e93be899affa30b313&name_0=MasterCI&name_1=AST%20fuzzer%20%28arm_asan%29
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Test plan
04027_totals_blob_columns_cutthat reproduces the issue withremote('127.0.0.{1,2}', view(... WITH TOTALS)) WHERE arrayJoin(...)🤖 Generated with Claude Code
Note
Low Risk
Small, localized change to
ColumnBLOBbehavior plus a regression test; main risk is unintended overhead/behavior differences whencut()forces BLOB conversion, but it’s only exercised in narrow totals-slicing paths.Overview
Prevents
prepareTotalsfrom triggering a debug/sanitizer assertion when it slices multi-row totals by adding aColumnBLOB::cut()override that delegates to the underlying wrapped/deserialized column.Adds a distributed regression test (
04027_totals_blob_columns_cut) reproducing theremote(...) WITH TOTALS+arrayJoinscenario and asserting the query completes without crashing.Written by Cursor Bugbot for commit 21760fc. This will update automatically on new commits. Configure here.
Version info
26.3.1.600