RocMarshal commented on a change in pull request #18386:
URL: https://github.com/apache/flink/pull/18386#discussion_r836080280



##########
File path: 
flink-table/flink-sql-parser/src/main/java/org/apache/flink/sql/parser/dql/SqlShowDatabases.java
##########
@@ -49,8 +70,44 @@ public SqlOperator getOperator() {
         return Collections.EMPTY_LIST;
     }
 
+    public String getCatalogName() {
+        return Objects.isNull(this.catalogName) ? null : 
catalogName.getSimple();
+    }
+
+    public boolean isNotLike() {
+        return notLike;
+    }
+
+    public String getPreposition() {
+        return preposition;
+    }
+
+    public String getLikeSqlPattern() {
+        return Objects.isNull(this.likeLiteral) ? null : 
likeLiteral.getValueAs(String.class);
+    }
+
+    public SqlCharStringLiteral getLikeLiteral() {
+        return likeLiteral;
+    }
+
+    public boolean isWithLike() {
+        return Objects.nonNull(likeLiteral);
+    }
+
     @Override
     public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
-        writer.keyword("SHOW DATABASES");
+        if (this.preposition == null) {
+            writer.keyword("SHOW DATABASES");
+        } else if (catalogName != null) {
+            writer.keyword("SHOW DATABASES " + this.preposition);
+            catalogName.unparse(writer, leftPrec, rightPrec);
+        }
+        if (likeLiteral != null) {
+            if (notLike) {
+                writer.keyword(String.format("NOT LIKE '%s'", 
getLikeSqlPattern()));

Review comment:
       Flink SQL> show databases like ;
   [ERROR] Could not execute SQL statement. Reason:
   org.apache.flink.sql.parser.impl.ParseException: Encountered ";" at line 1, 
column 21.
   Was expecting:
       <QUOTED_STRING> ...
       
   
   Flink SQL> show databases like '';
   Empty set
   




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