You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by su...@apache.org on 2017/05/02 22:56:06 UTC
hive git commit: HIVE-16563: Alter table partition set location
should use fully qualified path for non-default FS (Chao Sun,
reviewed by Xuefu Zhang)
Repository: hive
Updated Branches:
refs/heads/master 1af980242 -> 40b70eb18
HIVE-16563: Alter table partition set location should use fully qualified path for non-default FS (Chao Sun, reviewed by Xuefu Zhang)
Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/40b70eb1
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/40b70eb1
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/40b70eb1
Branch: refs/heads/master
Commit: 40b70eb18172b593d4184254190fe89990d8ffc5
Parents: 1af9802
Author: Chao Sun <su...@apache.org>
Authored: Mon May 1 13:16:11 2017 -0700
Committer: Chao Sun <su...@apache.org>
Committed: Tue May 2 15:55:37 2017 -0700
----------------------------------------------------------------------
...estDDLWithRemoteMetastoreSecondNamenode.java | 31 ++++++++++++++++++++
.../apache/hadoop/hive/ql/metadata/Hive.java | 10 +++++++
2 files changed, 41 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hive/blob/40b70eb1/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestDDLWithRemoteMetastoreSecondNamenode.java
----------------------------------------------------------------------
diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestDDLWithRemoteMetastoreSecondNamenode.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestDDLWithRemoteMetastoreSecondNamenode.java
index bfb25aa..ce8fe60 100644
--- a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestDDLWithRemoteMetastoreSecondNamenode.java
+++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestDDLWithRemoteMetastoreSecondNamenode.java
@@ -52,6 +52,7 @@ public class TestDDLWithRemoteMetastoreSecondNamenode extends TestCase {
private static final String Table4Name = "table4_nondefault_nn";
private static final String Table5Name = "table5_nondefault_nn";
private static final String Table6Name = "table6_nondefault_nn";
+ private static final String Table7Name = "table7_nondefault_nn";
private static final String Index1Name = "index1_table1_nondefault_nn";
private static final String Index2Name = "index2_table1_nondefault_nn";
private static final String tmpdir = System.getProperty("test.tmp.dir");
@@ -197,6 +198,27 @@ public class TestDDLWithRemoteMetastoreSecondNamenode extends TestCase {
}
}
+ private void alterPartitionAndCheck(Table table, String column,
+ String value, String location) throws CommandNeedRetryException, HiveException {
+ assertNotNull(location);
+ executeQuery("ALTER TABLE " + table.getTableName() +
+ " PARTITION (" + column + "='" + value + "')" +
+ " SET LOCATION '" + location + "'");
+ HashMap<String, String> partitions = new HashMap<String, String>();
+ partitions.put(column, value);
+ Partition partition = db.getPartition(table, partitions, false);
+ assertNotNull("Partition object is expected for " + table.getTableName() , partition);
+ String locationActual = partition.getLocation();
+ if (new Path(location).toUri().getScheme() != null) {
+ assertEquals("Partition should be located in the first filesystem",
+ fs.makeQualified(new Path(location)).toString(), locationActual);
+ }
+ else {
+ assertEquals("Partition should be located in the second filesystem",
+ fs2.makeQualified(new Path(location)).toString(), locationActual);
+ }
+ }
+
private Table createTableAndCheck(String tableName, String tableLocation)
throws CommandNeedRetryException, HiveException, URISyntaxException {
return createTableAndCheck(null, tableName, tableLocation);
@@ -294,6 +316,15 @@ public class TestDDLWithRemoteMetastoreSecondNamenode extends TestCase {
createTableAndCheck(table1, Table6Name, null);
}
+ public void testAlterPartitionSetLocationNonDefaultNameNode() throws Exception {
+ assertTrue("Test suite should have been initialized", isInitialized);
+ String tableLocation = tmppathFs2 + "/" + "test_set_part_loc";
+ Table table = createTableAndCheck(Table7Name, tableLocation);
+
+ addPartitionAndCheck(table, "p", "p1", "/tmp/test/1");
+ alterPartitionAndCheck(table, "p", "p1", "/tmp/test/2");
+ }
+
public void testCreateDatabaseWithTableNonDefaultNameNode() throws Exception {
assertTrue("Test suite should be initialied", isInitialized );
final String tableLocation = tmppathFs2 + "/" + Table3Name;
http://git-wip-us.apache.org/repos/asf/hive/blob/40b70eb1/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java b/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
index dec73a7..5b49dfd 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
@@ -690,6 +690,11 @@ public class Hive {
throws InvalidOperationException, HiveException {
try {
validatePartition(newPart);
+ String location = newPart.getLocation();
+ if (location != null && !Utilities.isDefaultNameNode(conf)) {
+ location = Utilities.getQualifiedPath(conf, new Path(location));
+ newPart.setLocation(location);
+ }
getMSC().alter_partition(dbName, tblName, newPart.getTPartition(), environmentContext);
} catch (MetaException e) {
@@ -729,6 +734,11 @@ public class Hive {
if (tmpPart.getParameters() != null) {
tmpPart.getParameters().remove(hive_metastoreConstants.DDL_TIME);
}
+ String location = tmpPart.getLocation();
+ if (location != null && !Utilities.isDefaultNameNode(conf)) {
+ location = Utilities.getQualifiedPath(conf, new Path(location));
+ tmpPart.setLocation(location);
+ }
newTParts.add(tmpPart.getTPartition());
}
getMSC().alter_partitions(names[0], names[1], newTParts, environmentContext);