maheshk114 commented on a change in pull request #688: HIVE-21886 : REPL - With 
table list - Handle rename events during replace policy
URL: https://github.com/apache/hive/pull/688#discussion_r297642233
 
 

 ##########
 File path: 
itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestTableLevelReplicationScenarios.java
 ##########
 @@ -786,4 +786,127 @@ public void testRenameTableScenariosExternalTable() 
throws Throwable {
     replicateAndVerify(replPolicy, null, lastReplId, dumpWithClause,
             loadWithClause, bootstrapTables, replicatedTables);
   }
+
+  @Test
+  public void testRenameTableScenariosWithReplaceExternalTable() throws 
Throwable {
+    List<String> loadWithClause = 
ReplicationTestUtils.externalTableBasePathWithClause(REPLICA_EXTERNAL_BASE, 
replica);
+    List<String> dumpWithClause = Arrays.asList(
+            "'" + HiveConf.ConfVars.REPL_INCLUDE_EXTERNAL_TABLES.varname + 
"'='false'",
+            "'" + HiveConf.ConfVars.REPL_BOOTSTRAP_EXTERNAL_TABLES.varname + 
"'='false'",
+            "'" + HiveConf.ConfVars.REPL_BOOTSTRAP_ACID_TABLES.varname + 
"'='false'",
+            "'" + ReplUtils.REPL_DUMP_INCLUDE_ACID_TABLES + "'='false'"
+    );
+    String replPolicy = primaryDbName + ".['in[0-9]+'].['in100', 'in200', 
'in1400']";
+    String lastReplId = replicateAndVerify(replPolicy, null, null, 
dumpWithClause,
+            loadWithClause, new String[]{}, new String[]{});
+
+    String[] originalFullAcidTables = new String[]{"in1", "in2", "out3", 
"out4", "out5", "in100", "in200", "in300"};
+    String[] originalExternalTables = new String[]{"in400", "out500"};
+    String[] originalNonAcidTables = new String[]{"in1400", "out1500", 
"out1600"};
+    createTables(originalNonAcidTables, CreateTableType.NON_ACID);
+    createTables(originalFullAcidTables, CreateTableType.FULL_ACID);
+    createTables(originalExternalTables, CreateTableType.EXTERNAL);
+
+    // Replicate and verify, no table should be there.
+    String[] replicatedTables = new String[]{};
+    String[] bootstrapTables = new String[]{};
+    lastReplId = replicateAndVerify(replPolicy, null, lastReplId, 
dumpWithClause,
+            loadWithClause, bootstrapTables, replicatedTables);
+
+    // Rename the tables to satisfy the condition also replace the policy.
+    primary.run("use " + primaryDbName)
+            .run("alter table out1600 rename to in1600")
+            .run("alter table in1400 rename to out1400")
+            .run("alter table in1 rename to out7")
+            .run("alter table out3 rename to in8")
+            .run("alter table out4 rename to in9")
+            .run("drop table in9")
+            .run("alter table out5 rename to in10")
+            .run("alter table in10 rename to out11")
+            .run("alter table out500 rename to in500")
+            .run("alter table in400 rename to out400");
+
+    String newPolicy = primaryDbName + ".['in[0-9]+', 'out1500'].['in2']";
+    dumpWithClause = Arrays.asList(
+            "'" + HiveConf.ConfVars.REPL_INCLUDE_EXTERNAL_TABLES.varname + 
"'='true'",
+            "'" + HiveConf.ConfVars.REPL_BOOTSTRAP_EXTERNAL_TABLES.varname + 
"'='true'",
+            "'" + HiveConf.ConfVars.REPL_BOOTSTRAP_ACID_TABLES.varname + 
"'='true'",
+            "'" + ReplUtils.REPL_DUMP_INCLUDE_ACID_TABLES + "'='true'"
+    );
+
+    // in2 should be dropped.
+    replicatedTables = new String[]{"in8", "in100", "in200", "in300", "in500", 
"in1600", "out1500"};
+    bootstrapTables = new String[]{"in8", "in100", "in200", "in300", "in500", 
"in1600", "out1500"};
+    replicateAndVerify(newPolicy, replPolicy, lastReplId, dumpWithClause,
 
 Review comment:
   i think external table behavior is same as managed ..so i don't think its 
required.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to