Repository navigation
Fix a crash reading a Quantized codec subcolumn through a Merge table whose other table lacks the column - #123895
Conversation
…child lacks the column ClickHouse#123633 made `Merge` derive a subcolumn of a column a child table does not have from the column's default value. That holds for subcolumns of the declared type, but the `quantized` and `product_quantization_codebook` subcolumns of a `Quantized` codec column come from the codec's custom serialization and cannot be computed from an in-memory value: for `product` there is no column at all, so `IDataType::getSubcolumn` returned null and `getModifiedQueryInfo` built a `ColumnConst` over it (SIGSEGV); for the other methods the codes of the default `[]` were rejected with SIZES_OF_ARRAYS_DONT_MATCH. Both places that fill a missing column (the query tree substitution and the stream path) now derive the subcolumn from the default only when the declared type has it, and give other subcolumns the default of their own type, which is what releases before ClickHouse#123633 did. `IDataType::getSubcolumn` now throws NOT_IMPLEMENTED instead of returning a null column, which every caller dereferenced. This also turns `getSubcolumn(materialize(vec), 'quantized')` (LOGICAL_ERROR "Empty column was returned") and reading `vec.quantized` from a Memory table with a `product` codec (null dereference) into an error. `tryGetSubcolumn` is unchanged: its callers use null as "not available". Closes ClickHouse#123866 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 0 findings) plus my own review (3 nits, none blocking).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20261004-193600 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-6:20261004-152100 |
|
Workflow [PR], commit [d6e2c04] Summary: ✅
AI ReviewSummaryThis PR narrows Final Verdict
LLVM Coverage ReportMeasured on commit d6e2c04.
Changed lines: Changed C/C++ lines covered: 20/20 (100.00%) · Uncovered code |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units8 translation units recompiled, 24 s compile time in total, 8 of them have a recent master baseline. |
CI finish ledger - 8d70b14Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
All 146 checks completed, Session id: cron:our-pr-ci-monitor:20261005-010535 |
|
Fixing PR for 02482_load_parts_refcounts created: #123934 |
|
@alexey-milovidov this seems to fix a regression from #123923 |
|
@groeneai merge with master and resolve the conflict |
…o fix-merge-quantized-subcolumn-of-missing-column # Conflicts: # src/Storages/StorageMerge.cpp
|
Merged master in d6e2c04. The only conflict was the include list in |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Reading the codes of a
Quantizedcolumn (vec.quantized,vec.product_quantization_codebook) through aMergetable no longer crashes the server when another table of theMergedoes not have the column.Description
Closes #123866. Related: #123633 (the regression origin).
SELECT varSamp(cityHash64(vec.quantized)) FROM merge('t.*')crashes the server (SIGSEGV inColumnConst::ColumnConstfromReadFromMerge::getModifiedQueryInfo) when one table hasvec Array(Float32) CODEC(Quantized('product', ...))and another has novec; for the other quantization methods the query fails withSIZES_OF_ARRAYS_DONT_MATCH.#123633 made
Mergederive a subcolumn of a column a child does not have from the column's default value. That is right for subcolumns of the declared type (.null, tuple elements, sizes), butquantizedandproduct_quantization_codebookare added by the codec's custom serialization and cannot be computed from a value in memory: forproductthere is no column at all, soIDataType::getSubcolumnreturned null.Changes:
StorageMerge.cpp: both places that fill a missing column (query tree substitution and stream path) derive the subcolumn from the default only when the declared type has it; otherwise it gets the default of its own type, as on 26.9.IDataType::getSubcolumnthrowsNOT_IMPLEMENTEDinstead of returning a null column. This also turnsgetSubcolumn(materialize(vec), 'quantized')(aLOGICAL_ERRORtoday) andSELECT vec.quantizedfrom aMemorytable with aproductcodec (a SIGSEGV on 26.8/26.9) into an error.The new test crashes the base server with the reported stack and passes with the fix (50/50 randomized runs); reverting any one of the three changes makes it fail. Not for changelog: the
Mergecrash is master-only (26.9 returns zero bytes), and the other paths need the experimentalenable_quantized_codec.Workflow [PR]
Sync PR [sync-upstream/pr/123895]
Version info
26.10.1.1618-master(included in26.10and later)