diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosExternalTables.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosExternalTables.java index 1815824b5f..7a90dcc6e8 100644 --- a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosExternalTables.java +++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosExternalTables.java @@ -855,6 +855,52 @@ public void testExtTableBootstrapDuringIncrementalWithoutAnyEvents() throws Thro .verifyReplTargetProperty(replicatedDbName); } + @Test + public void replicationWithTableNameContainsKeywords() throws Throwable { + List loadWithClause = externalTableBasePathWithClause(); + + WarehouseInstance.Tuple tuple = primary + .run("use " + primaryDbName) + .run("create external table t1_functions (id int)") + .run("insert into table t1_functions values (1)") + .run("insert into table t1_functions values (2)") + .run("create external table t2_constraints (place string) partitioned by (country string)") + .run("insert into table t2_constraints partition(country='india') values ('bangalore')") + .run("insert into table t2_constraints partition(country='us') values ('austin')") + .run("insert into table t2_constraints partition(country='france') values ('paris')") + .dump(primaryDbName, null); + + replica.load(replicatedDbName, tuple.dumpLocation, loadWithClause) + .run("repl status " + replicatedDbName) + .verifyResult(tuple.lastReplicationId) + .run("use " + replicatedDbName) + .run("show tables like 't1_functions'") + .verifyResults(new String[] {"t1_functions"}) + .run("show tables like 't2_constraints'") + .verifyResults(new String[] {"t2_constraints"}) + .run("select id from t1_functions") + .verifyResults(new String[] {"1", "2"}) + .verifyReplTargetProperty(replicatedDbName); + + tuple = primary.run("use " + primaryDbName) + .run("create external table t3_bootstrap (id int)") + .run("insert into table t3_bootstrap values (10)") + .run("insert into table t3_bootstrap values (20)") + .run("create table t4_tables (id int)") + .run("insert into table t4_tables values (10)") + .run("insert into table t4_tables values (20)") + .dump(primaryDbName, tuple.lastReplicationId); + + replica.load(replicatedDbName, tuple.dumpLocation, loadWithClause) + .run("use " + replicatedDbName) + .run("show tables like 't3_bootstrap'") + .verifyResults(new String[] {"t3_bootstrap"}) + .run("show tables like 't4_tables'") + .verifyResults(new String[] {"t4_tables"}) + .verifyReplTargetProperty(replicatedDbName); + } + + private List externalTableBasePathWithClause() throws IOException, SemanticException { return ReplicationTestUtils.externalTableBasePathWithClause(REPLICA_EXTERNAL_BASE, replica); } diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/repl/bootstrap/events/filesystem/DatabaseEventsIterator.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/repl/bootstrap/events/filesystem/DatabaseEventsIterator.java index 4c84797efe..72baee6881 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/exec/repl/bootstrap/events/filesystem/DatabaseEventsIterator.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/repl/bootstrap/events/filesystem/DatabaseEventsIterator.java @@ -170,7 +170,7 @@ public BootstrapEvent next() { } String currentPath = next.toString(); - if (currentPath.contains(FUNCTIONS_ROOT_DIR_NAME)) { + if (currentPath.contains(Path.SEPARATOR + FUNCTIONS_ROOT_DIR_NAME + Path.SEPARATOR)) { LOG.debug("functions directory: {}", next.toString()); return postProcessing(new FSFunctionEvent(next)); }