sankarh commented on a change in pull request #679: HIVE-21764 : REPL DUMP
should detect and bootstrap any rename table events where old table was
excluded but renamed table is included.
URL: https://github.com/apache/hive/pull/679#discussion_r296109918
##########
File path:
itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestTableLevelReplicationScenarios.java
##########
@@ -585,4 +585,143 @@ public void
testReplacePolicyOnBootstrapExternalTablesIncrementalPhase() throws
.run("show tables")
.verifyResults(incrementalReplicatedTables);
}
+
+ @Test
+ public void testRenameTableScenariosBasic() throws Throwable {
+ String replPolicy = primaryDbName + ".['in[0-9]+'].['out[0-9]+']";
+ String lastReplId = replicateAndVerify(replPolicy, null, null, null,
+ null, new String[]{}, new String[]{});
+
+ String[] originalNonAcidTables = new String[]{"in1", "in2", "out3",
"out4", "out5", "out6"};
+ createTables(originalNonAcidTables, CreateTableType.NON_ACID);
+
+ // Replicate and verify if only 2 tables are replicated to target.
+ String[] replicatedTables = new String[]{"in1", "in2"};
+ String[] bootstrapTables = new String[]{};
+ lastReplId = replicateAndVerify(replPolicy, null, lastReplId, null,
+ null, bootstrapTables, replicatedTables);
+
+ // Rename tables to make them satisfy the filter.
+ primary.run("use " + primaryDbName)
+ .run("alter table out3 rename to in3")
+ .run("alter table out4 rename to in4")
+ .run("alter table out5 rename to in5");
+
+ replicatedTables = new String[]{"in1", "in2", "in3", "in4", "in5"};
+ bootstrapTables = new String[]{"in3", "in4", "in5"};
+ lastReplId = replicateAndVerify(replPolicy, null, lastReplId, null,
+ null, bootstrapTables, replicatedTables);
+
+ primary.run("use " + primaryDbName)
+ .run("alter table in3 rename to in7")
+ .run("alter table in7 rename to in8") // Double rename, both
satisfying the filter, so no bootstrap.
+ .run("alter table in4 rename to out9") // out9 does not match the
filter so in4 should be dropped.
+ .run("alter table in5 rename to out10") // Rename from satisfying
name to not satisfying name.
+ .run("alter table out10 rename to in11");// from non satisfying to
satisfying, should be bootstrapped
+
+ replicatedTables = new String[]{"in1", "in2", "in8", "in11"};
+ bootstrapTables = new String[]{"in11"};
+ lastReplId = replicateAndVerify(replPolicy, null, lastReplId, null,
+ null, bootstrapTables, replicatedTables);
+
+ primary.run("use " + primaryDbName)
+ .run("alter table in8 rename to in12") // table is renamed from
satisfying to satisfying, no bootstrap
+ .run("alter table out9 rename to in13") // out9 does not match the
filter so in13 should be bootstrapped.
+ .run("alter table in13 rename to in14") // table is renamed from
satisfying to satisfying
+ .run("drop table in14"); // table in14 is dropped, so no
bootstrap should happen.
Review comment:
Need to add a scenario for out9 -> in13 -> in14 without drop (in14). It
should bootstrap in14.
----------------------------------------------------------------
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]