Repository navigation
Fix projection rewrite collapsing groups when WHERE and GROUP BY share a column - #106590
Conversation
…e a column Closes: ClickHouse#106573 A `SELECT c, count() FROM t WHERE c GROUP BY c` query against a `MergeTree` table that has the implicit `_minmax_count_projection`, an explicit aggregate projection, or a normal projection returned wrong results: every group collapsed into a single row whose key was a constant and whose `count()` was the total number of matching rows. `QueryDAG::findInOutputs` in `projectionsCommon.cpp` replaces a filter column output with a `ColumnConst` of value `1` when the filter column survives `FilterStep` (`remove_filter_column == false`). The substitution assumes that, post-filter, every surviving row of the filter expression equals `1` -- which is true when the filter expression is a derived boolean like `c > 5`, but wrong when the filter expression is the column itself. In `WHERE c GROUP BY c` the filter expression IS the column `c`; post-filter it still carries the actual data values (`1`, `2`, ...) and is also the data column referenced by `GROUP BY` and the `SELECT` list under the same `result_name` (`__table1.c`). With the substitution, projection rewrite later folded the `GROUP BY` key into a `ColumnConst(UInt8)` -- visible in `EXPLAIN actions=1` as `COLUMN Const(UInt8) -> __table1.c UInt8` inside the `FilterStep` actions -- so `AggregatingStep` saw all input rows under one constant key value and produced one collapsed row per query. Drop the constant substitution. The original boolean filter expression is still returned by `findInOutputs`, and `QueryDAG::build` already wraps it as a separate `_projection_filter` alias prepended to the dag outputs, so the filter remains correctly attached to the rewritten plan. Skipping the substitution leaves the output as the data column it actually represents. The cost is at most a recomputation of the boolean expression in `optimizeUseNormalProjection`, which is cheap; correctness wins. The bug affects all three projection-rewrite paths in `projectionsCommon.cpp` (row-level filter, prewhere, regular filter) and reproduces with `_minmax_count_projection`, an explicit aggregate projection, and a normal projection. The regression test exercises all three. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Pre-PR validation gate
Session id: cron:clickhouse-ci-task-worker:20260605-163800 |
|
cc @KochetovNicolai @novikd could you review this? It removes an unsound |
|
Workflow [PR], commit [82d826c] Summary: ✅
AI ReviewSummaryThis PR removes the unsound Final VerdictStatus: ✅ Approve |
|
@groeneai build check failed |
|
@fm4v thanks for flagging. The Evidence
Source of the regressionPR #106102 ( int last_version; // line 731
String metadata_path;
CompressionMethod compression_method; // line 733
if (!catalog) { ... last_version = ...; compression_method = ...; }
else { ... last_version = ...; compression_method = ...; }CIDB (last 2 days, ActionI am filing a separate one-line fix PR against master (initialize
Session: cron:clickhouse-ci-task-worker:20260605-222000 |
…rg::alter PR ClickHouse#106102 (merged 2026-06-05 17:43 UTC) refactored Iceberg::alter to declare last_version and compression_method outside an if/else that assigns them in both branches. Clang-tidy cppcoreguidelines-init-variables flags the bare declarations and Build (arm_tidy) is built with -warnings-as-errors, so the build fails for every PR whose CI ran on master after this commit. CIDB shows 30+ unrelated PRs hitting this in the last 2 days (e.g. ClickHouse#89360, ClickHouse#103540, ClickHouse#106120, ClickHouse#106386, ClickHouse#106404, ClickHouse#106522, ClickHouse#105102, ClickHouse#106590). Initialize both variables to safe defaults at declaration. They are unconditionally overwritten in both if and else branches before use, so behavior is unchanged. The new defaults are only relevant if a future code path skips both assignments, in which case last_version=0 and compression_method=CompressionMethod::None are sane no-op values (the same defaults the old structured-binding form would produce through default-construction of the destructured aggregate). Co-Authored-By: Claude Opus 4.8 <[email protected]> (cherry picked from commit d72cac5)
…rg::alter PR ClickHouse#106102 (merged 2026-06-05 17:43 UTC) refactored Iceberg::alter to declare last_version and compression_method outside an if/else that assigns them in both branches. Clang-tidy cppcoreguidelines-init-variables flags the bare declarations and Build (arm_tidy) is built with -warnings-as-errors, so the build fails for every PR whose CI ran on master after this commit. CIDB shows 30+ unrelated PRs hitting this in the last 2 days (e.g. ClickHouse#89360, ClickHouse#103540, ClickHouse#106120, ClickHouse#106386, ClickHouse#106404, ClickHouse#106522, ClickHouse#105102, ClickHouse#106590). Initialize both variables to safe defaults at declaration. They are unconditionally overwritten in both if and else branches before use, so behavior is unchanged. The new defaults are only relevant if a future code path skips both assignments, in which case last_version=0 and compression_method=CompressionMethod::None are sane no-op values (the same defaults the old structured-binding form would produce through default-construction of the destructured aggregate). Co-Authored-By: Claude Opus 4.8 <[email protected]> (cherry picked from commit d72cac5)
…rg::alter PR ClickHouse#106102 (merged 2026-06-05 17:43 UTC) refactored Iceberg::alter to declare last_version and compression_method outside an if/else that assigns them in both branches. Clang-tidy cppcoreguidelines-init-variables flags the bare declarations and Build (arm_tidy) is built with -warnings-as-errors, so the build fails for every PR whose CI ran on master after this commit. CIDB shows 30+ unrelated PRs hitting this in the last 2 days (e.g. ClickHouse#89360, ClickHouse#103540, ClickHouse#106120, ClickHouse#106386, ClickHouse#106404, ClickHouse#106522, ClickHouse#105102, ClickHouse#106590). Initialize both variables to safe defaults at declaration. They are unconditionally overwritten in both if and else branches before use, so behavior is unchanged. The new defaults are only relevant if a future code path skips both assignments, in which case last_version=0 and compression_method=CompressionMethod::None are sane no-op values (the same defaults the old structured-binding form would produce through default-construction of the destructured aggregate). Co-Authored-By: Claude Opus 4.8 <[email protected]> (cherry picked from commit d72cac5)
…rg::alter PR ClickHouse#106102 (merged 2026-06-05 17:43 UTC) refactored Iceberg::alter to declare last_version and compression_method outside an if/else that assigns them in both branches. Clang-tidy cppcoreguidelines-init-variables flags the bare declarations and Build (arm_tidy) is built with -warnings-as-errors, so the build fails for every PR whose CI ran on master after this commit. CIDB shows 30+ unrelated PRs hitting this in the last 2 days (e.g. ClickHouse#89360, ClickHouse#103540, ClickHouse#106120, ClickHouse#106386, ClickHouse#106404, ClickHouse#106522, ClickHouse#105102, ClickHouse#106590). Initialize both variables to safe defaults at declaration. They are unconditionally overwritten in both if and else branches before use, so behavior is unchanged. The new defaults are only relevant if a future code path skips both assignments, in which case last_version=0 and compression_method=CompressionMethod::None are sane no-op values (the same defaults the old structured-binding form would produce through default-construction of the destructured aggregate). Co-Authored-By: Claude Opus 4.8 <[email protected]> (cherry picked from commit d72cac5)
…rg::alter PR ClickHouse#106102 (merged 2026-06-05 17:43 UTC) refactored Iceberg::alter to declare last_version and compression_method outside an if/else that assigns them in both branches. Clang-tidy cppcoreguidelines-init-variables flags the bare declarations and Build (arm_tidy) is built with -warnings-as-errors, so the build fails for every PR whose CI ran on master after this commit. CIDB shows 30+ unrelated PRs hitting this in the last 2 days (e.g. ClickHouse#89360, ClickHouse#103540, ClickHouse#106120, ClickHouse#106386, ClickHouse#106404, ClickHouse#106522, ClickHouse#105102, ClickHouse#106590). Initialize both variables to safe defaults at declaration. They are unconditionally overwritten in both if and else branches before use, so behavior is unchanged. The new defaults are only relevant if a future code path skips both assignments, in which case last_version=0 and compression_method=CompressionMethod::None are sane no-op values (the same defaults the old structured-binding form would produce through default-construction of the destructured aggregate). Co-Authored-By: Claude Opus 4.8 <[email protected]> (cherry picked from commit d72cac5)
…rg::alter PR ClickHouse#106102 (merged 2026-06-05 17:43 UTC) refactored Iceberg::alter to declare last_version and compression_method outside an if/else that assigns them in both branches. Clang-tidy cppcoreguidelines-init-variables flags the bare declarations and Build (arm_tidy) is built with -warnings-as-errors, so the build fails for every PR whose CI ran on master after this commit. CIDB shows 30+ unrelated PRs hitting this in the last 2 days (e.g. ClickHouse#89360, ClickHouse#103540, ClickHouse#106120, ClickHouse#106386, ClickHouse#106404, ClickHouse#106522, ClickHouse#105102, ClickHouse#106590). Initialize both variables to safe defaults at declaration. They are unconditionally overwritten in both if and else branches before use, so behavior is unchanged. The new defaults are only relevant if a future code path skips both assignments, in which case last_version=0 and compression_method=CompressionMethod::None are sane no-op values (the same defaults the old structured-binding form would produce through default-construction of the destructured aggregate). Co-Authored-By: Claude Opus 4.8 <[email protected]> (cherry picked from commit d72cac5)
…rg::alter PR ClickHouse#106102 (merged 2026-06-05 17:43 UTC) refactored Iceberg::alter to declare last_version and compression_method outside an if/else that assigns them in both branches. Clang-tidy cppcoreguidelines-init-variables flags the bare declarations and Build (arm_tidy) is built with -warnings-as-errors, so the build fails for every PR whose CI ran on master after this commit. CIDB shows 30+ unrelated PRs hitting this in the last 2 days (e.g. ClickHouse#89360, ClickHouse#103540, ClickHouse#106120, ClickHouse#106386, ClickHouse#106404, ClickHouse#106522, ClickHouse#105102, ClickHouse#106590). Initialize both variables to safe defaults at declaration. They are unconditionally overwritten in both if and else branches before use, so behavior is unchanged. The new defaults are only relevant if a future code path skips both assignments, in which case last_version=0 and compression_method=CompressionMethod::None are sane no-op values (the same defaults the old structured-binding form would produce through default-construction of the destructured aggregate). Co-Authored-By: Claude Opus 4.8 <[email protected]> (cherry picked from commit d72cac5)
…rg::alter PR ClickHouse#106102 (merged 2026-06-05 17:43 UTC) refactored Iceberg::alter to declare last_version and compression_method outside an if/else that assigns them in both branches. Clang-tidy cppcoreguidelines-init-variables flags the bare declarations and Build (arm_tidy) is built with -warnings-as-errors, so the build fails for every PR whose CI ran on master after this commit. CIDB shows 30+ unrelated PRs hitting this in the last 2 days (e.g. ClickHouse#89360, ClickHouse#103540, ClickHouse#106120, ClickHouse#106386, ClickHouse#106404, ClickHouse#106522, ClickHouse#105102, ClickHouse#106590). Initialize both variables to safe defaults at declaration. They are unconditionally overwritten in both if and else branches before use, so behavior is unchanged. The new defaults are only relevant if a future code path skips both assignments, in which case last_version=0 and compression_method=CompressionMethod::None are sane no-op values (the same defaults the old structured-binding form would produce through default-construction of the destructured aggregate). Co-Authored-By: Claude Opus 4.8 <[email protected]> (cherry picked from commit d72cac5)
…rg::alter PR ClickHouse#106102 (merged 2026-06-05 17:43 UTC) refactored Iceberg::alter to declare last_version and compression_method outside an if/else that assigns them in both branches. Clang-tidy cppcoreguidelines-init-variables flags the bare declarations and Build (arm_tidy) is built with -warnings-as-errors, so the build fails for every PR whose CI ran on master after this commit. CIDB shows 30+ unrelated PRs hitting this in the last 2 days (e.g. ClickHouse#89360, ClickHouse#103540, ClickHouse#106120, ClickHouse#106386, ClickHouse#106404, ClickHouse#106522, ClickHouse#105102, ClickHouse#106590). Initialize both variables to safe defaults at declaration. They are unconditionally overwritten in both if and else branches before use, so behavior is unchanged. The new defaults are only relevant if a future code path skips both assignments, in which case last_version=0 and compression_method=CompressionMethod::None are sane no-op values (the same defaults the old structured-binding form would produce through default-construction of the destructured aggregate). Co-Authored-By: Claude Opus 4.8 <[email protected]> (cherry picked from commit d72cac5)
…rg::alter PR #106102 (merged 2026-06-05 17:43 UTC) refactored Iceberg::alter to declare last_version and compression_method outside an if/else that assigns them in both branches. Clang-tidy cppcoreguidelines-init-variables flags the bare declarations and Build (arm_tidy) is built with -warnings-as-errors, so the build fails for every PR whose CI ran on master after this commit. CIDB shows 30+ unrelated PRs hitting this in the last 2 days (e.g. #89360, #103540, #106120, #106386, #106404, #106522, #105102, #106590). Initialize both variables to safe defaults at declaration. They are unconditionally overwritten in both if and else branches before use, so behavior is unchanged. The new defaults are only relevant if a future code path skips both assignments, in which case last_version=0 and compression_method=CompressionMethod::None are sane no-op values (the same defaults the old structured-binding form would produce through default-construction of the destructured aggregate). Co-Authored-By: Claude Opus 4.8 <[email protected]> (cherry picked from commit d72cac5)
…rg::alter PR ClickHouse#106102 (merged 2026-06-05 17:43 UTC) refactored Iceberg::alter to declare last_version and compression_method outside an if/else that assigns them in both branches. Clang-tidy cppcoreguidelines-init-variables flags the bare declarations and Build (arm_tidy) is built with -warnings-as-errors, so the build fails for every PR whose CI ran on master after this commit. CIDB shows 30+ unrelated PRs hitting this in the last 2 days (e.g. ClickHouse#89360, ClickHouse#103540, ClickHouse#106120, ClickHouse#106386, ClickHouse#106404, ClickHouse#106522, ClickHouse#105102, ClickHouse#106590). Initialize both variables to safe defaults at declaration. They are unconditionally overwritten in both if and else branches before use, so behavior is unchanged. The new defaults are only relevant if a future code path skips both assignments, in which case last_version=0 and compression_method=CompressionMethod::None are sane no-op values (the same defaults the old structured-binding form would produce through default-construction of the destructured aggregate). Co-Authored-By: Claude Opus 4.8 <[email protected]> (cherry picked from commit d72cac5)
…rg::alter PR ClickHouse#106102 (merged 2026-06-05 17:43 UTC) refactored Iceberg::alter to declare last_version and compression_method outside an if/else that assigns them in both branches. Clang-tidy cppcoreguidelines-init-variables flags the bare declarations and Build (arm_tidy) is built with -warnings-as-errors, so the build fails for every PR whose CI ran on master after this commit. CIDB shows 30+ unrelated PRs hitting this in the last 2 days (e.g. ClickHouse#89360, ClickHouse#103540, ClickHouse#106120, ClickHouse#106386, ClickHouse#106404, ClickHouse#106522, ClickHouse#105102, ClickHouse#106590). Initialize both variables to safe defaults at declaration. They are unconditionally overwritten in both if and else branches before use, so behavior is unchanged. The new defaults are only relevant if a future code path skips both assignments, in which case last_version=0 and compression_method=CompressionMethod::None are sane no-op values (the same defaults the old structured-binding form would produce through default-construction of the destructured aggregate). Co-Authored-By: Claude Opus 4.8 <[email protected]> (cherry picked from commit d72cac5)
…rg::alter PR #106102 (merged 2026-06-05 17:43 UTC) refactored Iceberg::alter to declare last_version and compression_method outside an if/else that assigns them in both branches. Clang-tidy cppcoreguidelines-init-variables flags the bare declarations and Build (arm_tidy) is built with -warnings-as-errors, so the build fails for every PR whose CI ran on master after this commit. CIDB shows 30+ unrelated PRs hitting this in the last 2 days (e.g. #89360, #103540, #106120, #106386, #106404, #106522, #105102, #106590). Initialize both variables to safe defaults at declaration. They are unconditionally overwritten in both if and else branches before use, so behavior is unchanged. The new defaults are only relevant if a future code path skips both assignments, in which case last_version=0 and compression_method=CompressionMethod::None are sane no-op values (the same defaults the old structured-binding form would produce through default-construction of the destructured aggregate). Co-Authored-By: Claude Opus 4.8 <[email protected]> (cherry picked from commit d72cac5)
…rg::alter PR #106102 (merged 2026-06-05 17:43 UTC) refactored Iceberg::alter to declare last_version and compression_method outside an if/else that assigns them in both branches. Clang-tidy cppcoreguidelines-init-variables flags the bare declarations and Build (arm_tidy) is built with -warnings-as-errors, so the build fails for every PR whose CI ran on master after this commit. CIDB shows 30+ unrelated PRs hitting this in the last 2 days (e.g. #89360, #103540, #106120, #106386, #106404, #106522, #105102, #106590). Initialize both variables to safe defaults at declaration. They are unconditionally overwritten in both if and else branches before use, so behavior is unchanged. The new defaults are only relevant if a future code path skips both assignments, in which case last_version=0 and compression_method=CompressionMethod::None are sane no-op values (the same defaults the old structured-binding form would produce through default-construction of the destructured aggregate). Co-Authored-By: Claude Opus 4.8 <[email protected]> (cherry picked from commit d72cac5)
…rg::alter PR ClickHouse#106102 (merged 2026-06-05 17:43 UTC) refactored Iceberg::alter to declare last_version and compression_method outside an if/else that assigns them in both branches. Clang-tidy cppcoreguidelines-init-variables flags the bare declarations and Build (arm_tidy) is built with -warnings-as-errors, so the build fails for every PR whose CI ran on master after this commit. CIDB shows 30+ unrelated PRs hitting this in the last 2 days (e.g. ClickHouse#89360, ClickHouse#103540, ClickHouse#106120, ClickHouse#106386, ClickHouse#106404, ClickHouse#106522, ClickHouse#105102, ClickHouse#106590). Initialize both variables to safe defaults at declaration. They are unconditionally overwritten in both if and else branches before use, so behavior is unchanged. The new defaults are only relevant if a future code path skips both assignments, in which case last_version=0 and compression_method=CompressionMethod::None are sane no-op values (the same defaults the old structured-binding form would produce through default-construction of the destructured aggregate). Co-Authored-By: Claude Opus 4.8 <[email protected]> (cherry picked from commit d72cac5)
…rg::alter PR #106102 (merged 2026-06-05 17:43 UTC) refactored Iceberg::alter to declare last_version and compression_method outside an if/else that assigns them in both branches. Clang-tidy cppcoreguidelines-init-variables flags the bare declarations and Build (arm_tidy) is built with -warnings-as-errors, so the build fails for every PR whose CI ran on master after this commit. CIDB shows 30+ unrelated PRs hitting this in the last 2 days (e.g. #89360, #103540, #106120, #106386, #106404, #106522, #105102, #106590). Initialize both variables to safe defaults at declaration. They are unconditionally overwritten in both if and else branches before use, so behavior is unchanged. The new defaults are only relevant if a future code path skips both assignments, in which case last_version=0 and compression_method=CompressionMethod::None are sane no-op values (the same defaults the old structured-binding form would produce through default-construction of the destructured aggregate). Co-Authored-By: Claude Opus 4.8 <[email protected]> (cherry picked from commit d72cac5)
|
@groenai push empty commit to restart ci. |
|
@fm4v done — empty commit pushed, CI is restarting on Note: master fix PR #106615 (the arm_tidy fix for PR #106102's uninitialized variables in |
CI Ledger — covered SHA:
|
| Failure | Classification | Disposition |
|---|---|---|
Stateless tests (amd_debug, parallel) (CheckRun: CANCELLED) |
infra (job cancelled before reporting any per-test results) | Zero per-test FAIL/ERROR rows in CIDB for this SHA across all checks. The praktika runner cancelled this single amd_debug, parallel job (likely runner-pressure / scheduling, not a test outcome). 64 sibling Stateless test jobs and 17 build variants ran clean (0 failures). arm_tidy SUCCESS. Bugfix validation, Fast test, Style check, Code Review, AST fuzzer, all Integration tests, all Unit tests: SUCCESS. |
Mergeable Check / PR (StatusContexts) |
aggregator | Aggregator FAILURE because of the cancelled CheckRun. Tracked together. |
PR-caused failure check: none. PR diff is unchanged (this commit is the empty Restart CI per @ fm4v's directive); previously verified projection-rewrite edit in src/Processors/QueryPlan/Optimizations/projectionsCommon.cpp plus the new test file. Zero per-test failures across the entire run; the only red CheckRun is one cancelled amd_debug, parallel slot with no test rows reported. Not actionable on this PR.
Moving to on_review.
|
@groeneai fix CI errors in this PR |
…106573-projection-filter-column-data-corruption
|
@fm4v The only red check was
The branch was also ~1238 commits behind master, including the period when I have refreshed the branch onto current master and pushed. New HEAD: |
…ion rewrite The projection-rewrite fix in ad61b73 (drop the const-1 substitution for a surviving filter column) raised a review question: when the filter expression is non-deterministic, could the post-read expression that rebuilds the surviving column re-evaluate it and disagree with the value that passed the filter? It cannot. optimizeUseNormalProjection turns the filter into projection PREWHERE via splitAndFillPrewhereInfo, which keeps the computed filter expression as a PREWHERE output; the post-read ExpressionStep consumes that value as an input (alias only) rather than recomputing it. EXPLAIN confirms a single rand() node in the whole plan, and WHERE rand()-derived predicates never output a row that failed the filter. The aggregate and minmax projection paths additionally reject non-deterministic filters up front via isDeterministicInScopeOfQuery. This adds a regression case asserting that a non-deterministic surviving filter served from a normal projection keeps the value that passed the filter (min(r) = 1), locking the contract in. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
CI finished on HEAD
Fast test, Style check, and Bugfix validation are green on this HEAD. |
…r-column-data-corruption
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 2/2 (100.00%) | Lost baseline coverage: none · Uncovered code |
…rojection key) The projection reproducer in ClickHouse#110795 filters on a column not stored in the projection (WHERE a over a projection on b). The previous revision used the projection key as the filter column, which exercises the separate ClickHouse#106590 rewrite instead. Add the exact issue shape back: WHERE a GROUP BY b over a projection on b, with result-parity against the projections-off path as the regression lock (force_optimize_projection confirms the projection is not chosen for this shape). enable_analyzer = 1 stays scoped to the two plan-shape EXPLAIN assertions; the result-comparison queries run under both analyzers. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…allel-replicas read paths A bare non-UInt8 column in WHERE (implicit `col != 0`) is coerced by the normal read path but was rejected with ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER on the projection and parallel-replicas read paths (issue ClickHouse#110795). The defect no longer reproduces on master (fixed via the WHERE-field-condition work in ClickHouse#89603 and the projection filter fix in ClickHouse#106590), but there was no test covering the non-UInt8 case across both alternative read paths. This adds one. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…rg::alter PR ClickHouse#106102 (merged 2026-06-05 17:43 UTC) refactored Iceberg::alter to declare last_version and compression_method outside an if/else that assigns them in both branches. Clang-tidy cppcoreguidelines-init-variables flags the bare declarations and Build (arm_tidy) is built with -warnings-as-errors, so the build fails for every PR whose CI ran on master after this commit. CIDB shows 30+ unrelated PRs hitting this in the last 2 days (e.g. ClickHouse#89360, ClickHouse#103540, ClickHouse#106120, ClickHouse#106386, ClickHouse#106404, ClickHouse#106522, ClickHouse#105102, ClickHouse#106590). Initialize both variables to safe defaults at declaration. They are unconditionally overwritten in both if and else branches before use, so behavior is unchanged. The new defaults are only relevant if a future code path skips both assignments, in which case last_version=0 and compression_method=CompressionMethod::None are sane no-op values (the same defaults the old structured-binding form would produce through default-construction of the destructured aggregate). Co-Authored-By: Claude Opus 4.8 <[email protected]> (cherry picked from commit d72cac5)
…rg::alter PR ClickHouse#106102 (merged 2026-06-05 17:43 UTC) refactored Iceberg::alter to declare last_version and compression_method outside an if/else that assigns them in both branches. Clang-tidy cppcoreguidelines-init-variables flags the bare declarations and Build (arm_tidy) is built with -warnings-as-errors, so the build fails for every PR whose CI ran on master after this commit. CIDB shows 30+ unrelated PRs hitting this in the last 2 days (e.g. ClickHouse#89360, ClickHouse#103540, ClickHouse#106120, ClickHouse#106386, ClickHouse#106404, ClickHouse#106522, ClickHouse#105102, ClickHouse#106590). Initialize both variables to safe defaults at declaration. They are unconditionally overwritten in both if and else branches before use, so behavior is unchanged. The new defaults are only relevant if a future code path skips both assignments, in which case last_version=0 and compression_method=CompressionMethod::None are sane no-op values (the same defaults the old structured-binding form would produce through default-construction of the destructured aggregate). Co-Authored-By: Claude Opus 4.8 <[email protected]> (cherry picked from commit d72cac5)
…rg::alter PR ClickHouse#106102 (merged 2026-06-05 17:43 UTC) refactored Iceberg::alter to declare last_version and compression_method outside an if/else that assigns them in both branches. Clang-tidy cppcoreguidelines-init-variables flags the bare declarations and Build (arm_tidy) is built with -warnings-as-errors, so the build fails for every PR whose CI ran on master after this commit. CIDB shows 30+ unrelated PRs hitting this in the last 2 days (e.g. ClickHouse#89360, ClickHouse#103540, ClickHouse#106120, ClickHouse#106386, ClickHouse#106404, ClickHouse#106522, ClickHouse#105102, ClickHouse#106590). Initialize both variables to safe defaults at declaration. They are unconditionally overwritten in both if and else branches before use, so behavior is unchanged. The new defaults are only relevant if a future code path skips both assignments, in which case last_version=0 and compression_method=CompressionMethod::None are sane no-op values (the same defaults the old structured-binding form would produce through default-construction of the destructured aggregate). Co-Authored-By: Claude Opus 4.8 <[email protected]> (cherry picked from commit d72cac5)
…allel-replicas read paths A bare non-UInt8 column in WHERE (implicit `col != 0`) is coerced by the normal read path but was rejected with ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER on the projection and parallel-replicas read paths (issue ClickHouse#110795). The defect no longer reproduces on master (fixed via the WHERE-field-condition work in ClickHouse#89603 and the projection filter fix in ClickHouse#106590), but there was no test covering the non-UInt8 case across both alternative read paths. This adds one. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…rojection key) The projection reproducer in ClickHouse#110795 filters on a column not stored in the projection (WHERE a over a projection on b). The previous revision used the projection key as the filter column, which exercises the separate ClickHouse#106590 rewrite instead. Add the exact issue shape back: WHERE a GROUP BY b over a projection on b, with result-parity against the projections-off path as the regression lock (force_optimize_projection confirms the projection is not chosen for this shape). enable_analyzer = 1 stays scoped to the two plan-shape EXPLAIN assertions; the result-comparison queries run under both analyzers. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Closes: #106573
A
SELECT c, count() FROM t WHERE c GROUP BY cquery against aMergeTreetable with the implicit_minmax_count_projection, an explicit aggregate projection, or a normal projection returned wrong results: every group collapsed into a single row whose key was a constant and whosecount()was the total number of matching rows.QueryDAG::findInOutputsinprojectionsCommon.cppreplaced a filter column output with aColumnConstof value1when the filter column survivedFilterStep(remove_filter_column == false). The substitution assumes that, post-filter, every surviving row of the filter expression equals1, which holds when the filter expression is a derived boolean likec > 5but is wrong when the filter expression is the column itself. InWHERE c GROUP BY cthe filter expression IS the column, so the constant substitution destroyed the data column thatGROUP BYand theSELECTlist reference under the sameresult_name. Projection rewrite then folded theGROUP BYkey into aColumnConst, andAggregatingStepcollapsed every group into one.Drop the constant substitution. The original boolean filter expression is still returned by
findInOutputsandQueryDAG::buildwraps it as a separate_projection_filteralias prepended to the dag outputs, so the filter remains correctly attached. The bug affects all three projection rewrite paths (row-level filter, prewhere, regular filter); the regression test exercises_minmax_count_projection, an explicit aggregate projection, and a normal projection.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed wrong results for
SELECT c, count() FROM t WHERE c GROUP BY cagainst tables with the implicit_minmax_count_projection, an explicit aggregate projection, or a normal projection: every group used to collapse into one row with a constant key and the total row count.Documentation entry for user-facing changes
Version info
26.6.1.927