pvary commented on code in PR #17873:
URL: https://github.com/apache/iceberg/pull/17873#discussion_r4007741419
##########
flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java:
##########
@@ -378,40 +437,82 @@ private Table loadIcebergTable(ObjectPath tablePath)
throws TableNotExistExcepti
@Override
public boolean tableExists(ObjectPath tablePath) throws CatalogException {
- return icebergCatalog.tableExists(toIdentifier(tablePath));
+ TableIdentifier identifier = toIdentifier(tablePath);
+ return icebergCatalog.tableExists(identifier)
+ || (canBeView(tablePath) && asViewCatalog.viewExists(identifier));
}
@Override
public void dropTable(ObjectPath tablePath, boolean ignoreIfNotExists)
throws TableNotExistException, CatalogException {
+ TableIdentifier identifier = toIdentifier(tablePath);
+
+ boolean dropped;
try {
- icebergCatalog.dropTable(toIdentifier(tablePath));
+ dropped = icebergCatalog.dropTable(identifier);
} catch (org.apache.iceberg.exceptions.NoSuchTableException e) {
+ // some catalogs signal "not a table" by throwing (e.g. Hive for a view
entry)
+ if (canBeView(tablePath) && asViewCatalog.dropView(identifier)) {
+ return;
+ }
+
if (!ignoreIfNotExists) {
throw new TableNotExistException(getName(), tablePath, e);
}
+
+ return;
+ }
+
+ // others return false for a missing table; keep that
+ // behavior for tables and only consult the view catalog before returning
+ if (!dropped && canBeView(tablePath)) {
+ asViewCatalog.dropView(identifier);
Review Comment:
Shall we check and throw if `!ignoreIfNotExists`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]