Repository navigation
Conversation
Contributor
|
Workflow [PR], commit [e06adcd] Summary: ❌
AI ReviewSummaryThis PR fixes row-policy handling when a Final VerdictStatus: ✅ Approve |
yariks5s
marked this pull request as draft
April 15, 2026 22:17
…b.com/ClickHouse/ClickHouse into yarik/fix-row-policies-in-merge-table
yariks5s
marked this pull request as ready for review
April 17, 2026 15:49
Contributor
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 58/70 (82.86%) | Lost baseline coverage (was covered on master, now uncovered in this PR): 13 line(s) · Uncovered code |
nihalzp
pushed a commit
to nihalzp/ClickHouse
that referenced
this pull request
Nov 4, 2026
… PREWHERE and WHERE `ReadFromMerge` applied the row policy of a local child as a `FilterStep` above the child's read. The query's PREWHERE is forwarded into that read, and the query's WHERE is pushed below the Merge, merged with the policy filter by the child plan's optimization and moved into the read's PREWHERE as one unordered conjunction. Either way the query's condition was evaluated on the rows the policy hides: a condition that throws on a value (`toUInt64(payload) > 10`, `throwIf`) printed hidden values and works as an oracle over hidden rows. A direct read of the same table is not affected, because the planner gives the read the policy as `SelectQueryInfo::row_level_filter`, which the reads evaluate as a separate step before every PREWHERE step. ClickHouse#125765 fixed the children that process the query themselves; a local child read at `FetchColumns` still got the late filter. Now the child's read gets the policy as its row-level filter whenever the planner's own push-down rule says the storage can evaluate it there, and the late `FilterStep` is not planted: - The rule (`supportsPrewhere`, not remote, every column inside the PREWHERE contract) was written out twice, in the planner and in the old interpreter. It is now `canPushDownRowPolicyFilter`, used by both and by `Merge`. - `RowPolicyData::makeRowLevelFilter` returns the policy as a `FilterDAGInfo`, or nothing when the rule fails or a column is not physical. When the Merge table has a policy of its own (forwarded to every child as `row_level_filter`), both are AND-ed into one filter that keeps every input column, as ClickHouse#102860 proposes; this also removes the `NOT_FOUND_COLUMN_IN_BLOCK` of ClickHouse#102650. - The policy's IN-subquery sets are still built by a step above the read (`addCreatingSetsStep`); a Buffer child's in-memory read needs it. - `ALIAS` columns in the policy are expanded before analysis, since a read cannot produce them. When the read cannot evaluate the policy (e.g. a `Memory` child's policy over a `DEFAULT` column) the previous path is kept. A direct read of such a table keeps the policy as a WHERE filter and orders it the same way; that is the planner's behaviour and is not changed here. Behaviour changes, both matching a direct read: a Merge child's plan shows a `Row level filter` instead of a `Filter` step, and `apply_row_policy_after_final = 0` now applies a Merge child's policy before FINAL. Test: 05453_merge_child_row_policy_before_prewhere, eight arms (MergeTree PREWHERE and WHERE, Memory, FINAL, IN subquery over Buffer, ALIAS, policies on both tables, nested Merge) plus a control showing the condition throws on the hidden value while it is visible. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixes NOT_FOUND_COLUMN_IN_BLOCK exception while applying row policies on the same column with the Merge table and the child table. Closes #102650
Documentation entry for user-facing changes