maheshk114 commented on a change in pull request #588: HIVE-20968 : Support conversion of managed to external where location set was not owned by hive URL: https://github.com/apache/hive/pull/588#discussion_r273443108
########## File path: ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/TableExport.java ########## @@ -84,6 +84,34 @@ public TableExport(Paths paths, TableSpec tableSpec, ReplicationSpec replication this.conf = conf; this.paths = paths; this.mmCtx = mmCtx; + this.replicationSpec.setEventBasedOwnershipCheck(false); + setPathOwnedByHive(this.replicationSpec, tableSpec.tableHandle.getDataLocation(), db.getConf()); + } + + public static void setPathOwnedByHive(ReplicationSpec replicationSpec, Path location, HiveConf conf) { + // For incremental load path, this flag should be set using the owner name in the event. + if (replicationSpec == null || !replicationSpec.isInReplicationScope() || + replicationSpec.isEventBasedOwnershipCheck()) { + return; + } + + // If the table path or path of any of the partitions is not owned by hive, + // then table location not owned by hive for whole table. + if (!replicationSpec.isPathOwnedByHive()) { + logger.info("Path is not owned by hive user for table or some partition. No need to check further."); + return; + } + + try { + FileStatus fileStatus = location.getFileSystem(conf).getFileStatus(location); + String hiveOwner = conf.get(HiveConf.ConfVars.STRICT_MANAGED_TABLES_MIGRARTION_OWNER.varname, "hive"); + replicationSpec.setPathOwnedByHive(hiveOwner.equals(fileStatus.getOwner())); Review comment: The same way its used in migration tool ..so kept it same ---------------------------------------------------------------- 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 With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org