You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by da...@apache.org on 2017/08/03 06:24:39 UTC

hive git commit: HIVE-17212: Dynamic add partition by insert shouldn't generate INSERT event (Sankar Hariappan, reviewed by Anishek Agarwal, Daniel Dai)

Repository: hive
Updated Branches:
  refs/heads/master e5cad8968 -> 8ff37ad87


HIVE-17212: Dynamic add partition by insert shouldn't generate INSERT event (Sankar Hariappan, reviewed by Anishek Agarwal, Daniel Dai)


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

Branch: refs/heads/master
Commit: 8ff37ad878562d7926baa94ef2099f8eb38b1ea8
Parents: e5cad89
Author: Daniel Dai <da...@hortonworks.com>
Authored: Wed Aug 2 23:23:10 2017 -0700
Committer: Daniel Dai <da...@hortonworks.com>
Committed: Wed Aug 2 23:24:17 2017 -0700

----------------------------------------------------------------------
 .../hive/ql/parse/TestReplicationScenarios.java | 48 ++++++++++++++++++++
 1 file changed, 48 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/8ff37ad8/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 6250ad6..cf2b517 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
@@ -1247,6 +1247,54 @@ public class TestReplicationScenarios {
   }
 
   @Test
+  public void testEventTypesForDynamicAddPartitionByInsert() throws IOException {
+    String name = testName.getMethodName();
+    final String dbName = createDB(name);
+    String replDbName = dbName + "_dupe";
+    run("CREATE TABLE " + dbName + ".ptned(a string) partitioned by (b int) STORED AS TEXTFILE");
+    Tuple bootstrap = bootstrapLoadAndVerify(dbName, replDbName);
+
+    String[] ptn_data = new String[]{ "ten"};
+    run("INSERT INTO TABLE " + dbName + ".ptned partition(b=1) values('" + ptn_data[0] + "')");
+
+    // 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
+    // event not an INSERT event
+    BehaviourInjection<NotificationEventResponse,NotificationEventResponse> eventTypeValidator
+            = new BehaviourInjection<NotificationEventResponse,NotificationEventResponse>(){
+
+      @Nullable
+      @Override
+      public NotificationEventResponse apply(@Nullable NotificationEventResponse eventsList) {
+        if (null != eventsList) {
+          List<NotificationEvent> events = eventsList.getEvents();
+          for (int i = 0; i < events.size(); i++) {
+            NotificationEvent event = events.get(i);
+
+            // Skip all the events belong to other DBs/tables.
+            if (event.getDbName().equalsIgnoreCase(dbName)) {
+              if (event.getEventType() == "INSERT") {
+                // If an insert event is found, then return null hence no event is dumped.
+                return null;
+              }
+            }
+          }
+          injectionPathCalled = true;
+        }
+        return eventsList;
+      }
+    };
+    InjectableBehaviourObjectStore.setGetNextNotificationBehaviour(eventTypeValidator);
+
+    incrementalLoadAndVerify(dbName, bootstrap.lastReplId, replDbName);
+
+    eventTypeValidator.assertInjectionsPerformed(true,false);
+    InjectableBehaviourObjectStore.resetGetNextNotificationBehaviour(); // reset the behaviour
+
+    verifyRun("SELECT a from " + replDbName + ".ptned where (b=1) ORDER BY a", ptn_data);
+  }
+
+  @Test
   public void testIncrementalInsertToPartition() throws IOException {
     String testName = "incrementalInsertToPartition";
     LOG.info("Testing " + testName);