Repository: hive
Updated Branches:
  refs/heads/master 02d359db2 -> 1c2e999c7


HIVE-17428 : REPL LOAD of ALTER_PARTITION event doesn't create import tasks if 
the partition doesn't exist during analyze phase (Sankar Hariappan, reviewed by 
Anishek Agarwal, Thejas Nair)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/1c2e999c
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/1c2e999c
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/1c2e999c

Branch: refs/heads/master
Commit: 1c2e999c79440d8b596235829de8fb6a185bd3cc
Parents: 02d359d
Author: Sankar Hariappan <mailtosank...@gmail.com>
Authored: Wed Sep 20 09:29:58 2017 -0700
Committer: Thejas M Nair <the...@hortonworks.com>
Committed: Wed Sep 20 12:07:48 2017 -0700

----------------------------------------------------------------------
 .../hive/ql/parse/TestReplicationScenarios.java | 57 +-------------------
 .../java/org/apache/hadoop/hive/ql/Driver.java  | 23 ++++++--
 .../hive/ql/parse/ImportSemanticAnalyzer.java   | 15 +++++-
 .../ql/parse/ReplicationSemanticAnalyzer.java   |  3 +-
 4 files changed, 35 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/1c2e999c/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenarios.java
----------------------------------------------------------------------
diff --git 
a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenarios.java
 
