Skip to content

[KYUUBI #3845][AUTHZ] CREATE OR REPLACE operation requires both CREATE and DROP table privileges - #7748

Open
attilapiros wants to merge 2 commits into
apache:masterfrom
attilapiros:3845
Open

attilapiros wants to merge 2 commits into
apache:masterfrom
attilapiros:3845

Conversation

@attilapiros

@attilapiros attilapiros commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Why are the changes needed?

CREATE OR REPLACE TABLE are authorized as pure creates today: the ReplaceTable / ReplaceTableAsSelect logical plans map only to CREATETABLE / CREATETABLE_AS_SELECT, which require just the CREATE privilege on the target table.

But these commands atomically drop and recreate the table - when the target already exists, its schema and all its data are destroyed. That means a user who was granted CREATE but deliberately not DROP on a table can still wipe it out with REPLACE TABLE, bypassing the very privilege an admin withheld to prevent destruction.

This PR makes REPLACE TABLE / CREATE OR REPLACE TABLE require both CREATE and DROP on the target table, so the privilege model reflects what the operation can actually do.

To express this:

  • AccessType.apply changed to return multiple access types and renamed to AccessType.getAccessTypes
  • introduced two new OperationTypes: REPLACETABLE and REPLACETABLE_AS_SELECT which mapped for both DROP and CREATE access types.

How was this patch tested?

The unit test was extended.

Was this patch assisted by generative AI tooling?

Assisted-by: Claude Opus 4.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant