-
Couldn't load subscription status.
- Fork 4.8k
HIVE-29215: Fix owner info for view in authorizable events for alter … #6087
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
saihemanth-cloudera
merged 3 commits into
apache:master
from
saihemanth-cloudera:HIVE-29215
Oct 13, 2025
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
24 changes: 24 additions & 0 deletions
24
ql/src/test/queries/clientnegative/authorization_alter_view.q
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| --! qt:authorizer | ||
| set hive.test.authz.sstd.hs2.mode=true; | ||
| set hive.security.authorization.manager=org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactoryForTest; | ||
| set hive.security.authenticator.manager=org.apache.hadoop.hive.ql.security.SessionStateConfigUserAuthenticator; | ||
|
|
||
| -- create db1, tab1, view1 as hive_admin_user | ||
| set user.name=hive_admin_user; | ||
| set role ADMIN; | ||
|
|
||
| create database db1; | ||
| create table db1.tab1(i int); | ||
| create view db1.view1 as select * from db1.tab1; | ||
|
|
||
| -- grant select privileges on db1 and view1 | ||
| GRANT select ON DATABASE db1 TO USER user2; | ||
| GRANT select ON TABLE db1.view1 to USER user2; | ||
|
|
||
| -- create db2, tab2 as user2 | ||
| set user.name=user2; | ||
| create database db2; | ||
| create table db2.tab2(i int); | ||
|
|
||
| -- try to alter view1 as user2 and it should fail as user2 doesn't have required privilege | ||
| alter view db1.view1 as select * from db2.tab2 |
54 changes: 54 additions & 0 deletions
54
ql/src/test/results/clientnegative/authorization_alter_view.q.out
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| PREHOOK: query: set role ADMIN | ||
| PREHOOK: type: SHOW_ROLES | ||
| POSTHOOK: query: set role ADMIN | ||
| POSTHOOK: type: SHOW_ROLES | ||
| PREHOOK: query: create database db1 | ||
| PREHOOK: type: CREATEDATABASE | ||
| PREHOOK: Output: database:db1 | ||
| POSTHOOK: query: create database db1 | ||
| POSTHOOK: type: CREATEDATABASE | ||
| POSTHOOK: Output: database:db1 | ||
| PREHOOK: query: create table db1.tab1(i int) | ||
| PREHOOK: type: CREATETABLE | ||
| PREHOOK: Output: database:db1 | ||
| PREHOOK: Output: db1@tab1 | ||
| POSTHOOK: query: create table db1.tab1(i int) | ||
| POSTHOOK: type: CREATETABLE | ||
| POSTHOOK: Output: database:db1 | ||
| POSTHOOK: Output: db1@tab1 | ||
| PREHOOK: query: create view db1.view1 as select * from db1.tab1 | ||
| PREHOOK: type: CREATEVIEW | ||
| PREHOOK: Input: db1@tab1 | ||
| PREHOOK: Output: database:db1 | ||
| PREHOOK: Output: db1@view1 | ||
| POSTHOOK: query: create view db1.view1 as select * from db1.tab1 | ||
| POSTHOOK: type: CREATEVIEW | ||
| POSTHOOK: Input: db1@tab1 | ||
| POSTHOOK: Output: database:db1 | ||
| POSTHOOK: Output: db1@view1 | ||
| POSTHOOK: Lineage: view1.i SIMPLE [(tab1)tab1.FieldSchema(name:i, type:int, comment:null), ] | ||
| PREHOOK: query: GRANT select ON DATABASE db1 TO USER user2 | ||
| PREHOOK: type: GRANT_PRIVILEGE | ||
| POSTHOOK: query: GRANT select ON DATABASE db1 TO USER user2 | ||
| POSTHOOK: type: GRANT_PRIVILEGE | ||
| PREHOOK: query: GRANT select ON TABLE db1.view1 to USER user2 | ||
| PREHOOK: type: GRANT_PRIVILEGE | ||
| PREHOOK: Output: db1@view1 | ||
| POSTHOOK: query: GRANT select ON TABLE db1.view1 to USER user2 | ||
| POSTHOOK: type: GRANT_PRIVILEGE | ||
| POSTHOOK: Output: db1@view1 | ||
| PREHOOK: query: create database db2 | ||
| PREHOOK: type: CREATEDATABASE | ||
| PREHOOK: Output: database:db2 | ||
| POSTHOOK: query: create database db2 | ||
| POSTHOOK: type: CREATEDATABASE | ||
| POSTHOOK: Output: database:db2 | ||
| PREHOOK: query: create table db2.tab2(i int) | ||
| PREHOOK: type: CREATETABLE | ||
| PREHOOK: Output: database:db2 | ||
| PREHOOK: Output: db2@tab2 | ||
| POSTHOOK: query: create table db2.tab2(i int) | ||
| POSTHOOK: type: CREATETABLE | ||
| POSTHOOK: Output: database:db2 | ||
| POSTHOOK: Output: db2@tab2 | ||
| FAILED: HiveAccessControlException Permission denied: Principal [name=user2, type=USER] does not have following privileges for operation ALTERVIEW_AS [[OBJECT OWNERSHIP] on Object [type=DATABASE, name=db1], [OBJECT OWNERSHIP] on Object [type=TABLE_OR_VIEW, name=db1.view1]] |
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
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get it, before this fix
DDLUtils.addDbAndTableToOutputswill create a dummy table based onviewName, it has the samedbandtablewith theoldView, why it doesn't work before?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The viewName has type TableName, which has dbname and table name. So the HivePrivilegeObject will be constructed with the current user as the owner of the view. This is incorrect behavior.