Author: brock
Date: Tue Dec 16 17:16:00 2014
New Revision: 1646012

URL: http://svn.apache.org/r1646012
Log:
HIVE-9087 - The move task does not handle properly in the case of loading data 
from the local file system path. (Ferdinand Xu via Brock)

Modified:
    
hive/branches/HIVE-8065/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java

Modified: 
hive/branches/HIVE-8065/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
URL: 
http://svn.apache.org/viewvc/hive/branches/HIVE-8065/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java?rev=1646012&r1=1646011&r2=1646012&view=diff
==============================================================================
--- 
hive/branches/HIVE-8065/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
 (original)
+++ 
hive/branches/HIVE-8065/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
 Tue Dec 16 17:16:00 2014
@@ -29,6 +29,7 @@ import static org.apache.hadoop.hive.ser
 
 import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.net.URI;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
@@ -2148,7 +2149,7 @@ private void constructOneLBLocationMap(F
       boolean grantOption) throws HiveException {
     try {
       return getMSC().grant_role(roleName, userName, principalType, grantor,
-          grantorType, grantOption);
+        grantorType, grantOption);
     } catch (Exception e) {
       throw new HiveException(e);
     }
@@ -2317,6 +2318,19 @@ private void constructOneLBLocationMap(F
     return false;
   }
 
+  private static boolean isSubDir(Path srcf, Path destf, FileSystem fs){
+    if (srcf == null) {
+      return false;
+    }
+    URI srcfUri = srcf.toUri();
+    // If the source file is in the file schema, it can not be the 
subdirectory of a HDFS path
+    if (srcfUri != null && srcfUri.isAbsolute() && 
!srcfUri.getScheme().equals("hdfs")) {
+      return false;
+    } else {
+      return FileUtils.isSubDir(srcf, destf, fs);
+    }
+  }
+
   //it is assumed that parent directory of the destf should already exist when 
this
   //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
@@ -2338,7 +2352,7 @@ private void constructOneLBLocationMap(F
     // (1) Do not delete the dest dir before doing the move operation.
     // (2) It is assumed that subdir and dir are in same encryption zone.
     // (3) Move individual files from scr dir to dest dir.
-    boolean destIsSubDir = FileUtils.isSubDir(srcf, destf, fs);
+    boolean destIsSubDir = isSubDir(srcf, destf, fs);
     try {
       if (inheritPerms || replace) {
         try{


Reply via email to