Repository navigation
Conversation
69cd02c to
9af150b
Compare
|
Workflow [PR], commit [10724cb] Summary: ❌
AI ReviewSummaryThis PR adds optional per-column projection codec declarations, binds visible output names to existing physical projection columns, and gates publication through replicated metadata and distributed DDL. Reviewed the current diff and implementation against all 94 prior review threads, their replies, and the conversation. No actionable findings remain under the current, deliberately narrower codec contract. The new declaration form was traced through parsing, formatting, AST cloning/hashing/JSON, the query fuzzer, Final VerdictStatus: ✅ Approve. No new inline findings or thread replies are required. |
Add an optional column list to a projection declaration, accepted by both
`CREATE TABLE` and `ALTER TABLE ... ADD PROJECTION`:
PROJECTION p (ts CODEC(DoubleDelta, ZSTD)) AS (SELECT id, ts ORDER BY ts)
Only the columns being overridden need to be listed, and `CODEC` is the
only property that may be declared. Declaring a column's type is optional;
doing so pins it against `ALTER TABLE ... MODIFY COLUMN` for as long as the
projection exists.
`system.projections` gains a `codecs` column.
- Extracts `isLossyCodecForType` into CompressionFactory to deduplicate logic between MergeTreeData and ProjectionsDescription. - Adds `validateDeclaredColumnCodecs` to InterpreterHypotheticalObjectQuery to reject invalid codecs in hypothetical queries rather than silently ignoring them. - Updates documentation regarding projection column codecs overriding, changing declared codecs, and aggregate projections. - Adds a stateful mutation test to verify column type changes correctly re-infer codec arguments during projection rebuilds.
a5f4703 to
7bc8cc4
Compare
e5d5040 to
ac0631b
Compare
Build profile diff (arm_release)Comparing commit See the job log for details. |
The Analyzer can rename `countDistinct` to `uniqExact`, while other expression rewrites retain their original spellings in projection metadata. Check both spellings against the stored columns before binding a codec, and reject ambiguous matches. Cover `countDistinct` writes and reads across `ATTACH TABLE`. Related: ClickHouse#120281 (comment)
A projection may store both `count()` and `count() IGNORE NULLS`. When a codec is declared only for another output, their alternative spellings need no disambiguation. Keep ambiguity rejection for outputs named by codec declarations. Add a stateless regression with a codec on the grouping key. Related: ClickHouse#120281
Projection outputs may share one physical column. Require uniqueness only when a codec declaration targets that physical column, so a declaration for another output does not reject an otherwise valid projection. Exercise creation, writing, and forced reads for aggregate and normal projections. ClickHouse#120281 (comment)
Use the original `SELECT` output set for binding when appended `ORDER BY` expressions expand to multiple columns. Read physical names from the legacy interpreter's rewritten `SELECT`, which already expands table `ALIAS` expressions before projection metadata is built. Add stateless coverage for aggregate and filtered alias outputs, a visible output under `COLUMNS`, and hidden ordering columns. Related: ClickHouse#120281 Review: ClickHouse#120281 (comment) Review: ClickHouse#120281 (comment)
Keep table `ALIAS` and `MATERIALIZED` markers in the temporary analyzer schema while omitting their expressions. This makes `SELECT *` expand to the same visible columns as the projection interpreter and avoids evaluating an alias during `ATTACH TABLE`. Cover accepted stored output `v` and rejected hidden alias `av`. Related: ClickHouse#120281
Bring in the upstream fix for flaky `02317_distinct_in_order_optimization_explain` while keeping the projection codec changes on current master. Related: ClickHouse#125742 Related: ClickHouse#120281
Expand projection `SELECT` matchers with the source columns used by the stored projection interpreter. This keeps `ALIAS` and `MATERIALIZED` columns out of matcher expansion while preserving the original expression names used in codec declarations. Cover `CREATE`, `ALTER`, materialization, and an aggregate expression name in a stateless regression. Related: ClickHouse#120281 (comment)
The Analyzer expands `untuple` into multiple visible outputs. Bind codec declarations against those resolved outputs instead of requiring the unexpanded `SELECT` AST to have the same number of children. Cover `CREATE`, `ALTER`, materialization, and reattach with a projection that stores codec targets on both sides of `untuple`. Related: ClickHouse#120281 (comment)
The legacy interpreter name identifies each output when present in projection metadata. The Analyzer rewritten name may refer to another stored output, so consult it only when the original is absent. Add a stateless regression for creation, alteration, materialization, and reload.\n\nReview: ClickHouse#120281 (comment)
Enable the explicit codec DDL opt-in for the new expression-name tests. Exclude the two tests that require plain `DETACH TABLE` and `ATTACH TABLE` from the `Replicated` database lane, where plain detach is unsupported. Keep the unbound aggregate test in that lane with the opt-in enabled. CI: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=120281&sha=59b81eb6122d0a6802687507d1f947faa4967eab&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20s3%20storage%2C%20DBReplicated%2C%20parallel%2C%201%2F2%29 CI: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=120281&sha=59b81eb6122d0a6802687507d1f947faa4967eab&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20s3%20storage%2C%20DBReplicated%2C%20parallel%2C%202%2F2%29 PR: ClickHouse#120281
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
916b357 to
d4fe67a
Compare
…dl` under 26.11 Master is now at 26.11, so the `settings_changes_history` style check requires the new setting to carry a 26.11 history record. The setting has not shipped in any release, so its only record moves from 26.10 to 26.11.
09384a9 to
b137d43
Compare
The test asserted that a legacy `CREATE TABLE ... ON CLUSTER ... AS` (with `distributed_ddl_entry_format_version` 2) succeeds when the source table exists only on the worker. Master now resolves the inherited definition on the initiator for that path to check the `TABLE_ENGINE` grant, so the initiator rejects that scenario by design and the test fails in the flaky check. The behavior the test covered is not changed by this PR. The projection-codec handling of legacy `CREATE ... AS` stays covered by `05322_projection_codec_legacy_cluster_copy`. Also remove the `cluster_worker_only` clusters that only this test used. Related: ClickHouse#118866
…ECT` For a filtered normal projection, `fillProjectionDescriptionByQuery` replaces the `ORDER BY` expression appended to the `SELECT` list with the columns that expression reads. Codec binding still dropped only the last child of that rewritten list, so ordering inputs remained among the visible outputs: - `PROJECTION p (k CODEC(ZSTD)) AS (SELECT k, v WHERE v > 0 ORDER BY (k, j))` failed with "Column `k` ambiguously names more than one output", in both `CREATE TABLE` and `ALTER TABLE ... ADD PROJECTION`. - `SELECT v WHERE v > 0 ORDER BY (k, j)` accepted a codec on `k`, which is not an output of the projection. Take the visible outputs from the projection's own query, which carries the single appended `ORDER BY` child. Also stop requiring at least one stored child after the visible outputs, since an `ORDER BY` that reads no columns appends none; such a projection now reaches its own sorting-key error. Reported by the AI review on ClickHouse#120281
…ted` database In a `Replicated` database the `CREATE TABLE` is published to Keeper, so the projection column codec gate rejected it with `SUPPORT_IS_DISABLED` in the DBReplicated stateless job. Use the same tags as the sibling codec binding tests, such as `05401_projection_codec_visible_output_binding`.
|
@CurtizJ any thoughts or guidance on this pr? Happy to meet sometime to talk about it. |
|
Dear @CurtizJ, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
Related: #28932
Related: #74234
Projections store their own copy of selected columns, often in a different sort order from the parent table. This PR lets a projection override compression codecs for selected output columns:
The column list is optional and partial. Each listed name must be an output column of the projection query; its type is inferred from that query. Only
CODECmay be declared. The first release permitsNONE,LZ4,ZSTD,Delta, andDoubleDelta, with the usual codec and output-type validation under a fixed policy that does not depend on session opt-ins. Explicit types, subcolumns, andCODEC(Default)are unsupported.The syntax works in
CREATE TABLEandALTER TABLE ... ADD PROJECTION. Replicated tables andON CLUSTERDDL requireallow_projection_column_codecs_in_replicated_or_distributed_ddl = 1;ON CLUSTERalso requiresdistributed_ddl_entry_format_version >= 2, or version 3 forCREATE TABLE ... AScopies. It does not add skip indexes inside projections.Added stateless tests covering creation, alteration, replication and cluster DDL, and AST JSON round trips. Focused local checks also covered projection part copying, backup and restore, and unavailable-projection behavior.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
A projection can now override compression codecs for selected output columns by adding an optional column list before the projection query in
CREATE TABLEorALTER TABLE ... ADD PROJECTION. The first release supportsNONE,LZ4,ZSTD,Delta, andDoubleDelta; column types are inferred from the projection query, and explicit types, subcolumns, andCODEC(Default)are unsupported. Replicated and distributed DDL requiresallow_projection_column_codecs_in_replicated_or_distributed_ddl = 1; distributed DDL also requiresdistributed_ddl_entry_format_version >= 2, or version 3 forCREATE TABLE ... AScopies.Workflow [PR]
Sync PR [sync-upstream/pr/120281]