maheshk114 commented on a change in pull request #610: HIVE-21654: External 
table location is not preserved at target when base dir is set as /.
URL: https://github.com/apache/hive/pull/610#discussion_r279246655
 
 

 ##########
 File path: 
ql/src/java/org/apache/hadoop/hive/ql/exec/repl/ReplExternalTables.java
 ##########
 @@ -66,18 +66,31 @@ public static String externalTableLocation(HiveConf 
hiveConf, String location) t
     String baseDir = 
hiveConf.get(HiveConf.ConfVars.REPL_EXTERNAL_TABLE_BASE_DIR.varname);
     Path basePath = new Path(baseDir);
     Path currentPath = new Path(location);
-    String targetPathWithoutSchemeAndAuth = basePath.toUri().getPath() + 
currentPath.toUri().getPath();
-    Path dataLocation;
+    Path dataLocation = externalTableDataPath(hiveConf, basePath, currentPath);
+
+    LOG.info("Incoming external table location: {} , new location: {}", 
location, dataLocation.toString());
+    return dataLocation.toString();
+  }
+
+  public static Path externalTableDataPath(HiveConf hiveConf, Path basePath, 
Path sourcePath)
+          throws SemanticException {
+    String baseUriPath = basePath.toUri().getPath();
+    String sourceUriPath = sourcePath.toUri().getPath();
+
+    // "/" is input for base directory, then we should use exact same path as 
source or else append
+    // source path under the base directory.
+    String targetPathWithoutSchemeAndAuth
+            = "/".equalsIgnoreCase(baseUriPath) ? sourceUriPath : (baseUriPath 
+ sourceUriPath);
 
 Review comment:
   equalsIgnoreCase is not required here

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to