[ https://issues.apache.org/jira/browse/HIVE-21654?focusedWorklogId=234331&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-234331 ]
ASF GitHub Bot logged work on HIVE-21654: ----------------------------------------- Author: ASF GitHub Bot Created on: 29/Apr/19 06:32 Start Date: 29/Apr/19 06:32 Worklog Time Spent: 10m Work Description: maheshk114 commented on 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: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 234331) Time Spent: 20m (was: 10m) > External table location is not preserved at target when base dir is set as /. > ----------------------------------------------------------------------------- > > Key: HIVE-21654 > URL: https://issues.apache.org/jira/browse/HIVE-21654 > Project: Hive > Issue Type: Bug > Components: repl > Affects Versions: 4.0.0 > Reporter: Sankar Hariappan > Assignee: Sankar Hariappan > Priority: Major > Labels: DR, pull-request-available, replication > Attachments: HIVE-21654.01.patch, HIVE-21654.02.patch > > Time Spent: 20m > Remaining Estimate: 0h > > External table location is not preserved same as source path when base > directory is set as "/". > Source path: /tmp/ext/src/db1/ext1 > Target path: /ext/src/db1/ext1 --> It should be /tmp/ext/src/db1/ext1 itself. > External table base dir supplied: / > If the base dir input is changed to "/abc", then target path is set as > "/abc/tmp/ext/src/db1/ext1 which is correct. -- This message was sent by Atlassian JIRA (v7.6.3#76005)