Repository navigation
[spark][flink] Reject row-level operations and rewrites under query auth rules - #10906
Open
plusplusjiajia wants to merge 1 commit into
Open
plusplusjiajia wants to merge 1 commit into
plusplusjiajia wants to merge 1 commit into
Conversation
plusplusjiajia
force-pushed
the
fix/reject-rewrites-under-query-auth-rules
branch
7 times, most recently
from
November 3, 2026 01:59
958f7ed to
87e9164
Compare
plusplusjiajia
force-pushed
the
fix/reject-rewrites-under-query-auth-rules
branch
from
November 16, 2026 01:39
87e9164 to
7350806
Compare
plusplusjiajia
force-pushed
the
fix/reject-rewrites-under-query-auth-rules
branch
4 times, most recently
from
November 24, 2026 03:34
a1bf2bd to
496f9e8
Compare
plusplusjiajia
marked this pull request as ready for review
November 24, 2026 03:43
plusplusjiajia
force-pushed
the
fix/reject-rewrites-under-query-auth-rules
branch
4 times, most recently
from
November 30, 2026 06:40
80476e8 to
92e4c11
Compare
…uth rules On a table with query auth, operations that read rows and write them back used the caller's row filter and column masks: masked values were stored as real data, hidden rows were deleted or lost in overwrites, and insert-only merges inserted hidden keys again. These operations now fail when query auth gives the caller a row filter or a column mask; users with full access are not affected. This covers Spark UPDATE, DELETE, MERGE INTO (including insert-only merges), TRUNCATE TABLE [PARTITION] and CompactChainTableProcedure, and Flink SQL UPDATE, DELETE and TRUNCATE TABLE and the Delete, MergeInto, DataEvolutionMergeInto, SortCompact, Rescale and CompactChainTable actions. TableQueryAuthResult.rejectRewriteUnderQueryAuth checks when the operation is planned or the action is built, including the fallback branch, the row tracking table of a Data Evolution table and the branches of a chain table. Since a rule can still be added before the job reads the table, the rewrites also write through a copy of the target with an internal commit.rewrite-operation option, whose TableCommitImpl authorizes again before each commit and truncation. It authorizes the table it writes and the table loaded again from the catalog, so query auth enabled, or a branch read with the table, after the job loaded the table is also seen, such as the delta branch that chain table compaction reads and that may enable query auth separately. The copy keeps the schema of a target pinned to a snapshot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
plusplusjiajia
force-pushed
the
fix/reject-rewrites-under-query-auth-rules
branch
from
November 30, 2026 10:11
92e4c11 to
87b6253
Compare
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.
Purpose
On a table with query auth, operations that read rows and write them back used the caller's row filter and column masks: masked values were stored as real data, hidden rows were deleted or lost in overwrites, and insert-only merges inserted hidden keys again.
These operations now fail when query auth gives the caller a row filter or a column mask. Users with full access are not affected, as in PyPaimon.
UPDATE,DELETE,MERGE INTO(including insert-only merges, which Spark plans as appends),TRUNCATE TABLE [PARTITION]andCompactChainTableProcedure.UPDATE/DELETE, truncation, and theDelete,MergeInto,DataEvolutionMergeInto,SortCompact,RescaleandCompactChainTableactions.TableQueryAuthResult.rejectRewriteUnderQueryAuthchecks when the operation is planned or the action is built, and also covers the fallback branch, the row tracking table of a Data Evolution table and the branches of a chain table, which may enable query auth separately.A rule can still be added before the job reads the table, so the rewrites also write through
rejectRewriteUnderQueryAuthOnCommit: a copy of the table with an internalcommit.rewrite-operationoption, whoseTableCommitImplauthorizes again before each commit and truncation: the table it writes and the table loaded again from the catalog, as a read that loads the table again sees it. Query auth enabled, or a branch read with the table, after the job loaded the table is then also seen, such as the delta branch that chain table compaction reads. A rule that the read applied is then seen before anything is written, wherever the read is planned, also for an empty overwrite.Known limitation: Spark writes an insert-only merge as an append to the target, so it is checked only when planned. A rule added between analysis and scan planning of that query can insert hidden keys again. Truncation does not read, so a rule added after its check is not enforced but cannot affect what it writes. A rule added and removed again before the commit is not seen.
Tests
SparkCatalogWithRestTest,Spark42CompatibilityTest(Spark 4.2 and 4.3): Spark operations are refused under a row filter or a column mask on append, primary-key and Data Evolution tables, with V1 and V2 writes, also when a UDF adds the rule while the statement runs, and work with full access.RESTCatalogITCase: the Flink SQL operations (includingTRUNCATE TABLEon primary-key and Data Evolution tables) and actions above are refused, also when the rule is added after the action is built or while the job runs, or query auth is enabled after the merge is built, or leaves no split to overwrite; full access works with dynamic table options disabled.MockRESTCatalogTest#testRewriteCommitAuthorizesAgain: a rewrite commit and truncation fail when a rule is added after the write started.#testChainCompactionCommitAuthorizesDeltaBranch: the chain table compaction commit fails when only the delta branch enables query auth and a rule is added.TableQueryAuthResultTest.🤖 Generated with Claude Code