You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] HiveCatalog.dropTable throws RuntimeException for a table in a missing database, even with ignoreIfNotExists=true #11408
I searched in the issues and found nothing similar.
Paimon version
2.0.0, 2.1.0, and master 88792ed0d1. 1.4.x and earlier are not affected.
Compute Engine
Java API (HiveCatalog). Found through Apache Gravitino, which drops Paimon tables through the catalog API.
Minimal reproduce step
Call dropTable on a Hive catalog for a table whose database does not exist. I added this test to HiveCatalogTest on master:
@TestpublicvoidtestDropTableInMissingDatabase() {
Identifieridentifier = Identifier.create("missing_db", "t");
// Both calls fail with RuntimeException.catalog.dropTable(identifier, false);
catalog.dropTable(identifier, true);
}
Both calls fail with the same error:
java.lang.RuntimeException: Can not get table Identifier{database='missing_db', object='t'} from metastore.
at org.apache.paimon.hive.HiveCatalog.getTableLocation(HiveCatalog.java)
at org.apache.paimon.catalog.AbstractCatalog.tableExists(AbstractCatalog.java)
at org.apache.paimon.hive.HiveCatalog.tableExists(HiveCatalog.java)
at org.apache.paimon.catalog.AbstractCatalog.dropTable(AbstractCatalog.java)
Caused by: NoSuchObjectException(message:missing_db)
getTable on the same identifier throws TableNotExistException: Table missing_db.t does not exist.
In practice this happens when the database has already been dropped, for example by Spark DROP DATABASE ... CASCADE, and a client then drops one of its tables.
What doesn't meet your expectations?
A table in a missing database does not exist, so I expected:
dropTable(identifier, true) to return without error;
dropTable(identifier, false) to throw TableNotExistException, as getTable does.
Before 2.0, dropTable behaved this way, because it started with getTable. #8130 added a tableExists check at the start of AbstractCatalog.dropTable. With the Hive catalog, tableExists first asks HMS whether the table exists and then calls getTableLocation. When the table is not in HMS, getTableLocation builds the table path from the database location with client.getDatabase(databaseName), which throws NoSuchObjectException when the database is missing. The exception is wrapped in a RuntimeException, so ignoreIfNotExists is never checked.
Anything else?
I'll open a PR that makes HiveCatalog.tableExists return false when the database does not exist, before it builds the table location. Other callers of getTableLocation keep the current error.
Activity