Repository navigation
CREATE TABLE ... AS SELECT and MODIFY QUERY do not inherit the serialization of a Quantized codec - #127801
CREATE TABLE ... AS SELECT and MODIFY QUERY do not inherit the serialization of a Quantized codec#127801groeneai wants to merge 4 commits into
CREATE TABLE ... AS SELECT and MODIFY QUERY do not inherit the serialization of a Quantized codec#127801Conversation
…AS SELECT The `Quantized(...)` codec attaches `SerializationQuantizedVector` to the column's type object as a nameless customization. Query analysis passes that object on, so `CREATE TABLE ... AS SELECT` from such a column (also wrapped in Array/Tuple/Map, through a JOIN, UNION, subquery, `EMPTY AS SELECT`, a VIEW) created the new table with the codec's serialization but without the codec. The stored definition is a plain `Array(Float32)`, so the in-memory table and the reloaded one disagreed: a `Log` table wrote a `vec.quantized` stream and marks for it, and after a restart or DETACH/ATTACH every read failed with SIZES_OF_MARKS_FILES_ARE_INCONSISTENT; a MergeTree target exposed `vec.quantized` only until the reload. An inferred column takes only the type from the SELECT, so the CTAS branch now re-creates any inferred type that carries the serialization from its name, which is exactly what a reload parses. Custom names that are part of the type (`SimpleAggregateFunction(anyLast, Array(Float32))`, tuple element names) are kept; types without the serialization are returned unchanged. `ALTER TABLE ... MODIFY QUERY` infers a view's columns from the new SELECT the same way and gets the same treatment. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Shorten the CTAS inference comment and the removeQuantizeSerializations declaration comment to one line each. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Three review rounds, an independent cold review and a second-model gate in each. The last round (head
|
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-self-slot-57:20261026-003000 |
|
Workflow [PR], commit [583c57d] Summary: ✅
AI ReviewSummaryReviewed PR #127801 at Final VerdictStatus: ✅ Approve |
|
cc @shankar-iyer @Algunenano, could you review this and add the |
CI finish ledger - d9d8bc5Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
Session id: cron:our-pr-ci-monitor:20261026-153005 |
…ized-codec-serialization
With this branch, a table created AS SELECT from a Quantized column gets the type without the codec's serialization, so Log no longer refuses it. The statement no longer differs between an Atomic and a Replicated database, so it runs in the test's own database. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
I merged master (with #127795) and updated its test: 583c57d The only interaction is the The PR is still needed after #127795: on master that CTAS is refused although the new table declares no codec, and a Measured on master with #127795: 05452 and 05453 pass 50/50 with random settings; without the fix both fail with |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units1152 translation units recompiled, 10310 s compile time in total, 1152 of them have a recent master baseline. |
Related: #127795
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
A table created by
CREATE TABLE ... AS SELECTfrom a column with the experimentalQuantizedcodec now gets a plain column, the same as its stored definition, so aLogtable created this way stays readable after a restart. The same applies to the columns of a materialized view afterALTER TABLE ... MODIFY QUERY.Description
On master,
CREATE TABLE ... ENGINE = Log AS SELECTfrom aQuantizedcolumn is refused, although the new table declares no codec. Before #127795 it was created and could not be read after a reload:The codec attaches
SerializationQuantizedVectorto the column's type object, without a custom name. CTAS builds the new columns from the SELECT sample block, so the new table gets that serialization but stores a plainArray(Float32)with no codec.Lognow refuses it (before, it wrote an extravec.quantizedstream whose marks did not match after a reload). AMergeTreetarget, or aVIEW, exposesvec.quantizedonly until the reload, and so does a materialized view afterALTER TABLE ... MODIFY QUERY, which infers its columns from the new SELECT the same way. The same happens when the column is wrapped ([vec],tuple(vec),map(...),groupArray, JOIN, UNION,EMPTY AS SELECT).The CTAS branch and the
MODIFY QUERYbranch ofAlterCommand::applynow re-create every inferred type that carries this serialization from its name, which is the type a reload parses. Custom names that are part of the type, such asSimpleAggregateFunction(anyLast, Array(Float32)), are kept. Other types are returned unchanged, and the source column keeps its subcolumn.The
AS SELECTstatement of #127795's05452_log_buffer_quantized_codecnow creates a plain table instead of expectingILLEGAL_COLUMN.The new test fails on master (
ILLEGAL_COLUMNat theLogCTAS) and passes 50/50 with randomized settings.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/127801]