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 df304c2607..64c853e329 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 @@ -166,7 +166,8 @@ public void externalTableReplicationWithDefaultPaths() throws Throwable { .run("select country from t2 where country = 'us'") .verifyResult("us") .run("select country from t2 where country = 'france'") - .verifyResult("france"); + .verifyResult("france") + .run("show partitions t2").verifyResults(new String[] {"country=france", "country=india", "country=us"}); // Ckpt should be set on bootstrapped db. replica.verifyIfCkptSet(replicatedDbName, tuple.dumpLocation); diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosExternalTablesMetaDataOnly.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosExternalTablesMetaDataOnly.java index bf691f331c..c7499228f3 100644 --- a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosExternalTablesMetaDataOnly.java +++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosExternalTablesMetaDataOnly.java @@ -164,7 +164,8 @@ public void externalTableReplicationWithDefaultPaths() throws Throwable { .run("select country from t2 where country = 'us'") .verifyResult(null) .run("select country from t2 where country = 'france'") - .verifyResult(null); + .verifyResult(null) + .run("show partitions t2").verifyResults(new String[] {"country=france", "country=india", "country=us"}); // Ckpt should be set on bootstrapped db. replica.verifyIfCkptSet(replicatedDbName, tuple.dumpLocation); @@ -276,7 +277,9 @@ public void externalTableWithPartitions() throws Throwable { .verifyResults(new String[] {"t2"}) .run("select place from t2") .verifyResults(new String[] {}) - .verifyReplTargetProperty(replicatedDbName); + .verifyReplTargetProperty(replicatedDbName) + .run("show partitions t2") + .verifyResults(new String[] {"country=india"}); // add new data externally, to a partition, but under the table level top directory Path partitionDir = new Path(externalTableLocation, "country=india"); @@ -299,6 +302,8 @@ public void externalTableWithPartitions() throws Throwable { .verifyResults(new String[] {}) .run("select place from t2 where country='australia'") .verifyResults(new String[] {}) + .run("show partitions t2") + .verifyResults(new String[] {"country=australia", "country=india"}) .verifyReplTargetProperty(replicatedDbName); Path customPartitionLocation = @@ -320,6 +325,8 @@ public void externalTableWithPartitions() throws Throwable { .run("use " + replicatedDbName) .run("select place from t2 where country='france'") .verifyResults(new String[] {}) + .run("show partitions t2") + .verifyResults(new String[] {"country=australia", "country=france", "country=india"}) .verifyReplTargetProperty(replicatedDbName); // change the location of the partition via alter command diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/TableExport.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/TableExport.java index 97a1dd31a7..5fde91d86a 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/TableExport.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/TableExport.java @@ -107,7 +107,9 @@ private PartitionIterable getPartitions() throws SemanticException { if (tableSpec != null && tableSpec.tableHandle != null && tableSpec.tableHandle.isPartitioned()) { if (tableSpec.specType == TableSpec.SpecType.TABLE_ONLY) { // TABLE-ONLY, fetch partitions if regular export, don't if metadata-only - if (replicationSpec.isMetadataOnly()) { + //For metadata only external tables, we still need the partition info + if (replicationSpec.isMetadataOnly() + && !Utils.shouldDumpMetaDataOnlyForExternalTables(this.tableSpec.tableHandle, conf)) { return null; } else { return new PartitionIterable(db, tableSpec.tableHandle, null, conf.getIntVar( diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/Utils.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/Utils.java index 6f8912b5f9..572f6d8902 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/Utils.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/Utils.java @@ -274,7 +274,11 @@ public static boolean shouldReplicate(NotificationEvent tableForEvent, public static boolean shouldDumpMetaDataOnly(Table table, HiveConf conf) { return conf.getBoolVar(HiveConf.ConfVars.REPL_DUMP_METADATA_ONLY) || - (conf.getBoolVar(HiveConf.ConfVars.REPL_INCLUDE_EXTERNAL_TABLES) && + shouldDumpMetaDataOnlyForExternalTables(table, conf); + } + + public static boolean shouldDumpMetaDataOnlyForExternalTables(Table table, HiveConf conf) { + return (conf.getBoolVar(HiveConf.ConfVars.REPL_INCLUDE_EXTERNAL_TABLES) && table.getTableType().equals(TableType.EXTERNAL_TABLE) && conf.getBoolVar(HiveConf.ConfVars.REPL_DUMP_METADATA_ONLY_FOR_EXTERNAL_TABLE)); }