pvary commented on code in PR #17873:
URL: https://github.com/apache/iceberg/pull/17873#discussion_r4014067645
##########
flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java:
##########
@@ -440,34 +441,77 @@ public boolean tableExists(ObjectPath tablePath) throws
CatalogException {
@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; consult the view catalog before
+ // deciding the object does not exist
+ if (!dropped) {
+ boolean viewDropped = canBeView(tablePath) &&
asViewCatalog.dropView(identifier);
+ if (!viewDropped && !ignoreIfNotExists) {
+ throw new TableNotExistException(getName(), tablePath);
+ }
}
}
@Override
public void renameTable(ObjectPath tablePath, String newTableName, boolean
ignoreIfNotExists)
throws TableNotExistException, TableAlreadyExistException,
CatalogException {
+ ObjectPath toPath = new ObjectPath(tablePath.getDatabaseName(),
newTableName);
try {
- icebergCatalog.renameTable(
- toIdentifier(tablePath),
- toIdentifier(new ObjectPath(tablePath.getDatabaseName(),
newTableName)));
+ icebergCatalog.renameTable(toIdentifier(tablePath),
toIdentifier(toPath));
} catch (org.apache.iceberg.exceptions.NoSuchTableException e) {
+ if (canBeView(tablePath)) {
+ try {
+ asViewCatalog.renameView(toIdentifier(tablePath),
toIdentifier(toPath));
Review Comment:
shall we reject target metadata tables? (renaming to `shadow$snapshots`)
--
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]