snuyanzin commented on code in PR #25200: URL: https://github.com/apache/flink/pull/25200#discussion_r1717450763
########## flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/ShowViewsOperation.java: ########## @@ -19,23 +19,125 @@ package org.apache.flink.table.operations; import org.apache.flink.annotation.Internal; +import org.apache.flink.table.api.ValidationException; import org.apache.flink.table.api.internal.TableResultInternal; +import org.apache.flink.table.catalog.Catalog; +import org.apache.flink.table.functions.SqlLikeUtils; + +import java.util.Set; import static org.apache.flink.table.api.internal.TableResultUtils.buildStringArrayResult; +import static org.apache.flink.util.Preconditions.checkNotNull; /** Operation to describe a SHOW VIEWS statement. */ @Internal public class ShowViewsOperation implements ShowOperation { + private final String catalogName; + private final String databaseName; + private final boolean useLike; + private final boolean notLike; + private final String likePattern; + private final String preposition; + + public ShowViewsOperation() { + catalogName = null; + databaseName = null; + useLike = false; + notLike = false; + likePattern = null; + preposition = null; + } + + public ShowViewsOperation(String likePattern, boolean useLike, boolean notLike) { + this.catalogName = null; + this.databaseName = null; + this.useLike = useLike; + this.notLike = notLike; + this.likePattern = + useLike ? checkNotNull(likePattern, "Like pattern must not be null.") : null; + this.preposition = null; + } + + public ShowViewsOperation( + String catalogName, + String databaseName, + String likePattern, + boolean useLike, + boolean notLike, + String preposition) { + this.catalogName = checkNotNull(catalogName, "Catalog name must not be null."); + this.databaseName = checkNotNull(databaseName, "Database name must not be null"); + this.useLike = useLike; + this.notLike = notLike; + this.likePattern = + useLike ? checkNotNull(likePattern, "Like pattern must not be null.") : null; + this.preposition = checkNotNull(preposition, "Preposition must not be null"); + } + + public String getLikePattern() { + return likePattern; + } + + public String getPreposition() { + return preposition; + } + + public boolean isUseLike() { + return useLike; + } + + public boolean isNotLike() { + return notLike; + } + + public String getCatalogName() { + return catalogName; + } + + public String getDatabaseName() { + return databaseName; + } + @Override public String asSummaryString() { + StringBuilder builder = new StringBuilder().append("SHOW VIEWS"); + if (preposition != null) { + builder.append(String.format(" %s %s.%s", preposition, catalogName, databaseName)); + } + if (useLike) { + final String prefix = notLike ? "NOT " : ""; + builder.append(String.format(" %sLIKE '%s'", prefix, likePattern)); + } return "SHOW VIEWS"; Review Comment: great catch, thanks added extra tests covering this for both table and views -- 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