JingsongLi commented on a change in pull request #12314:
URL: https://github.com/apache/flink/pull/12314#discussion_r429745539



##########
File path: 
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/CatalogManager.java
##########
@@ -682,20 +682,60 @@ public void alterTable(CatalogBaseTable table, 
ObjectIdentifier objectIdentifier
         * Drops a table in a given fully qualified path.
         *
         * @param objectIdentifier The fully qualified path of the table to 
drop.
-        * @param ignoreIfNotExists If false exception will be thrown if the 
table or database or catalog to be altered
+        * @param ignoreIfNotExists If false exception will be thrown if the 
table to drop
         *                          does not exist.
         */
        public void dropTable(ObjectIdentifier objectIdentifier, boolean 
ignoreIfNotExists) {
-               if (temporaryTables.containsKey(objectIdentifier)) {
-                       throw new ValidationException(String.format(
-                               "Temporary table with identifier '%s' exists. 
Drop it first before removing the permanent table.",
-                               objectIdentifier));
+               dropTableInternal(
+                               objectIdentifier,
+                               table -> table instanceof CatalogTable,
+                               ignoreIfNotExists);
+       }
+
+       /**
+        * Drops a view in a given fully qualified path.
+        *
+        * @param objectIdentifier The fully qualified path of the view to drop.
+        * @param ignoreIfNotExists If false exception will be thrown if the 
view to drop
+        *                          does not exist.
+        */
+       public void dropView(ObjectIdentifier objectIdentifier, boolean 
ignoreIfNotExists) {
+               dropTableInternal(
+                               objectIdentifier,
+                               table -> table instanceof CatalogView,
+                               ignoreIfNotExists);
+       }
+
+       private void dropTableInternal(
+                       ObjectIdentifier objectIdentifier,
+                       Predicate<CatalogBaseTable> filter,
+                       boolean ignoreIfNotExists) {
+               final Optional<TableLookupResult> resultOpt = 
getTable(objectIdentifier);

Review comment:
       Why not just `getPermanentTable`? You can keep previous 
`temporaryTables.containsKey(objectIdentifier)`




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to