b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenarios.java
index 2e880c7..d87a4c0 100644
--- 
a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenarios.java
+++ 
b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenarios.java
@@ -234,8 +234,6 @@ public class TestReplicationScenarios {
   }
 
   private void loadAndVerify(String replDbName, String dumpLocation, String 
lastReplId) throws IOException {
-    run("EXPLAIN REPL LOAD " + replDbName + " FROM '" + dumpLocation + "'", 
driverMirror);
-    printOutput(driverMirror);
     run("REPL LOAD " + replDbName + " FROM '" + dumpLocation + "'", 
driverMirror);
     verifyRun("REPL STATUS " + replDbName, lastReplId, driverMirror);
     return;
@@ -336,8 +334,6 @@ public class TestReplicationScenarios {
     // Partition droppped after "repl dump"
     run("ALTER TABLE " + dbName + ".ptned " + "DROP PARTITION(b=1)", driver);
 
-    run("EXPLAIN REPL LOAD " + dbName + "_dupe FROM '" + replDumpLocn + "'", 
driverMirror);
-    printOutput(driverMirror);
     run("REPL LOAD " + dbName + "_dupe FROM '" + replDumpLocn + "'", 
driverMirror);
 
     run("REPL STATUS " + dbName + "_dupe", driverMirror);
@@ -750,8 +746,6 @@ public class TestReplicationScenarios {
     String incrementalDumpLocn = getResult(0,0,driver);
     String incrementalDumpId = getResult(0,1,true,driver);
     LOG.info("Dumped to {} with id {}", incrementalDumpLocn, 
incrementalDumpId);
-    run("EXPLAIN REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + 
"'", driverMirror);
-    printOutput(driverMirror);
     run("REPL LOAD " + dbName + "_dupe FROM '"+incrementalDumpLocn+"'", 
driverMirror);
 
     run("REPL STATUS " + dbName + "_dupe", driverMirror);
@@ -876,8 +870,6 @@ public class TestReplicationScenarios {
     String incrementalDumpLocn = getResult(0, 0, driver);
     String incrementalDumpId = getResult(0, 1, true, driver);
     LOG.info("Incremental-Dump: Dumped to {} with id {} from {}", 
incrementalDumpLocn, incrementalDumpId, replDumpId);
-    run("EXPLAIN REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + 
"'", driverMirror);
-    printOutput(driverMirror);
     run("REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + "'", 
driverMirror);
     verifyRun("SELECT a from " + dbName + "_dupe.unptned ORDER BY a", 
unptn_data, driverMirror);
   }
@@ -927,8 +919,6 @@ public class TestReplicationScenarios {
     run("REPL DUMP " + dbName, driver);
     String replDumpLocn = getResult(0,0,driver);
     String replDumpId = getResult(0,1,true,driver);
-    run("EXPLAIN REPL LOAD " + dbName + "_dupe FROM '" + replDumpLocn + "'", 
driverMirror);
-    printOutput(driverMirror);
     run("REPL LOAD " + dbName + "_dupe FROM '" + replDumpLocn + "'", 
driverMirror);
     verifySetup("REPL STATUS " + dbName + "_dupe", new String[]{replDumpId}, 
driverMirror);
 
@@ -958,8 +948,6 @@ public class TestReplicationScenarios {
     String postDropReplDumpLocn = getResult(0,0,driver);
     String postDropReplDumpId = getResult(0,1,true,driver);
     LOG.info("Dumped to {} with id {}->{}", postDropReplDumpLocn, replDumpId, 
postDropReplDumpId);
-    run("EXPLAIN REPL LOAD " + dbName + "_dupe FROM '" + postDropReplDumpLocn 
+ "'", driverMirror);
-    printOutput(driverMirror);
     run("REPL LOAD " + dbName + "_dupe FROM '" + postDropReplDumpLocn + "'", 
driverMirror);
 
     // verify that drops were replicated. This can either be from tables or 
ptns
@@ -1018,8 +1006,6 @@ public class TestReplicationScenarios {
     run("REPL DUMP " + dbName, driver);
     String replDumpLocn = getResult(0,0,driver);
     String replDumpId = getResult(0,1,true,driver);
-    run("EXPLAIN REPL LOAD " + dbName + "_dupe FROM '" + replDumpLocn + "'", 
driverMirror);
-    printOutput(driverMirror);
     run("REPL LOAD " + dbName + "_dupe FROM '" + replDumpLocn + "'", 
driverMirror);
 
     run("REPL STATUS " + dbName + "_dupe", driverMirror);
@@ -1064,8 +1050,6 @@ public class TestReplicationScenarios {
     // Drop partition after dump
     run("ALTER TABLE " + dbName + ".ptned_copy DROP PARTITION(b='1')", driver);
 
-    run("EXPLAIN REPL LOAD " + dbName + "_dupe FROM '" + postDropReplDumpLocn 
+ "'", driverMirror);
-    printOutput(driverMirror);
     run("REPL LOAD " + dbName + "_dupe FROM '" + postDropReplDumpLocn + "'", 
driverMirror);
 
     Exception e = null;
@@ -1134,8 +1118,6 @@ public class TestReplicationScenarios {
     run("REPL DUMP " + dbName, driver);
     String replDumpLocn = getResult(0,0,driver);
     String replDumpId = getResult(0,1,true,driver);
-    run("EXPLAIN REPL LOAD " + dbName + "_dupe FROM '" + replDumpLocn + "'", 
driverMirror);
-    printOutput(driverMirror);
     run("REPL LOAD " + dbName + "_dupe FROM '" + replDumpLocn + "'", 
driverMirror);
 
     run("REPL STATUS " + dbName + "_dupe", driverMirror);
@@ -1210,8 +1192,6 @@ public class TestReplicationScenarios {
     String postAlterReplDumpLocn = getResult(0,0,driver);
     String postAlterReplDumpId = getResult(0,1,true,driver);
     LOG.info("Dumped to {} with id {}->{}", postAlterReplDumpLocn, replDumpId, 
postAlterReplDumpId);
-    run("EXPLAIN REPL LOAD " + dbName + "_dupe FROM '" + postAlterReplDumpLocn 
+ "'", driverMirror);
-    printOutput(driverMirror);
     run("REPL LOAD " + dbName + "_dupe FROM '" + postAlterReplDumpLocn + "'", 
driverMirror);
 
     // Replication done, we now do the following verifications:
@@ -1304,8 +1284,6 @@ public class TestReplicationScenarios {
     String incrementalDumpId = getResult(0, 1, true, driver);
     LOG.info("Incremental-Dump: Dumped to {} with id {} from {}", 
incrementalDumpLocn, incrementalDumpId, replDumpId);
     replDumpId = incrementalDumpId;
-    run("EXPLAIN REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + 
"'", driverMirror);
-    printOutput(driverMirror);
     run("REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + "'", 
driverMirror);
     verifyRun("SELECT * from " + dbName + "_dupe.unptned_late", unptn_data, 
driverMirror);
 
@@ -1333,8 +1311,6 @@ public class TestReplicationScenarios {
     incrementalDumpId = getResult(0, 1, true, driver);
     LOG.info("Incremental-Dump: Dumped to {} with id {} from {}", 
incrementalDumpLocn, incrementalDumpId, replDumpId);
     replDumpId = incrementalDumpId;
-    run("EXPLAIN REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + 
"'", driverMirror);
-    printOutput(driverMirror);
     run("REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + "'", 
driverMirror);
 
     verifyRun("SELECT a from " + dbName + "_dupe.ptned_late WHERE b=1", 
ptn_data_1, driverMirror);
@@ -1372,8 +1348,6 @@ public class TestReplicationScenarios {
     String incrementalDumpId = getResult(0, 1, true, driver);
     LOG.info("Incremental-Dump: Dumped to {} with id {} from {}", 
incrementalDumpLocn, incrementalDumpId, replDumpId);
     replDumpId = incrementalDumpId;
-    run("EXPLAIN REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + 
"'", driverMirror);
-    printOutput(driverMirror);
     run("REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + "'", 
driverMirror);
     verifyRun("SELECT a from " + dbName + ".unptned ORDER BY a", unptn_data, 
driver);
     verifyRun("SELECT a from " + dbName + ".unptned_late ORDER BY a", 
unptn_data, driver);
@@ -1393,8 +1367,6 @@ public class TestReplicationScenarios {
     incrementalDumpId = getResult(0, 1, true, driver);
     LOG.info("Incremental-Dump: Dumped to {} with id {} from {}", 
incrementalDumpLocn, incrementalDumpId, replDumpId);
     replDumpId = incrementalDumpId;
-    run("EXPLAIN REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + 
"'", driverMirror);
-    printOutput(driverMirror);
     run("REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + "'", 
driverMirror);
 
     verifyRun("SELECT a from " + dbName + "_dupe.unptned_late ORDER BY a", 
unptn_data_after_ins, driverMirror);
@@ -1412,7 +1384,6 @@ public class TestReplicationScenarios {
 
     String[] ptn_data = new String[]{ "ten"};
     run("INSERT INTO TABLE " + dbName + ".ptned partition(b=1) values('" + 
ptn_data[0] + "')", driver);
-    run("DROP TABLE " + dbName + ".ptned", driver);
 
     // Inject a behaviour where it throws exception if an INSERT event is found
     // As we dynamically add a partition through INSERT INTO cmd, it should 
just add ADD_PARTITION
@@ -1449,7 +1420,7 @@ public class TestReplicationScenarios {
     eventTypeValidator.assertInjectionsPerformed(true,false);
     InjectableBehaviourObjectStore.resetGetNextNotificationBehaviour(); // 
reset the behaviour
 
-    verifyIfTableNotExist(replDbName , "ptned", metaStoreClientMirror);
+    verifyRun("SELECT a from " + dbName + "_dupe.ptned where (b=1)", ptn_data, 
driverMirror);
   }
 
   @Test
@@ -1488,8 +1459,6 @@ public class TestReplicationScenarios {
     String incrementalDumpId = getResult(0, 1, true, driver);
     LOG.info("Incremental-Dump: Dumped to {} with id {} from {}", 
incrementalDumpLocn, incrementalDumpId, replDumpId);
     replDumpId = incrementalDumpId;
-    run("EXPLAIN REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + 
"'", driverMirror);
-    printOutput(driverMirror);
     run("REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + "'", 
driverMirror);
     verifyRun("SELECT a from " + dbName + ".ptned where (b=1) ORDER BY a", 
ptn_data_1, driver);
     verifyRun("SELECT a from " + dbName + ".ptned where (b=2) ORDER BY a", 
ptn_data_2, driver);
@@ -1510,8 +1479,6 @@ public class TestReplicationScenarios {
     incrementalDumpId = getResult(0, 1, true, driver);
     LOG.info("Incremental-Dump: Dumped to {} with id {} from {}", 
incrementalDumpLocn, incrementalDumpId, replDumpId);
     replDumpId = incrementalDumpId;
-    run("EXPLAIN REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + 
"'", driverMirror);
-    printOutput(driverMirror);
     run("REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + "'", 
driverMirror);
 
     verifyRun("SELECT a from " + dbName + "_dupe.ptned where (b=2)", 
data_after_ovwrite, driverMirror);
@@ -1590,8 +1557,6 @@ public class TestReplicationScenarios {
     String incrementalDumpId = getResult(0, 1, true, driver);
     LOG.info("Incremental-Dump: Dumped to {} with id {} from {}", 
incrementalDumpLocn, incrementalDumpId, replDumpId);
     replDumpId = incrementalDumpId;
-    run("EXPLAIN REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + 
"'", driverMirror);
-    printOutput(driverMirror);
     run("REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + "'", 
driverMirror);
     verifyRun("SELECT name from " + dbName + "_dupe.namelist where (year=1980) 
ORDER BY name", ptn_year_1980, driverMirror);
     verifyRun("SELECT name from " + dbName + "_dupe.namelist where (day=1) 
ORDER BY name", ptn_day_1_2, driverMirror);
@@ -1617,8 +1582,6 @@ public class TestReplicationScenarios {
     incrementalDumpId = getResult(0, 1, true, driver);
     LOG.info("Incremental-Dump: Dumped to {} with id {} from {}", 
incrementalDumpLocn, incrementalDumpId, replDumpId);
     replDumpId = incrementalDumpId;
-    run("EXPLAIN REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + 
"'", driverMirror);
-    printOutput(driverMirror);
     run("REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + "'", 
driverMirror);
 
     verifySetup("SELECT name from " + dbName + "_dupe.namelist where 
(year=1990 and month=5 and day=25)", data_after_ovwrite, driverMirror);
@@ -2050,8 +2013,6 @@ public class TestReplicationScenarios {
     String incrementalDumpLocn = getResult(0,0,driver);
     String incrementalDumpId = getResult(0,1,true,driver);
     LOG.info("Incremental-dump: Dumped to {} with id {}", incrementalDumpLocn, 
incrementalDumpId);
-    run("EXPLAIN REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + 
"'", driverMirror);
-    printOutput(driverMirror);
     run("REPL LOAD " + dbName + "_dupe FROM '"+incrementalDumpLocn+"'", 
driverMirror);
 
     run("REPL STATUS " + dbName + "_dupe", driverMirror);
@@ -2076,8 +2037,6 @@ public class TestReplicationScenarios {
     incrementalDumpLocn = getResult(0, 0, driver);
     incrementalDumpId = getResult(0, 1, true, driver);
     LOG.info("Incremental-dump: Dumped to {} with id {}", incrementalDumpLocn, 
incrementalDumpId);
-    run("EXPLAIN REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + 
"'", driverMirror);
-    printOutput(driverMirror);
     run("REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + "'", 
driverMirror);
     verifyRun("SELECT * from " + dbName + "_dupe.virtual_view_rename", empty, 
driverMirror);
 
@@ -2091,8 +2050,6 @@ public class TestReplicationScenarios {
     incrementalDumpLocn = getResult(0, 0, driver);
     incrementalDumpId = getResult(0, 1, true, driver);
     LOG.info("Incremental-dump: Dumped to {} with id {}", incrementalDumpLocn, 
incrementalDumpId);
-    run("EXPLAIN REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + 
"'", driverMirror);
-    printOutput(driverMirror);
     run("REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + "'", 
driverMirror);
     verifyRun("SHOW COLUMNS FROM " + dbName + "_dupe.virtual_view_rename", new 
String[] {"a", "a_"}, driverMirror);
 
@@ -2106,8 +2063,6 @@ public class TestReplicationScenarios {
     incrementalDumpLocn = getResult(0, 0, driver);
     incrementalDumpId = getResult(0, 1, true, driver);
     LOG.info("Incremental-dump: Dumped to {} with id {}", incrementalDumpLocn, 
incrementalDumpId);
-    run("EXPLAIN REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + 
"'", driverMirror);
-    printOutput(driverMirror);
     run("REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + "'", 
driverMirror);
     verifyIfTableNotExist(dbName + "_dupe", "virtual_view", 
metaStoreClientMirror);
   }
@@ -2295,8 +2250,6 @@ public class TestReplicationScenarios {
     String incrementalDumpId = getResult(0, 1, true, driver);
     LOG.info("Incremental-Dump: Dumped to {} with id {} from {}", 
incrementalDumpLocn, incrementalDumpId, replDumpId);
     replDumpId = incrementalDumpId;
-    run("EXPLAIN REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + 
"'", driverMirror);
-    printOutput(driverMirror);
     run("REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + "'", 
driverMirror);
     verifyRun("SELECT a from " + dbName + ".unptned ORDER BY a", unptn_data, 
driver);
     verifyRun("SELECT a from " + dbName + "_dupe.unptned ORDER BY a", 
unptn_data, driverMirror);
@@ -2879,8 +2832,6 @@ public class TestReplicationScenarios {
     String incrementalDumpLocn = getResult(0, 0, driver);
     String incrementalDumpId = getResult(0, 1, true, driver);
     LOG.info("Dumped to {} with id {}", incrementalDumpLocn, 
incrementalDumpId);
-    run("EXPLAIN REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + 
"'", driverMirror);
-    printOutput(driverMirror);
     run("REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + "'", 
driverMirror);
 
     String pkName = null;
@@ -2915,8 +2866,6 @@ public class TestReplicationScenarios {
     incrementalDumpLocn = getResult(0, 0, driver);
     incrementalDumpId = getResult(0, 1, true, driver);
     LOG.info("Dumped to {} with id {}", incrementalDumpLocn, 
incrementalDumpId);
-    run("EXPLAIN REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + 
"'", driverMirror);
-    printOutput(driverMirror);
     run("REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + "'", 
driverMirror);
 
     try {
@@ -2992,8 +2941,6 @@ public class TestReplicationScenarios {
     String incrementalDumpLocn = getResult(0,0,driver);
     String incrementalDumpId = getResult(0,1,true,driver);
     LOG.info("Dumped to {} with id {}", incrementalDumpLocn, 
incrementalDumpId);
-    run("EXPLAIN REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + 
"'", driverMirror);
-    printOutput(driverMirror);
     run("REPL LOAD " + dbName + "_dupe FROM '"+incrementalDumpLocn+"'", 
driverMirror);
 
     verifyRun("SELECT count(*) from " + dbName + "_dupe.unptned2", new 
String[]{"2"}, driverMirror);
@@ -3031,8 +2978,6 @@ public class TestReplicationScenarios {
     String incrementalDumpLocn = getResult(0,0,driver);
     String incrementalDumpId = getResult(0,1,true,driver);
     LOG.info("Incremental-dump: Dumped to {} with id {}", incrementalDumpLocn, 
incrementalDumpId);
-    run("EXPLAIN REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + 
"'", driverMirror);
-    printOutput(driverMirror);
     run("REPL LOAD " + dbName + "_dupe FROM '"+incrementalDumpLocn+"'", 
driverMirror);
     verifyIfTableNotExist(dbName + "_dupe", "acid_table_rename", 
metaStoreClientMirror);
 

http://git-wip-us.apache.org/repos/asf/hive/blob/1c2e999c/ql/src/java/org/apache/hadoop/hive/ql/Driver.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/Driver.java 
b/ql/src/java/org/apache/hadoop/hive/ql/Driver.java
index a3bbf00..6616cba 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/Driver.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/Driver.java
@@ -2081,13 +2081,30 @@ public class Driver implements CommandProcessor {
 
   private void setQueryDisplays(List<Task<? extends Serializable>> tasks) {
     if (tasks != null) {
-      for (Task<? extends Serializable> task : tasks) {
-        task.setQueryDisplay(queryDisplay);
-        setQueryDisplays(task.getDependentTasks());
+      Set<Task<? extends Serializable>> visited = new HashSet<Task<? extends 
Serializable>>();
+      while (!tasks.isEmpty()) {
+        tasks = setQueryDisplays(tasks, visited);
       }
     }
   }
 
+  private List<Task<? extends Serializable>> setQueryDisplays(
+          List<Task<? extends Serializable>> tasks,
+          Set<Task<? extends Serializable>> visited) {
+    List<Task<? extends Serializable>> childTasks = new ArrayList<>();
+    for (Task<? extends Serializable> task : tasks) {
+      if (visited.contains(task)) {
+        continue;
+      }
+      task.setQueryDisplay(queryDisplay);
+      if (task.getDependentTasks() != null) {
+        childTasks.addAll(task.getDependentTasks());
+      }
+      visited.add(task);
+    }
+    return childTasks;
+  }
+
   private void logMrWarning(int mrJobs) {
     if (mrJobs <= 0 || !("mr".equals(HiveConf.getVar(conf, 
ConfVars.HIVE_EXECUTION_ENGINE)))) {
       return;

http://git-wip-us.apache.org/repos/asf/hive/blob/1c2e999c/ql/src/java/org/apache/hadoop/hive/ql/parse/ImportSemanticAnalyzer.java
----------------------------------------------------------------------
diff --git 
a/ql/src/java/org/apache/hadoop/hive/ql/parse/ImportSemanticAnalyzer.java 
b/ql/src/java/org/apache/hadoop/hive/ql/parse/ImportSemanticAnalyzer.java
index ed004fe..89c4e2c 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/ImportSemanticAnalyzer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/ImportSemanticAnalyzer.java
@@ -375,12 +375,17 @@ public class ImportSemanticAnalyzer extends 
BaseSemanticAnalyzer {
       URI fromURI, FileSystem fs, ImportTableDesc tblDesc,
       Table table, Warehouse wh, AddPartitionDesc addPartitionDesc,
       ReplicationSpec replicationSpec, 
org.apache.hadoop.hive.ql.metadata.Partition ptn,
-      EximUtil.SemanticAnalyzerWrapperContext x) {
+      EximUtil.SemanticAnalyzerWrapperContext x) throws MetaException, 
IOException, HiveException {
     addPartitionDesc.setReplaceMode(true);
     if ((replicationSpec != null) && (replicationSpec.isInReplicationScope())){
       addPartitionDesc.setReplicationSpec(replicationSpec);
     }
-    addPartitionDesc.getPartition(0).setLocation(ptn.getLocation()); // use 
existing location
+    AddPartitionDesc.OnePartitionDesc partSpec = 
addPartitionDesc.getPartition(0);
+    if (ptn == null) {
+      fixLocationInPartSpec(fs, tblDesc, table, wh, replicationSpec, partSpec, 
x);
+    } else {
+      partSpec.setLocation(ptn.getLocation()); // use existing location
+    }
     return TaskFactory.get(new DDLWork(
         x.getInputs(),
         x.getOutputs(),
@@ -895,6 +900,12 @@ public class ImportSemanticAnalyzer extends 
BaseSemanticAnalyzer {
               if (updatedMetadata != null) {
                 
updatedMetadata.addPartition(addPartitionDesc.getPartition(0).getPartSpec());
               }
+            } else {
+              x.getTasks().add(alterSinglePartition(
+                      fromURI, fs, tblDesc, table, wh, addPartitionDesc, 
replicationSpec, null, x));
+              if (updatedMetadata != null) {
+                
updatedMetadata.addPartition(addPartitionDesc.getPartition(0).getPartSpec());
+              }
             }
           } else {
             // If replicating, then the partition already existing means we 
need to replace, maybe, if

http://git-wip-us.apache.org/repos/asf/hive/blob/1c2e999c/ql/src/java/org/apache/hadoop/hive/ql/parse/ReplicationSemanticAnalyzer.java
----------------------------------------------------------------------
diff --git 
a/ql/src/java/org/apache/hadoop/hive/ql/parse/ReplicationSemanticAnalyzer.java 
b/ql/src/java/org/apache/hadoop/hive/ql/parse/ReplicationSemanticAnalyzer.java
index 8f6316d..fd97baa 100644
--- 
a/ql/src/java/org/apache/hadoop/hive/ql/parse/ReplicationSemanticAnalyzer.java
+++ 
b/ql/src/java/org/apache/hadoop/hive/ql/parse/ReplicationSemanticAnalyzer.java
@@ -17,7 +17,6 @@
  */
 package org.apache.hadoop.hive.ql.parse;
 
-import io.netty.util.internal.StringUtil;
 import org.antlr.runtime.tree.Tree;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.hadoop.fs.FileStatus;
@@ -373,7 +372,7 @@ public class ReplicationSemanticAnalyzer extends 
BaseSemanticAnalyzer {
               LOG.debug("Added {}:{} as a precursor of barrier task {}:{}",
                   t.getClass(), t.getId(), barrierTask.getClass(), 
barrierTask.getId());
             }
-            LOG.debug("Updated taskChainTail from {}{} to {}{}",
+            LOG.debug("Updated taskChainTail from {}:{} to {}:{}",
                 taskChainTail.getClass(), taskChainTail.getId(), 
barrierTask.getClass(), barrierTask.getId());
             taskChainTail = barrierTask;
           }

Reply via email to