diqiu50 commented on code in PR #11189:
URL: https://github.com/apache/gravitino/pull/11189#discussion_r3301991540


##########
flink-connector/flink-common/src/main/java/org/apache/gravitino/flink/connector/catalog/BaseCatalog.java:
##########
@@ -261,16 +338,36 @@ public void renameTable(ObjectPath tablePath, String 
newTableName, boolean ignor
 
     if (catalog().asTableCatalog().tableExists(identifier)) {
       throw new TableAlreadyExistException(
-          catalogName(), ObjectPath.fromString(tablePath.getDatabaseName() + 
newTableName));
+          catalogName(), new ObjectPath(tablePath.getDatabaseName(), 
newTableName));
+    }
+    try {
+      if (catalog().asViewCatalog().viewExists(identifier)) {
+        throw new TableAlreadyExistException(
+            catalogName(), new ObjectPath(tablePath.getDatabaseName(), 
newTableName));
+      }
+    } catch (UnsupportedOperationException ignored) {
+      // catalog does not support views
     }
 
+    CatalogBaseTable existing;
     try {
-      catalog()
-          .asTableCatalog()
-          .alterTable(
-              NameIdentifier.of(tablePath.getDatabaseName(), 
tablePath.getObjectName()),
-              TableChange.rename(newTableName));
-    } catch (NoSuchTableException e) {
+      existing = getTable(tablePath);

Review Comment:
   removed



##########
flink-connector/flink-common/src/main/java/org/apache/gravitino/flink/connector/catalog/BaseCatalog.java:
##########
@@ -244,12 +297,36 @@ public boolean tableExists(ObjectPath tablePath) throws 
CatalogException {
   @Override
   public void dropTable(ObjectPath tablePath, boolean ignoreIfNotExists)
       throws TableNotExistException, CatalogException {
-    boolean dropped =
-        catalog()
-            .asTableCatalog()
-            .dropTable(NameIdentifier.of(tablePath.getDatabaseName(), 
tablePath.getObjectName()));
-    if (!dropped && !ignoreIfNotExists) {
-      throw new TableNotExistException(catalogName(), tablePath);
+    NameIdentifier ident =
+        NameIdentifier.of(tablePath.getDatabaseName(), 
tablePath.getObjectName());
+
+    // Determine kind before dropping to avoid a view being silently missed.
+    CatalogBaseTable existing;
+    try {
+      existing = getTable(tablePath);
+    } catch (TableNotExistException e) {
+      if (!ignoreIfNotExists) {
+        throw e;
+      }
+      return;
+    }

Review Comment:
   fixed



-- 
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]

Reply via email to