ZhangChaoming commented on a change in pull request #18386: URL: https://github.com/apache/flink/pull/18386#discussion_r834913824
########## 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: This condition is equals to `isWithLike()`. IMO, to check this condition is nessauary. If not, the method `getLikeSqlPattern()` in else code block will return null value. ```java if (isWithLike()) { if (notLike) { writer.keyword(String.format("NOT LIKE '%s'", getLikeSqlPattern())); } else { writer.keyword(String.format("LIKE '%s'", getLikeSqlPattern())); } } ``` -- 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