diff --git metastore/src/java/org/apache/hadoop/hive/metastore/HiveAlterHandler.java metastore/src/java/org/apache/hadoop/hive/metastore/HiveAlterHandler.java index 88288ed..c7fb20d 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/HiveAlterHandler.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/HiveAlterHandler.java @@ -141,7 +141,7 @@ public void alterTable(RawStore msdb, Warehouse wh, String dbname, 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"); @@ -237,6 +237,21 @@ public void alterTable(RawStore msdb, Warehouse wh, String dbname, } } + /** + * @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 part_vals, final Partition new_part) throws InvalidOperationException, InvalidObjectException, AlreadyExistsException,