You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by br...@apache.org on 2014/04/05 21:55:42 UTC

svn commit: r1585197 - in /hive/trunk/ql/src/java/org/apache/hadoop/hive/ql: exec/MoveTask.java metadata/Hive.java

Author: brock
Date: Sat Apr  5 19:55:42 2014
New Revision: 1585197

URL: http://svn.apache.org/r1585197
Log:
HIVE-6792 - hive.warehouse.subdir.inherit.perms doesn't work correctly in CTAS (Chaoyu via Brock)

Modified:
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/MoveTask.java
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/MoveTask.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/MoveTask.java?rev=1585197&r1=1585196&r2=1585197&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/MoveTask.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/MoveTask.java Sat Apr  5 19:55:42 2014
@@ -40,6 +40,7 @@ import org.apache.hadoop.hive.ql.io.rcfi
 import org.apache.hadoop.hive.ql.lockmgr.HiveLock;
 import org.apache.hadoop.hive.ql.lockmgr.HiveLockManager;
 import org.apache.hadoop.hive.ql.lockmgr.HiveLockObj;
+import org.apache.hadoop.hive.ql.metadata.Hive;
 import org.apache.hadoop.hive.ql.metadata.HiveException;
 import org.apache.hadoop.hive.ql.metadata.Partition;
 import org.apache.hadoop.hive.ql.metadata.Table;
@@ -77,17 +78,15 @@ public class MoveTask extends Task<MoveW
       String mesg_detail = " from " + sourcePath.toString();
       console.printInfo(mesg, mesg_detail);
 
-      // delete the output directory if it already exists
-      fs.delete(targetPath, true);
       // if source exists, rename. Otherwise, create a empty directory
       if (fs.exists(sourcePath)) {
         Path deletePath = null;
         // If it multiple level of folder are there fs.rename is failing so first
         // create the targetpath.getParent() if it not exist
         if (HiveConf.getBoolVar(conf, HiveConf.ConfVars.HIVE_INSERT_INTO_MULTILEVEL_DIRS)) {
-        deletePath = createTargetPath(targetPath, fs);
+          deletePath = createTargetPath(targetPath, fs);
         }
-        if (!fs.rename(sourcePath, targetPath)) {
+        if (!Hive.renameFile(conf, sourcePath, targetPath, fs, true, false)) {
           try {
             if (deletePath != null) {
               fs.delete(deletePath, true);
@@ -146,6 +145,9 @@ public class MoveTask extends Task<MoveW
         actualPath = actualPath.getParent();
       }
       fs.mkdirs(mkDirPath);
+      if (HiveConf.getBoolVar(conf, HiveConf.ConfVars.HIVE_WAREHOUSE_SUBDIR_INHERIT_PERMS)) {
+        fs.setPermission(mkDirPath, fs.getFileStatus(actualPath).getPermission());
+      }
     }
     return deletePath;
   }

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java?rev=1585197&r1=1585196&r2=1585197&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java Sat Apr  5 19:55:42 2014
@@ -2210,7 +2210,7 @@ private void constructOneLBLocationMap(F
   //method is called. when the replace value is true, this method works a little different
   //from mv command if the destf is a directory, it replaces the destf instead of moving under
   //the destf. in this case, the replaced destf still preserves the original destf's permission
-  static protected boolean renameFile(HiveConf conf, Path srcf, Path destf,
+  public static boolean renameFile(HiveConf conf, Path srcf, Path destf,
       FileSystem fs, boolean replace, boolean isSrcLocal) throws HiveException {
     boolean success = false;
     boolean inheritPerms = HiveConf.getBoolVar(conf,