Repository navigation
Conversation
A read sent as a serialized query plan lost the row policy that the storage applies inside the read. The step now carries the filter (step version 1), and the server that executes the plan gives it to the storage.
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
|
Workflow [PR], commit [6096552] Summary: ✅
AI ReviewSummaryReviewed head Final VerdictStatus: ✅ Approve |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes8 object files changed (+31.37 KiB total), 0 added.
711 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units131 translation units recompiled, 1153 s compile time in total, 131 of them have a recent master baseline. |
# Conflicts: # src/Processors/QueryPlan/ReadFromTableStep.h
description
A read that the initiator sends as a serialized query plan (`serialize_query_plan = 1`) lost the row policy of a `MergeTree` table. The planner gives such a policy to the storage as `row_level_filter`, and the `ReadFromTableStep` placeholder did not carry it. The server that executes the plan built the read without the filter and returned all rows.Example: a policy
USING y < 5on a 10-row table, read through aDistributedtable withprefer_localhost_replica = 0.SELECT count()returned 10 withserialize_query_plan = 1and 5 withserialize_query_plan = 0. With parallel replicas, a policy on the first sorting key column andORDER BYon the second gave the exceptionCoordination mode mismatch ...: got Default, expected WithOrder.The fix:
ReadFromTableStepcarries the filter (step version 1, written since plan version 21). The server that executes the plan gives the filter to the storage, which applies it in PREWHERE as for a local read, soFINALandapply_row_policy_after_finalwork the same in both modes. If the table on that server cannot apply the filter inside the read, the query fails withILLEGAL_PREWHERE.The policy in the plan is the policy that the initiator resolves. The executing server does not add its own, so the policy must be the same on all servers. The docs say this now.
This is a small alternative to #114955 and completes the approach of #107745, which failed with
THERE_IS_NO_COLUMNbecause the step header still contained the columns that the filter removes.Closes: #112891
Related: #114955
Related: #107745
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix a
SELECTrow policy on aMergeTreetable being ignored when the read is sent to another server as a serialized query plan (serialize_query_plan = 1): reads through aDistributedtable withprefer_localhost_replica = 0returned rows that the policy excludes.Workflow [PR]
Sync PR [sync-upstream/pr/131123]