Repository navigation
Do not keep an IN set placeholder alive for INTERPOLATE - #118420
Conversation
`INTERPOLATE` keeps every column of the step below alive, because its expressions may name any of
them. The `Set` placeholder of an `IN` predicate is not one of those: its name is internal, no
expression can name it, and it cannot be materialized. Kept as an output it travelled past the filter
that consumes it into every step above, including ones that build rows out of the whole header:
SELECT a, k FROM coal FINAL WHERE dictGet('dict', 'val', toUInt64(k) % 500) >= 6
ORDER BY k WITH FILL FROM 0 TO 38 INTERPOLATE (a AS 7)
SETTINGS optimize_move_to_prewhere_if_final = 1;
-- Code: 246. SummingSortedAlgorithm failed to read row 0 of column 1 (__set_...), reason:
-- Cannot get value from Set: While executing CoalescingSortedTransform. (CORRUPTED_DATA)
`optimize_inverse_dictionary_lookup` (on by default) is what turns the `dictGet` comparison into a
membership test against such a set, and `optimize_move_to_prewhere_if_final` is what puts it under the
`FINAL` merge. The virtual row of an in-order read hit the same placeholder from the other side
(#111831, fixed in the virtual row itself).
A `Set` column - and the `Function` column of a lambda, which is a placeholder in the same way - is no
longer kept for `INTERPOLATE`, so neither reaches a step that materializes rows.
Closes: #112030
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Workflow [PR], commit [9647d62] Summary: ✅
AI ReviewSummaryThe PR fixes the new-planner Tests
Final VerdictLLVM Coverage ReportMeasured on commit 9647d62.
Changed lines: Changed C/C++ lines covered: 9/9 (100.00%) · Uncovered code |
| @@ -0,0 +1,54 @@ | |||
| -- `INTERPOLATE` keeps every column of the previous step alive, which used to include the `Set` | |||
There was a problem hiding this comment.
This regression file does not pin enable_analyzer = 1, so it does not guarantee that CI is exercising the only changed codepath in PlannerExpressionAnalysis.cpp; the legacy InterpreterSelectQuery path can still make the test pass. It also only constructs the __set_* carrier, while the code change adds a second contract for DataTypeFunction. Please force the analyzer here and add a tiny higher-order-function case so the isFunction() branch is covered too.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 12 s compile time in total, 7 of them have a recent master baseline. |
`analyzeLimitRange` adds an identity actions-chain step over every column the previous step makes available, so that columns read only by the LIMIT AFTER/UNTIL boundary survive chain finalization. That list also holds the `Function` column of every lambda and the `Set` placeholder of every `IN` of the projection step, so chain finalization made the projection output them, and they crossed into the `LimitRange` step header and, on a shard, into the header sent to the initiator. Three failures follow: - When the boundary repeats a lambda of the SELECT list, the boundary DAG takes that lambda from the header as an INPUT holding the folded constant. `removeUnusedActions` retyped that INPUT to a COLUMN in place (fixed in the previous commit) and `ExpressionActions::linearizeActions` aborted the server on an empty argument vector (STID 3843-5ec7, plain local SQL; also aborts the official 26.9.9.28 build). - `LimitRangeTransform` cuts the chunk, and cutting a constant `ColumnFunction` throws NOT_IMPLEMENTED "compareAt is not implemented for Function" inside a debug-build assertion. - A shard sends the lambda column, which has no serialization: NOT_IMPLEMENTED on the initiator or, before the previous commit, the same abort in `addConvertingActions` (STID 3843-4f7e, 3843-4f98). Build the identity step over value columns only, skipping the `Set` and `Function` types. `before_interpolate_actions` already applies this rule for the same reason (ClickHouse#118420). A boundary expression that needs a lambda or a set builds its own, as it already did when its lambda text differs from the SELECT list's. Neither type can be a boundary (boundaries are boolean) or a SELECT result, so nothing above the step loses a column it reads. The test is renamed to 05260_limit_after_until_lambda and covers the local LIMIT AFTER, LIMIT UNTIL and AFTER + UNTIL shapes, the debug-build shape, the rebuilt-set path, and the two remote shapes, which now return their rows instead of NOT_IMPLEMENTED. Co-Authored-By: Claude Opus 5.5 <[email protected]>
INTERPOLATEkeeps every column of the step below alive, because its expressions may name any of them. TheSetplaceholder of anINpredicate is not one of those: its name is internal, no expression can name it,and it cannot be materialized. Kept as an output it travelled past the filter that consumes it into every
step above, including ones that build rows out of the whole header:
optimize_inverse_dictionary_lookup(on by default) is what turns thedictGetcomparison into a membershiptest against such a set, and
optimize_move_to_prewhere_if_finalis what puts it under theFINALmerge. Thevirtual row of an in-order read hit the same placeholder from the other side (#111831, fixed in the virtual
row itself).
A
Setcolumn - and theFunctioncolumn of a lambda, which is a placeholder in the same way - is no longerkept for
INTERPOLATE, so neither reaches a step that materializes rows.Closes: #112030
Related: #111831
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fixed
CORRUPTED_DATA("Cannot get value from Set") for aFINALquery withORDER BY ... WITH FILL INTERPOLATEwhose filter is anINset moved intoPREWHERE: the set placeholder column is no longer keptalive past the filter.
Workflow [PR]
Sync PR [sync-upstream/pr/118420]
Version info
26.9.1.872(included in26.9and later)