saihemanth-cloudera commented on code in PR #3599:
URL: https://github.com/apache/hive/pull/3599#discussion_r1669448259


##########
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java:
##########
@@ -1343,7 +1381,48 @@ public void createDatabase(Database db)
     if (!db.isSetCatalogName()) {
       db.setCatalogName(getDefaultCatalog(conf));
     }
-    client.create_database(db);
+    if (db.getName() == null) {
+      throw new MetaException("DbName cannot be null");
+    }
+    CreateDatabaseRequest req = new CreateDatabaseRequest(db.getName());
+    if (db.isSetDescription()) {
+      req.setDescription(db.getDescription());
+    }
+    if (db.isSetLocationUri()) {
+      req.setLocationUri(db.getLocationUri());
+    }
+    if (db.isSetParameters()) {
+      req.setParameters(db.getParameters());
+    }
+    if (db.isSetPrivileges()) {
+      req.setPrivileges(db.getPrivileges());
+    }
+    if (db.isSetOwnerName()) {
+      req.setOwnerName(db.getOwnerName());
+    }
+    if (db.isSetOwnerType()) {
+      req.setOwnerType(db.getOwnerType());
+    }
+    req.setCatalogName(db.getCatalogName());
+    if (db.isSetCreateTime()) {
+      req.setCreateTime(db.getCreateTime());
+    }
+    if (db.isSetManagedLocationUri()) {
+      req.setManagedLocationUri(db.getManagedLocationUri());
+    }
+    if (db.isSetType()) {
+      req.setType(db.getType());
+    }
+    if (db.isSetConnector_name()) {
+      req.setDataConnectorName(db.getConnector_name());
+    }
+    if (db.isSetRemote_dbname()) {
+      req.setRemote_dbname(db.getRemote_dbname());
+    }
+    client.create_database_req(req);
+    //location and manged location might be set/changed.
+    db.setLocationUri(req.getLocationUri());
+    db.setManagedLocationUri(req.getManagedLocationUri());

Review Comment:
   No, the Metastore default transformer creates the location/managedLocation 
if not set on the db object, so we set it here so that the client can use this 
location for further processing. If we create a new database object then it 
totally defeats this purpose.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org
For additional commands, e-mail: gitbox-h...@hive.apache.org

Reply via email to