Aitozi commented on code in PR #22179:
URL: https://github.com/apache/flink/pull/22179#discussion_r1154263645


##########
flink-table/flink-sql-parser/src/main/java/org/apache/flink/sql/parser/dql/SqlShowCatalogs.java:
##########
@@ -28,15 +31,61 @@
 
 import java.util.Collections;
 import java.util.List;
+import java.util.Objects;
+
+import static java.util.Objects.requireNonNull;
 
 /** SHOW CATALOGS sql call. */
 public class SqlShowCatalogs extends SqlCall {
 
+    // different like type such as like, ilike
+    protected final SqlLikeType likeType;
+    protected final boolean notLike;
+    protected final SqlCharStringLiteral likeLiteral;
+
     public static final SqlSpecialOperator OPERATOR =
             new SqlSpecialOperator("SHOW CATALOGS", SqlKind.OTHER);
 
-    public SqlShowCatalogs(SqlParserPos pos) {
+    public SqlShowCatalogs(
+            SqlParserPos pos, String likeType, SqlCharStringLiteral 
likeLiteral, boolean notLike) {
         super(pos);
+        if (likeType != null) {
+            this.likeType = SqlLikeType.of(likeType);
+            this.likeLiteral = requireNonNull(likeLiteral, "Like pattern must 
not be null");
+            this.notLike = notLike;
+        } else {
+            this.likeType = null;
+            this.likeLiteral = null;
+            this.notLike = false;
+        }
+    }
+
+    public SqlLikeType getLikeType() {
+        return likeType;
+    }
+
+    public boolean isLike() {
+        return likeType == SqlLikeType.LIKE;
+    }
+
+    public boolean isILike() {
+        return likeType == SqlLikeType.ILIKE;
+    }
+
+    public boolean isWithLike() {
+        return isLike() || isILike();
+    }
+
+    public SqlCharStringLiteral getLikeLiteral() {

Review Comment:
   not used



##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/ShowCatalogsOperation.java:
##########
@@ -19,21 +19,90 @@
 package org.apache.flink.table.operations;
 
 import org.apache.flink.table.api.internal.TableResultInternal;
+import org.apache.flink.table.functions.SqlLikeUtils;
+import org.apache.flink.table.operations.utils.OperationLikeType;
 
+import java.util.Arrays;
+
+import static java.util.Objects.requireNonNull;
 import static 
org.apache.flink.table.api.internal.TableResultUtils.buildStringArrayResult;
 
 /** Operation to describe a SHOW CATALOGS statement. */
 public class ShowCatalogsOperation implements ShowOperation {
 
+    // different like type such as like, ilike
+    private final OperationLikeType likeType;
+    private final boolean notLike;
+    private final String likePattern;
+
+    public ShowCatalogsOperation(String likeType, String likePattern, boolean 
notLike) {
+        if (likeType != null) {
+            this.likeType = OperationLikeType.of(likeType);
+            this.likePattern = requireNonNull(likePattern, "Like pattern must 
not be null");
+            this.notLike = notLike;
+        } else {
+            this.likeType = null;
+            this.likePattern = null;
+            this.notLike = false;
+        }
+    }
+
+    public OperationLikeType getLikeType() {
+        return likeType;
+    }
+
+    public boolean isLike() {
+        return likeType == OperationLikeType.LIKE;
+    }
+
+    public boolean isIlike() {
+        return likeType == OperationLikeType.ILIKE;
+    }
+
+    public boolean isWithLike() {
+        return isLike() || isIlike();
+    }
+
+    public String getLikePattern() {

Review Comment:
   not used



##########
flink-table/flink-sql-parser/src/main/java/org/apache/flink/sql/parser/SqlLikeType.java:
##########
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.sql.parser;
+
+/** Like types utils. */
+public enum SqlLikeType {
+    /** sql like pattern, case sensitive. */
+    LIKE,
+    /** sql like pattern, case insensitive. */
+    ILIKE,
+    /** use regex to match (currently flink not support it). */

Review Comment:
   Maybe we can add this until supported ?



##########
flink-table/flink-sql-parser/src/main/java/org/apache/flink/sql/parser/dql/SqlShowCatalogs.java:
##########
@@ -28,15 +31,61 @@
 
 import java.util.Collections;
 import java.util.List;
+import java.util.Objects;
+
+import static java.util.Objects.requireNonNull;
 
 /** SHOW CATALOGS sql call. */
 public class SqlShowCatalogs extends SqlCall {
 
+    // different like type such as like, ilike
+    protected final SqlLikeType likeType;
+    protected final boolean notLike;
+    protected final SqlCharStringLiteral likeLiteral;
+
     public static final SqlSpecialOperator OPERATOR =
             new SqlSpecialOperator("SHOW CATALOGS", SqlKind.OTHER);
 
-    public SqlShowCatalogs(SqlParserPos pos) {
+    public SqlShowCatalogs(
+            SqlParserPos pos, String likeType, SqlCharStringLiteral 
likeLiteral, boolean notLike) {
         super(pos);
+        if (likeType != null) {
+            this.likeType = SqlLikeType.of(likeType);
+            this.likeLiteral = requireNonNull(likeLiteral, "Like pattern must 
not be null");
+            this.notLike = notLike;
+        } else {
+            this.likeType = null;
+            this.likeLiteral = null;
+            this.notLike = false;
+        }
+    }
+
+    public SqlLikeType getLikeType() {
+        return likeType;
+    }
+
+    public boolean isLike() {
+        return likeType == SqlLikeType.LIKE;
+    }
+
+    public boolean isILike() {
+        return likeType == SqlLikeType.ILIKE;
+    }
+
+    public boolean isWithLike() {
+        return isLike() || isILike();

Review Comment:
   can be replaced by `return likeType != null` and the `isLike` and `isILike` 
can be removed (seems not used by other class)



##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/ShowCatalogsOperation.java:
##########
@@ -19,21 +19,90 @@
 package org.apache.flink.table.operations;
 
 import org.apache.flink.table.api.internal.TableResultInternal;
+import org.apache.flink.table.functions.SqlLikeUtils;
+import org.apache.flink.table.operations.utils.OperationLikeType;
 
+import java.util.Arrays;
+
+import static java.util.Objects.requireNonNull;
 import static 
org.apache.flink.table.api.internal.TableResultUtils.buildStringArrayResult;
 
 /** Operation to describe a SHOW CATALOGS statement. */
 public class ShowCatalogsOperation implements ShowOperation {
 
+    // different like type such as like, ilike
+    private final OperationLikeType likeType;
+    private final boolean notLike;
+    private final String likePattern;
+
+    public ShowCatalogsOperation(String likeType, String likePattern, boolean 
notLike) {
+        if (likeType != null) {
+            this.likeType = OperationLikeType.of(likeType);
+            this.likePattern = requireNonNull(likePattern, "Like pattern must 
not be null");
+            this.notLike = notLike;
+        } else {
+            this.likeType = null;
+            this.likePattern = null;
+            this.notLike = false;
+        }
+    }
+
+    public OperationLikeType getLikeType() {
+        return likeType;
+    }
+
+    public boolean isLike() {

Review Comment:
   the same to `SqlShowCatalogs`.



##########
flink-table/flink-sql-parser/src/main/java/org/apache/flink/sql/parser/SqlLikeType.java:
##########
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.sql.parser;
+
+/** Like types utils. */
+public enum SqlLikeType {
+    /** sql like pattern, case sensitive. */
+    LIKE,
+    /** sql like pattern, case insensitive. */
+    ILIKE,
+    /** use regex to match (currently flink not support it). */

Review Comment:
   BTW, why rlike is not supported in this PR ?  



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