Skip to content

Commit

Permalink
Allow hive table owner to change ownership
Browse files Browse the repository at this point in the history
  • Loading branch information
guyco33 committed Oct 28, 2024
1 parent d0bab0f commit a2a8dd5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public void checkCanAlterColumn(ConnectorSecurityContext context, SchemaTableNam
@Override
public void checkCanSetTableAuthorization(ConnectorSecurityContext context, SchemaTableName tableName, TrinoPrincipal principal)
{
if (!isAdmin(context)) {
if (!isTableOwner(context, tableName)) {
denySetTableAuthorization(tableName.toString(), principal);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -945,11 +945,7 @@ public void testTableAuthorization()
"ALTER TABLE test_table_authorization.foo SET AUTHORIZATION alice",
"Cannot set authorization for table test_table_authorization.foo to USER alice");
assertUpdate(admin, "ALTER TABLE test_table_authorization.foo SET AUTHORIZATION alice");
// only admin can change the owner
assertAccessDenied(
alice,
"ALTER TABLE test_table_authorization.foo SET AUTHORIZATION alice",
"Cannot set authorization for table test_table_authorization.foo to USER alice");
assertUpdate(alice, "ALTER TABLE test_table_authorization.foo SET AUTHORIZATION alice");
// alice as new owner can now drop table
assertUpdate(alice, "DROP TABLE test_table_authorization.foo");

Expand Down Expand Up @@ -982,11 +978,10 @@ public void testTableAuthorizationForRole()
"DROP TABLE test_table_authorization_role.foo",
"Cannot drop table test_table_authorization_role.foo");
assertUpdate(admin, "ALTER TABLE test_table_authorization_role.foo SET AUTHORIZATION alice");
// Only admin can change the owner
assertAccessDenied(
assertQueryFails(
alice,
"ALTER TABLE test_table_authorization_role.foo SET AUTHORIZATION ROLE admin",
"Cannot set authorization for table test_table_authorization_role.foo to ROLE admin");
"Setting table owner type as a role is not supported");
// new owner can drop table
assertUpdate(alice, "DROP TABLE test_table_authorization_role.foo");
assertUpdate(admin, "DROP SCHEMA test_table_authorization_role");
Expand Down

0 comments on commit a2a8dd5

Please sign in to comment.