Skip to content

Commit

Permalink
HIVE-28716: Add owner information in HivePrivilegeObject for create d…
Browse files Browse the repository at this point in the history
…atabase query (#5616) (Raghav Aggarwal reviewed by Zsolt Miskolczi, Shohei Okumiya)
  • Loading branch information
Aggarwal-Raghav authored Jan 28, 2025
1 parent 36608b4 commit 544c8b3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.hadoop.hive.metastore.api.DataConnector;
import org.apache.hadoop.hive.metastore.api.Database;
import org.apache.hadoop.hive.metastore.api.DatabaseType;
import org.apache.hadoop.hive.metastore.api.PrincipalType;
import org.apache.hadoop.hive.ql.QueryState;
import org.apache.hadoop.hive.ql.exec.TaskFactory;
import org.apache.hadoop.hive.ql.ddl.DDLSemanticAnalyzerFactory.DDLType;
Expand All @@ -33,6 +34,7 @@
import org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer;
import org.apache.hadoop.hive.ql.parse.HiveParser;
import org.apache.hadoop.hive.ql.parse.SemanticException;
import org.apache.hadoop.hive.ql.session.SessionState;

/**
* Analyzer for database creation commands.
Expand Down Expand Up @@ -113,6 +115,8 @@ public void analyzeInternal(ASTNode root) throws SemanticException {
database.setType(DatabaseType.REMOTE);
database.setRemote_dbname(remoteDbName);
}
database.setOwnerName(SessionState.getUserFromAuthenticator());
database.setOwnerType(PrincipalType.USER);
rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(), desc)));
outputs.add(new WriteEntity(database, WriteEntity.WriteType.DDL_NO_LOCK));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
outputHObjs:
HIVE PRIVILEGE OBJECT { type: DATABASE actionType: OTHER dbName: test_auth_obj_db}
HIVE PRIVILEGE OBJECT { type: DATABASE actionType: OTHER dbName: test_auth_obj_db OWNER: testuser OWNERTYPE: USER}
PREHOOK: query: CREATE DATABASE test_auth_obj_db
PREHOOK: type: CREATEDATABASE
PREHOOK: Output: database:test_auth_obj_db
Expand Down

0 comments on commit 544c8b3

Please sign in to comment.