dawidwys commented on code in PR #23612:
URL: https://github.com/apache/flink/pull/23612#discussion_r1450129925


##########
flink-table/flink-sql-parser/src/main/java/org/apache/flink/sql/parser/dql/SqlShowDatabases.java:
##########
@@ -29,14 +33,64 @@
 import java.util.Collections;
 import java.util.List;
 
-/** SHOW Databases sql call. */
+import static java.util.Objects.requireNonNull;
+
+/**
+ * SHOW Databases sql call. The full syntax for show databases is as 
followings:
+ *
+ * <pre>{@code
+ * SHOW DATABASES [ ( FROM | IN ) catalog_name] [ [NOT] (LIKE | ILIKE)
+ * <sql_like_pattern> ] statement
+ * }</pre>
+ */
 public class SqlShowDatabases extends SqlCall {
 
     public static final SqlSpecialOperator OPERATOR =
             new SqlSpecialOperator("SHOW DATABASES", SqlKind.OTHER);
 
-    public SqlShowDatabases(SqlParserPos pos) {
+    private final String preposition;
+    private final SqlIdentifier catalogName;
+    private final String likeType;
+    private final SqlCharStringLiteral likeLiteral;
+    private final boolean notLike;
+
+    public String[] getCatalog() {
+        return catalogName == null || catalogName.names.isEmpty()
+                ? new String[] {}
+                : catalogName.names.toArray(new String[0]);
+    }
+
+    public SqlShowDatabases(
+            SqlParserPos pos,
+            String preposition,
+            SqlIdentifier catalogName,
+            String likeType,
+            SqlCharStringLiteral likeLiteral,
+            boolean notLike)
+            throws ParseException {
         super(pos);
+        this.preposition = preposition;
+
+        this.catalogName =
+                preposition != null
+                        ? requireNonNull(catalogName, "Catalog name must not 
be null.")
+                        : null;
+        if (this.catalogName != null && this.catalogName.names.size() > 1) {
+            throw new ParseException(
+                    String.format(
+                            "Show databases from/in identifier [ %s ] format 
error, catalog cannot contain dot character.",

Review Comment:
   Given the responses, could you please update the exception to e.g.
   
   ```
   "Show databases from/in identifier [ %s ] format error, catalog must be a 
single part identifier."
   ```



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