You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by th...@apache.org on 2013/11/22 23:03:55 UTC

svn commit: r1544694 - /hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveAlterHandler.java

Author: thejas
Date: Fri Nov 22 22:03:54 2013
New Revision: 1544694

URL: http://svn.apache.org/r1544694
Log:
HIVE-3815 : hive table rename fails if filesystem cache is disabled (Thejas Nair reviewed by Navis)

Modified:
    hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveAlterHandler.java

Modified: hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveAlterHandler.java
URL: http://svn.apache.org/viewvc/hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveAlterHandler.java?rev=1544694&r1=1544693&r2=1544694&view=diff
==============================================================================
--- hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveAlterHandler.java (original)
+++ hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveAlterHandler.java Fri Nov 22 22:03:54 2013
@@ -156,7 +156,7 @@ public class HiveAlterHandler implements
         destPath = new Path(newTblLoc);
         destFs = wh.getFs(destPath);
         // check that src and dest are on the same file system
-        if (srcFs != destFs) {
+        if (! equalsFileSystem(srcFs, destFs)) {
           throw new InvalidOperationException("table new location " + destPath
               + " is on a different file system than the old location "
               + srcPath + ". This operation is not supported");
@@ -251,6 +251,21 @@ public class HiveAlterHandler implements
     }
   }
 
+  /**
+   * @param fs1
+   * @param fs2
+   * @return return true if both file system arguments point to same file system
+   */
+  private boolean equalsFileSystem(FileSystem fs1, FileSystem fs2) {
+    //When file system cache is disabled, you get different FileSystem objects
+    // for same file system, so '==' can't be used in such cases
+    //FileSystem api doesn't have a .equals() function implemented, so using
+    //the uri for comparison. FileSystem already uses uri+Configuration for
+    //equality in its CACHE .
+    //Once equality has been added in HDFS-4321, we should make use of it
+    return fs1.getUri().equals(fs2.getUri());
+  }
+
   public Partition alterPartition(final RawStore msdb, Warehouse wh, final String dbname,
       final String name, final List<String> part_vals, final Partition new_part)
       throws InvalidOperationException, InvalidObjectException, AlreadyExistsException,