snuyanzin commented on code in PR #25200:
URL: https://github.com/apache/flink/pull/25200#discussion_r1721673717


##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/ShowProceduresOperation.java:
##########
@@ -20,130 +20,83 @@
 
 import org.apache.flink.annotation.Internal;
 import org.apache.flink.table.api.TableException;
-import org.apache.flink.table.api.internal.TableResultInternal;
 import org.apache.flink.table.catalog.Catalog;
 import org.apache.flink.table.catalog.CatalogManager;
 import org.apache.flink.table.catalog.exceptions.DatabaseNotExistException;
-import org.apache.flink.table.functions.SqlLikeUtils;
+import org.apache.flink.table.operations.utils.ShowLikeOperator;
 
 import javax.annotation.Nullable;
 
-import java.util.List;
-
-import static java.util.Objects.requireNonNull;
-import static 
org.apache.flink.table.api.internal.TableResultUtils.buildStringArrayResult;
+import java.util.Collection;
 
 /**
- * Operation to describe a SHOW PROCEDURES [ ( FROM | IN ) 
[catalog_name.]database_name ] [ [NOT]
- * (LIKE | ILIKE) <sql_like_pattern> ] statement.
+ * Operation to describe a SHOW PROCEDURES statement. The full syntax for SHOW 
PROCEDURES is as
+ * followings:
+ *
+ * <pre>{@code
+ * SHOW PROCEDURES [ ( FROM | IN ) [catalog_name.]database_name ] [ [NOT] 
(LIKE | ILIKE)
+ * &lt;sql_like_pattern&gt; ] statement
+ * }</pre>
  */
 @Internal
-public class ShowProceduresOperation implements ExecutableOperation {
-
-    private final @Nullable String catalogName;
+public class ShowProceduresOperation extends AbstractShowOperation {
 
     private final @Nullable String databaseName;
-    private final @Nullable String preposition;
-
-    private final boolean notLike;
-
-    // different like type such as like, ilike
-    private final LikeType likeType;
-
-    @Nullable private final String sqlLikePattern;
-
-    public ShowProceduresOperation(boolean isNotLike, String likeType, String 
sqlLikePattern) {
-        this(null, null, null, isNotLike, likeType, sqlLikePattern);
-    }
 
     public ShowProceduresOperation(
-            @Nullable String preposition,
             @Nullable String catalogName,
             @Nullable String databaseName,
-            boolean notLike,
-            @Nullable String likeType,
-            @Nullable String sqlLikePattern) {
-        this.preposition = preposition;
-        this.catalogName = catalogName;
+            @Nullable String preposition,
+            @Nullable ShowLikeOperator likeOp) {
+        super(catalogName, preposition, likeOp);
         this.databaseName = databaseName;
-
-        if (likeType != null) {
-            this.likeType = LikeType.of(likeType);
-            this.sqlLikePattern = requireNonNull(sqlLikePattern, "Like pattern 
must not be null");
-            this.notLike = notLike;
-        } else {
-            this.likeType = null;
-            this.sqlLikePattern = null;
-            this.notLike = false;
-        }
     }
 
-    public boolean isWithLike() {
-        return likeType != null;
+    public ShowProceduresOperation(@Nullable ShowLikeOperator likeOp) {
+        this(null, null, null, likeOp);
     }
 
     @Override
-    public TableResultInternal execute(Context ctx) {
-        final List<String> procedures;
-        CatalogManager catalogManager = ctx.getCatalogManager();
+    protected Collection<String> retrieveDataForTableResult(Context ctx) {
+        final CatalogManager catalogManager = ctx.getCatalogManager();
+        final String catalogName = 
catalogManager.qualifyCatalog(this.catalogName);
+        final String dbName = 
catalogManager.qualifyDatabase(this.databaseName);
         try {
             if (preposition == null) {
                 // it's to show current_catalog.current_database
-                procedures =
-                        catalogManager
-                                
.getCatalogOrError(catalogManager.getCurrentCatalog())
-                                
.listProcedures(catalogManager.getCurrentDatabase());
+                return catalogManager
+                        .getCatalogOrError(catalogManager.getCurrentCatalog())

Review Comment:
   here it is a special case for these `SHOW` operations.
   We have here `preposition == null` which means that we don't have `IN` or 
`FROM` in our `SHOW` query, so no catalog/database specified. In this case we 
assume that this `SHOW` operation should be done against current 
catalog/database



-- 
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: issues-unsubscr...@flink.apache.org

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

Reply via email to