Repository navigation
Conversation
`tryBuildPrewhereSteps` splits a PREWHERE conjunction so that a guard filters before a condition that may throw, e.g. `substring(s, 1, 19) != 'invaliddatetime' AND toDateTime64(substring(s, 1, 19), 3) > ...`. The shared `substring(s, 1, 19)` is computed in step 1 and passed to step 2 by name. The Parquet V3 reader passes columns between steps only through slots of `extended_sample_block` (query outputs and file columns), so the intermediate had no slot and `preparePrewhere` dropped the split. In the single step `toDateTime64` ran on every row and threw CANNOT_PARSE_DATETIME on the row the guard rejects. MergeTree and Memory pass a name-keyed block between steps and return the row. Give such an intermediate a hidden slot in `RowSubgroup::output` after the columns of `extended_sample_block`, recorded in `prewhere_intermediates`. The producing step writes it like any prewhere output, later steps read it in `applyPrewhere`, the existing per-step filter loop filters it, and the last step drops every slot past `sample_block`. The name -> slot map is per `add_step` call, so the row-level filter and PREWHERE stay independent. A generated name equal to a file column still falls back to one step (04342). `decode_dictionary_as_replicated` skips a last step whose only input is an intermediate. Closes ClickHouse#132525 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Remove the unslotted_outputs comment, which restates the rule stated just above it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 1 finding; 1 full pass).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20261118-015500 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-41:20261118-004600 |
|
Workflow [PR], commit [4fea046] Summary: ❌
AI ReviewSummaryThe PR preserves split Parquet Missing context / blind spots
Final VerdictStatus: ✅ Approve |
CI finish ledger - 4fea046Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
The other CIDB Session id: cron:our-pr-ci-monitor:20261118-060016 |
Closes: #132525
Related: #129178
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed a
CANNOT_PARSE_DATETIME(or another conversion error) when reading Parquet files with a filter whose conditions share an expression, such assubstring(s, 1, 19) != 'invalid' AND toDateTime64(substring(s, 1, 19), 3) > '2020-01-01': the conversion was evaluated on the rows rejected by the earlier condition. Closes #132525.Description
On 26.10.2.103 (also 26.8, 26.3), a
file()read of Parquet withWHERE substring(s, 1, 19) != 'invaliddatetime' AND toDateTime64(substring(s, 1, 19), 3) > '2020-01-01'rejects valid input withCANNOT_PARSE_DATETIME. The same query on MergeTree, or withoptimize_move_to_prewhere = 0, returns the row.Root cause.
tryBuildPrewhereStepssplits the PREWHERE so that the guard filters beforetoDateTime64runs, and passes the sharedsubstring(s, 1, 19)from step 1 to step 2 by name. The Parquet reader passes columns between steps only through slots ofextended_sample_block, which has no slot for that intermediate, sopreparePrewheredropped the split and ran everything as one step, wheretoDateTime64sees every row.Change. Such an intermediate gets a hidden slot in
RowSubgroup::outputafter the columns ofextended_sample_block. The producing step writes it, later steps read it, and the existing per-step filtering and end-of-PREWHERE cleanup cover it. The splitter is unchanged; a generated name equal to a file column (04342) still falls back to one step.Tests. New
05828(WHERE, 3-step PREWHERE, row policy) fails on master and passes with the fix 50/50 under randomized settings. Allparquet/prewherestateless tests: no new failures.Price. Such queries now run the same steps as the twin without a shared expression. On a dictionary-encoded column the old single step could evaluate the whole condition once per dictionary value; measured on 2M rows (debug build): 24 ms before, 71 ms after, 64 ms for the twin on master. Plain-encoded: 82 ms before and after.
Workflow [PR]
Sync PR [sync-upstream/pr/132560]