deniskuzZ commented on code in PR #6267:
URL: https://github.com/apache/hive/pull/6267#discussion_r3068045324


##########
ql/src/java/org/apache/hadoop/hive/ql/parse/EximUtil.java:
##########
@@ -388,14 +389,34 @@ public static void createDbExportDump(FileSystem fs, Path 
metadataPath, Database
 
   private static void updateIfCustomDbLocations(Database database, 
Configuration conf) throws SemanticException {
     try {
-      String whLocatoion = MetastoreConf.getVar(conf, 
MetastoreConf.ConfVars.WAREHOUSE_EXTERNAL,
-              MetastoreConf.getVar(conf, MetastoreConf.ConfVars.WAREHOUSE));
-      Path dbDerivedLoc = new Path(whLocatoion, 
database.getName().toLowerCase() + DATABASE_PATH_SUFFIX);
+      String catName = database.getCatalogName();
+      String dbName = database.getName().toLowerCase();
+      boolean isDefaultCatalog = 
Warehouse.DEFAULT_CATALOG_NAME.equals(catName);
+
+      // external warehouse root
+      String whLocation = MetastoreConf.getVar(conf,
+              isDefaultCatalog ? MetastoreConf.ConfVars.WAREHOUSE_EXTERNAL : 
MetastoreConf.ConfVars.WAREHOUSE_CATALOG_EXTERNAL,
+              MetastoreConf.getVar(conf,
+                      isDefaultCatalog ? MetastoreConf.ConfVars.WAREHOUSE : 
MetastoreConf.ConfVars.WAREHOUSE_CATALOG));
+
+      if (!isDefaultCatalog) {
+        whLocation = new Path(whLocation, catName).toString();
+      }
+
+      Path dbDerivedLoc = new Path(whLocation, dbName + DATABASE_PATH_SUFFIX);
       String defaultDbLoc = Utilities.getQualifiedPath((HiveConf) conf, 
dbDerivedLoc);
       database.putToParameters(ReplConst.REPL_IS_CUSTOM_DB_LOC,
               
Boolean.toString(!defaultDbLoc.equals(database.getLocationUri())));
-      String whManagedLocatoion = MetastoreConf.getVar(conf, 
MetastoreConf.ConfVars.WAREHOUSE);
-      Path dbDerivedManagedLoc = new Path(whManagedLocatoion, 
database.getName().toLowerCase()
+
+      // managed warehouse root
+      String whManagedLocatoion = MetastoreConf.getVar(conf,
+              isDefaultCatalog ? MetastoreConf.ConfVars.WAREHOUSE

Review Comment:
   please see https://github.com/apache/hive/pull/6267#discussion_r3068019699



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to