Repository navigation
Fix column node make nullable - #95657
Conversation
|
Workflow [PR], commit [7ed0ef4] Summary: ❌
AI ReviewSummaryThis PR fixes Final Verdict
|
|
code seems good, but test fails for some reason |
|
@novikd, tests have failed. |
8e291c7 to
a1c9b2f
Compare
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.
… and WITH CUBE When `group_by_use_nulls=1`, the `AggregatingStep` output header is built via `convertToNullable` which (after this PR) correctly maps a `LowCardinality(T)` key to `LowCardinality(Nullable(T))`. However, the actions DAG built in `makeCreatingMissingKeysForGroupingSetDAG` (`AggregatingStep`) and `addGroupingSetForTotals` (`CubeStep`) guarded the `toNullable` insertion with `canBeInsideNullable`, which returns `false` for `LowCardinality` — so for `LowCardinality` keys the column flowed through unchanged as `LowCardinality(T)`, producing a logical error such as `Block structure mismatch in A stream: different types` in `AggregatingStep::transformPipeline` and `CubeStep::transformPipeline`. Use `removeLowCardinality(...)->canBeInsideNullable()` (the pattern already used in `JoinStepLogical`) so that `LowCardinality` keys are routed through `toNullable` as well, keeping the pipeline header consistent with the actual chunk types. Also extend `03821_analyzer_group_by_use_nulls` with `GROUPING SETS` and `WITH CUBE` cases for both `LowCardinality(String)` and `LowCardinality(UInt16)`, which are the failing combinations reported by Stress tests on #95657 (commit cf5fec0). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The previous version of the regression test for the LowCardinality + GROUPING SETS / WITH CUBE crash used a single-key GROUPING SETS with an empty `()` set, which collapses on aggregation and does not hit the missing-keys `makeCreatingMissingKeysForGroupingSetDAG` path. Replace it with a two-key table (`LowCardinality(UInt16)` × 2) and use `GROUPING SETS ((a, b), (a))` plus `WITH CUBE` / `WITH ROLLUP` on both keys — these all touch the failing code paths reported in #95657: - `AggregatingStep::transformPipeline` / `makeCreatingMissingKeysForGroupingSetDAG` - `CubeStep::transformPipeline` / `addGroupingSetForTotals` Verified by temporarily reverting the C++ fix: without it, the GROUPING SETS case throws `Block structure mismatch in Pipe stream: different types: __table1.b LowCardinality(UInt16) ... __table1.b LowCardinality(Nullable(UInt16))` — matching the Stress test failure from the CI report on commit cf5fec0. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The analyzer/planner side of the fix made `convertToNullable` and the pre-aggregation key types correctly map `LowCardinality(T)` to `LowCardinality(Nullable(T))` under `group_by_use_nulls`. The legacy planner had the analogous issue: in `ExpressionAnalyzer::analyzeAggregation` (both the explicit grouping-set and the regular paths) and in `InterpreterSelectQuery::getSampleBlockImpl` the aggregation-key type was computed via `makeNullableSafe`, which is a no-op for `LowCardinality(T)`. The runtime pipeline (`AggregatingStep`, `RollupTransform`, `CubeTransform`, the missing-keys DAG) still ultimately wraps such keys in `Nullable`, which then triggered `CANNOT_INSERT_NULL_IN_ORDINARY_COLUMN: Cannot convert NULL value to non-Nullable type: while converting source column ... LowCardinality(UInt16)` on `ROLLUP/CUBE/GROUPING SETS` with `enable_analyzer = 0`. Switch those three legacy call sites to `makeNullableOrLowCardinalityNullableSafe` so both planners stay consistent, and extend `03821_analyzer_group_by_use_nulls` with `enable_analyzer = 0` variants for every modifier (`WITH ROLLUP`, `WITH CUBE`, `GROUPING SETS`) — addresses the unresolved review comment from the AI reviewer on #95657. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
This was fixed by #105146. Let's update the branch. |
LLVM Coverage Report
Changed lines: 97.56% (40/41) | lost baseline coverage: 6 line(s) · Uncovered code |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix column with
LowCardinalitytype conversion toNullablewhengroup_by_use_nullsis enabled. Fixes #95299.Documentation entry for user-facing changes
Note
Medium Risk
Changes nullability conversion in analyzer/planner and aggregation execution to treat
LowCardinalitycolumns correctly, which can affect result types and GROUP BY WITH ROLLUP/CUBE output schemas. Scope is small and covered by a new regression test, but it touches core aggregation/type-handling paths.Overview
Fixes
group_by_use_nullshandling so converting GROUP BY keys/results to Nullable also works forLowCardinalitytypes by switching several call sites frommakeNullableSafetomakeNullableOrLowCardinalityNullableSafe(query tree nodes, planner aggregation-key typing, and rollup/aggregation headers/columns).Adds a stateless regression test exercising
LowCardinality(String)withGROUP BY ... WITH ROLLUP SETTINGS group_by_use_nulls=1, asserting the rolled-up key becomesNULLas expected.Written by Cursor Bugbot for commit 37102b7. This will update automatically on new commits. Configure here.
Version info
26.5.1.827