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 b19c1aa1cb..a79e73a9dc 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 @@ -1953,6 +1953,21 @@ public void testViewsReplication() throws IOException { printOutput(driverMirror); run("REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + "'", driverMirror); verifyRun("SHOW COLUMNS FROM " + dbName + "_dupe.virtual_view_rename", new String[] {"a", "a_"}, driverMirror); + + // Test "DROP VIEW" + run("DROP VIEW " + dbName + ".virtual_view", driver); + verifyIfTableNotExist(dbName, "virtual_view", metaStoreClient); + + // Perform REPL-DUMP/LOAD + advanceDumpDir(); + run("REPL DUMP " + dbName + " FROM " + incrementalDumpId, driver); + incrementalDumpLocn = getResult(0, 0, driver); + incrementalDumpId = getResult(0, 1, true, driver); + LOG.info("Incremental-dump: Dumped to {} with id {}", incrementalDumpLocn, incrementalDumpId); + run("EXPLAIN REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + "'", driverMirror); + printOutput(driverMirror); + run("REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + "'", driverMirror); + verifyIfTableNotExist(dbName + "_dupe", "virtual_view", metaStoreClientMirror); } @Test diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java index acc23901d3..0458b5102c 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java @@ -4173,7 +4173,7 @@ private void dropPartitions(Hive db, Table tbl, DropTableDesc dropTbl) throws Hi private void dropTable(Hive db, Table tbl, DropTableDesc dropTbl) throws HiveException { // This is a true DROP TABLE - if (tbl != null) { + if (tbl != null && dropTbl.getExpectedType() != null) { if (tbl.isView()) { if (!dropTbl.getExpectView()) { if (dropTbl.getIfExists()) { diff --git a/ql/src/java/org/apache/hadoop/hive/ql/plan/DropTableDesc.java b/ql/src/java/org/apache/hadoop/hive/ql/plan/DropTableDesc.java index 74c742c9e3..b99f5bc869 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/plan/DropTableDesc.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/plan/DropTableDesc.java @@ -117,6 +117,13 @@ public void setTableName(String tableName) { } /** + * @return the expectedType + */ + public TableType getExpectedType() { + return expectedType; + } + + /** * @return whether to expect a view being dropped */ public boolean getExpectView() {