wuchong commented on a change in pull request #16723:
URL: https://github.com/apache/flink/pull/16723#discussion_r689235882



##########
File path: flink-table/flink-sql-client/src/test/resources/sql/table.q
##########
@@ -89,6 +89,193 @@ CREATE TABLE `default_catalog`.`default_database`.`orders` (
 
 !ok
 
+# test SHOW COLUMNS

Review comment:
       We should add tests in 
`org.apache.flink.table.api.TableEnvironmentITCase` as well. 
   New syntax shoudn't been tested just by SQL CLI. 

##########
File path: docs/content/docs/dev/table/sql/show.md
##########
@@ -39,6 +39,7 @@ Flink SQL supports the following SHOW statements for now:
 - SHOW FUNCTIONS
 - SHOW MODULES
 - SHOW JARS
+- SHOW COLUMNS

Review comment:
       Put it after `SHOW CREATE TABLE`, because it's more related with SHOW 
CREATE TABLE. 

##########
File path: flink-table/flink-sql-parser/src/main/codegen/data/Parser.tdd
##########
@@ -107,6 +108,7 @@
     "CATALOGS"
     "CHANGELOG_MODE"
     "COMMENT"
+    "COLUMNS"

Review comment:
       Also add it to `nonReservedKeywordsToAdd`. 

##########
File path: 
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/ShowColumnsOperation.java
##########
@@ -0,0 +1,99 @@
+/*
+ * 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.table.operations;
+
+import org.apache.flink.table.catalog.ObjectIdentifier;
+
+/** Show columns from [[catalog.]database.]table. */
+public class ShowColumnsOperation implements ShowOperation {
+
+    private ObjectIdentifier tableIdentifier;
+    private boolean useLike;
+    private boolean notLike;
+    private String likePattern;
+    private String preposition;

Review comment:
       ??

##########
File path: docs/content.zh/docs/dev/table/sql/show.md
##########
@@ -511,4 +547,15 @@ SHOW JARS
 
 <span class="label label-danger">Attention</span> 当前 SHOW JARS 命令只能在 [SQL 
CLI]({{< ref "docs/dev/table/sqlClient" >}}) 中使用。
 
+## SHOW COLUMNS
+
+```sql
+SHOW COLUMNS ( FROM | IN ) <table_name> [ [NOT] LIKE <sql_like_pattern>]
+```
+
+展示给定表的所有列。
+
+**LIKE**
+根据可选的 `LIKE` 语句展示给定表中与 `<sql_like_pattern>` 是否模糊相似的所有列。

Review comment:
       Could you add more examples to explain how to use the LIKE clause? I 
think Hive gives a good example. 

##########
File path: 
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/utils/SQLLikeUtils.java
##########
@@ -0,0 +1,83 @@
+/*
+ * 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.table.operations.utils;
+
+import java.util.regex.Pattern;
+
+/** Utility class for 'like' function in sql like-clause. */
+public enum SQLLikeUtils {

Review comment:
       Would be better to reuse the sql like code. 
   I think you can move `SqlLikeUtils` to package 
`org.apache.flink.table.functions` in `flink-table-api-java` module. 




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