Skip to content

Commit c8b5e1f

Browse files
author
xiaohongbo
committed
Revert "[hive] Fix no longer possible to drop the hms table issue when table not in fs (apache#4853)"
This reverts commit 6690253.
1 parent 6690253 commit c8b5e1f

File tree

3 files changed

+1
-62
lines changed

3 files changed

+1
-62
lines changed

paimon-core/src/main/java/org/apache/paimon/catalog/AbstractCatalog.java

+1-5
Original file line numberDiff line numberDiff line change
@@ -272,14 +272,10 @@ public void dropTable(Identifier identifier, boolean ignoreIfNotExists)
272272
try {
273273
getTable(identifier);
274274
} catch (TableNotExistException e) {
275-
if (!tableExistsInFileSystem(getTableLocation(identifier), DEFAULT_MAIN_BRANCH)) {
276-
dropTableImpl(identifier);
277-
}
278275
if (ignoreIfNotExists) {
279276
return;
280-
} else {
281-
throw new TableNotExistException(identifier);
282277
}
278+
throw new TableNotExistException(identifier);
283279
}
284280

285281
dropTableImpl(identifier);

paimon-hive/paimon-hive-catalog/src/test/java/org/apache/paimon/hive/HiveCatalogTest.java

-34
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@
4444
import org.junit.jupiter.api.io.TempDir;
4545

4646
import java.lang.reflect.Field;
47-
import java.nio.file.Path;
48-
import java.nio.file.Paths;
4947
import java.util.ArrayList;
5048
import java.util.Arrays;
5149
import java.util.Collections;
@@ -61,7 +59,6 @@
6159
import static org.apache.paimon.hive.HiveCatalog.TABLE_TYPE_PROP;
6260
import static org.assertj.core.api.Assertions.assertThat;
6361
import static org.assertj.core.api.Assertions.assertThatThrownBy;
64-
import static org.junit.Assert.assertThrows;
6562
import static org.junit.jupiter.api.Assertions.assertEquals;
6663
import static org.junit.jupiter.api.Assertions.fail;
6764

@@ -410,37 +407,6 @@ public void testListTables() throws Exception {
410407
catalog.dropDatabase(databaseName, true, true);
411408
}
412409

413-
@Test
414-
public void testDropTable() throws Exception {
415-
String databaseName = "drop_table_test_db";
416-
String tableName = "drop_table_test_table";
417-
catalog.dropDatabase(databaseName, true, true);
418-
catalog.createDatabase(databaseName, true);
419-
Identifier identifier = Identifier.create(databaseName, tableName);
420-
421-
// test ignore if exists
422-
catalog.createTable(
423-
identifier, Schema.newBuilder().column("col", DataTypes.INT()).build(), true);
424-
Path path = Paths.get(catalog.warehouse(), databaseName.concat(".db"), tableName);
425-
catalog.fileIO().delete(new org.apache.paimon.fs.Path(path.toString()), true);
426-
List<String> tables = catalog.listTables(databaseName);
427-
assertEquals(1, tables.size());
428-
catalog.dropTable(identifier, true);
429-
List<String> newTables = catalog.listTables(databaseName);
430-
assertEquals(0, newTables.size());
431-
432-
// test not ignore if exists
433-
catalog.createTable(
434-
identifier, Schema.newBuilder().column("col", DataTypes.INT()).build(), true);
435-
catalog.fileIO().delete(new org.apache.paimon.fs.Path(path.toString()), true);
436-
tables = catalog.listTables(databaseName);
437-
assertEquals(1, tables.size());
438-
assertThrows(
439-
Catalog.TableNotExistException.class, () -> catalog.dropTable(identifier, false));
440-
441-
catalog.dropDatabase(databaseName, true, true);
442-
}
443-
444410
@Override
445411
protected boolean supportsView() {
446412
return true;

paimon-spark/paimon-spark-ut/src/test/scala/org/apache/paimon/spark/sql/DDLWithHiveCatalogTestBase.scala

-23
Original file line numberDiff line numberDiff line change
@@ -621,29 +621,6 @@ abstract class DDLWithHiveCatalogTestBase extends PaimonHiveTestBase {
621621
}
622622
}
623623

624-
test("Paimon DDL with hive catalog: drop table which location has been deleted") {
625-
Seq("paimon", sparkCatalogName, paimonHiveCatalogName).foreach {
626-
catalogName =>
627-
spark.sql(s"USE $catalogName")
628-
withDatabase("paimon_db") {
629-
spark.sql(s"CREATE DATABASE paimon_db")
630-
spark.sql(s"USE paimon_db")
631-
spark.sql("CREATE TABLE t USING paimon")
632-
val table = loadTable("paimon_db", "t")
633-
table.fileIO().delete(table.location(), true)
634-
if (catalogName.equals("paimon")) {
635-
// Filesystem catalog determines whether a table exists based on table location
636-
assert(spark.sql("SHOW TABLES").count() == 0)
637-
} else {
638-
// Hive catalog determines whether a table exists based on metadata in hms
639-
assert(spark.sql("SHOW TABLES").count() == 1)
640-
}
641-
spark.sql("DROP TABLE IF EXISTS t")
642-
assert(spark.sql("SHOW TABLES").count() == 0)
643-
}
644-
}
645-
}
646-
647624
def getDatabaseProp(dbName: String, propertyName: String): String = {
648625
spark
649626
.sql(s"DESC DATABASE EXTENDED $dbName")

0 commit comments

Comments
 (0)