You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "snuyanzin (via GitHub)" <gi...@apache.org> on 2024/08/14 13:35:48 UTC
[PR] [FLINK-36050][table] Support enhanced `SHOW VIEW` syntax [flink]
snuyanzin opened a new pull request, #25200:
URL: https://github.com/apache/flink/pull/25200
## What is the purpose of the change
Support enhanced `SHOW VIEWS` syntax like `SHOW VIEWS FROM catalog1.db1 LIKE 't%'`
in a way similar to existing `SHOW TABLES` syntax
## Brief change log
parser was extended
## Verifying this change
catalog_database.q in sql client and sql gateway
+ a number of unit tests
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): ( no)
- The public API, i.e., is any changed class annotated with `@Public(Evolving)`: ( no)
- The serializers: (no)
- The runtime per-record code paths (performance sensitive): ( no)
- Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: ( no)
- The S3 file system connector: (yes)
## Documentation
- Does this pull request introduce a new feature? (yes )
- If yes, how is the feature documented? (docs )
--
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36050][table] Support enhanced `SHOW VIEW` syntax [flink]
Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #25200:
URL: https://github.com/apache/flink/pull/25200#issuecomment-2288779628
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "2af84b098ee9f3c64f7da181fa8da4e8b5935ef9",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "2af84b098ee9f3c64f7da181fa8da4e8b5935ef9",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 2af84b098ee9f3c64f7da181fa8da4e8b5935ef9 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run azure` re-run the last Azure build
</details>
--
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36050][table] Support enhanced `SHOW VIEW` syntax [flink]
Posted by "twalthr (via GitHub)" <gi...@apache.org>.
twalthr commented on code in PR #25200:
URL: https://github.com/apache/flink/pull/25200#discussion_r1722860053
##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/operations/converters/SqlShowFunctionsConverter.java:
##########
@@ -19,50 +19,49 @@
package org.apache.flink.table.planner.operations.converters;
import org.apache.flink.sql.parser.dql.SqlShowFunctions;
-import org.apache.flink.table.api.ValidationException;
-import org.apache.flink.table.catalog.CatalogManager;
import org.apache.flink.table.operations.Operation;
import org.apache.flink.table.operations.ShowFunctionsOperation;
+import org.apache.flink.table.operations.ShowFunctionsOperation.FunctionScope;
+import org.apache.flink.table.operations.utils.ShowLikeOperator;
/** A converter for {@link SqlShowFunctions}. */
-public class SqlShowFunctionsConverter implements SqlNodeConverter<SqlShowFunctions> {
+public class SqlShowFunctionsConverter extends AbstractSqlShowConverter<SqlShowFunctions> {
+
+ @Override
+ public Operation getOperationWithoutPrep(
+ String qualifiedCatalogName,
Review Comment:
rename back to `catalogName` and `databaseName` because `getOperation` also just calls them this way.
##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/operations/converters/SqlShowFunctionsConverter.java:
##########
@@ -19,50 +19,49 @@
package org.apache.flink.table.planner.operations.converters;
import org.apache.flink.sql.parser.dql.SqlShowFunctions;
-import org.apache.flink.table.api.ValidationException;
-import org.apache.flink.table.catalog.CatalogManager;
import org.apache.flink.table.operations.Operation;
import org.apache.flink.table.operations.ShowFunctionsOperation;
+import org.apache.flink.table.operations.ShowFunctionsOperation.FunctionScope;
+import org.apache.flink.table.operations.utils.ShowLikeOperator;
/** A converter for {@link SqlShowFunctions}. */
-public class SqlShowFunctionsConverter implements SqlNodeConverter<SqlShowFunctions> {
+public class SqlShowFunctionsConverter extends AbstractSqlShowConverter<SqlShowFunctions> {
+
+ @Override
+ public Operation getOperationWithoutPrep(
+ String qualifiedCatalogName,
+ String qualifiedDatabaseName,
+ SqlShowFunctions sqlShowFunctions,
+ ShowLikeOperator likeOp) {
+ final FunctionScope functionScope = getFunctionScope(sqlShowFunctions);
+ return new ShowFunctionsOperation(
+ functionScope, qualifiedCatalogName, qualifiedDatabaseName, likeOp);
+ }
+
+ @Override
+ public Operation getOperation(
+ SqlShowFunctions sqlShowFunctions,
+ String catalogName,
+ String databaseName,
+ String prep,
+ ShowLikeOperator likeOp) {
+ final FunctionScope functionScope = getFunctionScope(sqlShowFunctions);
+ return new ShowFunctionsOperation(functionScope, prep, catalogName, databaseName, likeOp);
+ }
@Override
public Operation convertSqlNode(SqlShowFunctions sqlShowFunctions, ConvertContext context) {
- ShowFunctionsOperation.FunctionScope functionScope =
- sqlShowFunctions.requireUser()
- ? ShowFunctionsOperation.FunctionScope.USER
- : ShowFunctionsOperation.FunctionScope.ALL;
+ return convertShowOperation(sqlShowFunctions, context);
+ }
- if (sqlShowFunctions.getPreposition() == null) {
- return new ShowFunctionsOperation(
- functionScope,
- sqlShowFunctions.getLikeType(),
- sqlShowFunctions.getLikeSqlPattern(),
- sqlShowFunctions.isNotLike());
- }
+ private static FunctionScope getFunctionScope(SqlShowFunctions sqlShowFunctions) {
+ return sqlShowFunctions.requireUser() ? FunctionScope.USER : FunctionScope.ALL;
+ }
- String[] fullDatabaseName = sqlShowFunctions.fullDatabaseName();
- if (fullDatabaseName.length > 2) {
- throw new ValidationException(
- String.format(
- "Show functions from/in identifier [ %s ] format error, it should be [catalog_name.]database_name.",
- String.join(".", fullDatabaseName)));
- }
- CatalogManager catalogManager = context.getCatalogManager();
- String catalogName =
- (fullDatabaseName.length == 1)
- ? catalogManager.getCurrentCatalog()
- : fullDatabaseName[0];
- String databaseName =
- (fullDatabaseName.length == 1) ? fullDatabaseName[0] : fullDatabaseName[1];
- return new ShowFunctionsOperation(
- functionScope,
- sqlShowFunctions.getPreposition(),
- catalogName,
- databaseName,
- sqlShowFunctions.getLikeType(),
- sqlShowFunctions.getLikeSqlPattern(),
- sqlShowFunctions.isNotLike());
+ @Override
+ protected boolean skipQualifyingDefaultCatalogAndDatabase() {
+ // It should be supported to list functions with unset catalog
+ // for more info FLINhK-33093
Review Comment:
nit: typo
--
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36050][table] Support enhanced `SHOW VIEW` syntax [flink]
Posted by "jnh5y (via GitHub)" <gi...@apache.org>.
jnh5y commented on code in PR #25200:
URL: https://github.com/apache/flink/pull/25200#discussion_r1717244214
##########
docs/content.zh/docs/dev/table/sql/show.md:
##########
@@ -913,10 +913,17 @@ SHOW PROCEDURES [ ( FROM | IN ) [catalog_name.]database_name ] [ [NOT] (LIKE | I
## SHOW VIEWS
```sql
-SHOW VIEWS
+SHOW VIEWS [ ( FROM | IN ) [catalog_name.]database_name ] [ [NOT] LIKE <sql_like_pattern> ]
```
-展示当前 catalog 和当前 database 中所有的视图。
+Show all views for an optionally specified database. If no database is specified then the views are returned from the current database. Additionally, the output of this statement may be filtered by an optional matching pattern.
+
+**LIKE**
+Show all views with given view name and optional `LIKE` clause, whose name is whether similar to the `<sql_like_pattern>`.
+
+The syntax of sql pattern in `LIKE` clause is the same as that of `MySQL` dialect.
+* `%` matches any number of characters, even zero characters, `\%` matches one `%` character.
+* `_` matches exactly one character, `\_` matches one `_` character.
Review Comment:
Do we want to provide examples? Or is it similar enough to SHOW TABLES that it'd be redundant?
--
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36050][table] Support enhanced `SHOW VIEW` syntax [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #25200:
URL: https://github.com/apache/flink/pull/25200#discussion_r1721749631
##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/ShowProceduresOperation.java:
##########
@@ -65,7 +65,7 @@ protected Collection<String> retrieveDataForTableResult(Context ctx) {
if (preposition == null) {
// it's to show current_catalog.current_database
return catalogManager
- .getCatalogOrError(catalogManager.getCurrentCatalog())
+ .getCatalogOrThrowException(catalogManager.getCurrentCatalog())
Review Comment:
here it is a case with `preposition == null`
i.e. when no catalog or database was specified e.g.
```sql
SHOW PROCEDURES
```
in this case we need to use current catalog and database.
In theory we could precalculate it on converters level and then here use only `catalogName`, `databaseName`
--
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36050][table] Support enhanced `SHOW VIEW` syntax [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin closed pull request #25200: [FLINK-36050][table] Support enhanced `SHOW VIEW` syntax
URL: https://github.com/apache/flink/pull/25200
--
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36050][table] Support enhanced `SHOW VIEW` syntax [flink]
Posted by "twalthr (via GitHub)" <gi...@apache.org>.
twalthr commented on code in PR #25200:
URL: https://github.com/apache/flink/pull/25200#discussion_r1721523945
##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/ShowDatabasesOperation.java:
##########
@@ -19,83 +19,54 @@
package org.apache.flink.table.operations;
import org.apache.flink.annotation.Internal;
-import org.apache.flink.table.api.internal.TableResultInternal;
-import org.apache.flink.table.functions.SqlLikeUtils;
+import org.apache.flink.table.catalog.CatalogManager;
+import org.apache.flink.table.operations.utils.ShowLikeOperator;
-import java.util.stream.Stream;
+import javax.annotation.Nullable;
-import static java.util.Objects.requireNonNull;
-import static org.apache.flink.table.api.internal.TableResultUtils.buildStringArrayResult;
+import java.util.Collection;
-/** Operation to describe a SHOW DATABASES statement. */
+/**
+ * Operation to describe a SHOW DATABASES statement. The full syntax for SHOW DATABASES is as
+ * followings:
+ *
+ * <pre>{@code
+ * SHOW DATABASES [ ( FROM | IN ) catalog_name] [ [NOT] (LIKE | ILIKE) <sql_like_pattern> ]
+ * }</pre>
+ */
@Internal
-public class ShowDatabasesOperation implements ShowOperation {
-
- private final String catalogName;
- private final LikeType likeType;
- private final String likePattern;
- private final boolean notLike;
+public class ShowDatabasesOperation extends AbstractShowOperation {
- public ShowDatabasesOperation() {
- // "SHOW DATABASES" command with all options being default
- this(null, null, null, false);
+ public ShowDatabasesOperation(
+ @Nullable String catalogName,
+ @Nullable String preposition,
+ @Nullable ShowLikeOperator likeOp) {
+ super(catalogName, preposition, likeOp);
}
- public ShowDatabasesOperation(String likeType, String likePattern, boolean notLike) {
- this(null, likeType, likePattern, notLike);
+ public ShowDatabasesOperation(ShowLikeOperator likeOp) {
+ this(null, null, likeOp);
}
- public ShowDatabasesOperation(
- String catalogName, String likeType, String likePattern, boolean notLike) {
- this.catalogName = catalogName;
- if (likeType != null) {
- this.likeType = LikeType.of(likeType);
- this.likePattern = requireNonNull(likePattern, "Like pattern must not be null");
- this.notLike = notLike;
- } else {
- this.likeType = null;
- this.likePattern = null;
- this.notLike = false;
- }
+ public ShowDatabasesOperation() {
+ this(null, null, null);
}
@Override
- public String asSummaryString() {
- StringBuilder builder = new StringBuilder();
- builder.append("SHOW DATABASES");
- if (catalogName != null) {
- builder.append(String.format(" FROM/IN %s", catalogName));
- }
- if (likeType != null) {
- if (notLike) {
- builder.append(String.format(" NOT %s '%s'", likeType.name(), likePattern));
- } else {
- builder.append(String.format(" %s '%s'", likeType.name(), likePattern));
- }
- }
- return builder.toString();
+ protected Collection<String> retrieveDataForTableResult(Context ctx) {
+ final CatalogManager catalogManager = ctx.getCatalogManager();
+ final String catalogName = catalogManager.qualifyCatalog(this.catalogName);
+ String cName = catalogName == null ? catalogManager.getCurrentCatalog() : catalogName;
Review Comment:
`catalogName` can never be null at this location. that is the core assumption of `qualifyCatalog`
##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/ShowProceduresOperation.java:
##########
@@ -20,130 +20,83 @@
import org.apache.flink.annotation.Internal;
import org.apache.flink.table.api.TableException;
-import org.apache.flink.table.api.internal.TableResultInternal;
import org.apache.flink.table.catalog.Catalog;
import org.apache.flink.table.catalog.CatalogManager;
import org.apache.flink.table.catalog.exceptions.DatabaseNotExistException;
-import org.apache.flink.table.functions.SqlLikeUtils;
+import org.apache.flink.table.operations.utils.ShowLikeOperator;
import javax.annotation.Nullable;
-import java.util.List;
-
-import static java.util.Objects.requireNonNull;
-import static org.apache.flink.table.api.internal.TableResultUtils.buildStringArrayResult;
+import java.util.Collection;
/**
- * Operation to describe a SHOW PROCEDURES [ ( FROM | IN ) [catalog_name.]database_name ] [ [NOT]
- * (LIKE | ILIKE) <sql_like_pattern> ] statement.
+ * Operation to describe a SHOW PROCEDURES statement. The full syntax for SHOW PROCEDURES is as
+ * followings:
+ *
+ * <pre>{@code
+ * SHOW PROCEDURES [ ( FROM | IN ) [catalog_name.]database_name ] [ [NOT] (LIKE | ILIKE)
+ * <sql_like_pattern> ] statement
+ * }</pre>
*/
@Internal
-public class ShowProceduresOperation implements ExecutableOperation {
-
- private final @Nullable String catalogName;
+public class ShowProceduresOperation extends AbstractShowOperation {
private final @Nullable String databaseName;
- private final @Nullable String preposition;
-
- private final boolean notLike;
-
- // different like type such as like, ilike
- private final LikeType likeType;
-
- @Nullable private final String sqlLikePattern;
-
- public ShowProceduresOperation(boolean isNotLike, String likeType, String sqlLikePattern) {
- this(null, null, null, isNotLike, likeType, sqlLikePattern);
- }
public ShowProceduresOperation(
- @Nullable String preposition,
@Nullable String catalogName,
@Nullable String databaseName,
- boolean notLike,
- @Nullable String likeType,
- @Nullable String sqlLikePattern) {
- this.preposition = preposition;
- this.catalogName = catalogName;
+ @Nullable String preposition,
+ @Nullable ShowLikeOperator likeOp) {
+ super(catalogName, preposition, likeOp);
this.databaseName = databaseName;
-
- if (likeType != null) {
- this.likeType = LikeType.of(likeType);
- this.sqlLikePattern = requireNonNull(sqlLikePattern, "Like pattern must not be null");
- this.notLike = notLike;
- } else {
- this.likeType = null;
- this.sqlLikePattern = null;
- this.notLike = false;
- }
}
- public boolean isWithLike() {
- return likeType != null;
+ public ShowProceduresOperation(@Nullable ShowLikeOperator likeOp) {
+ this(null, null, null, likeOp);
}
@Override
- public TableResultInternal execute(Context ctx) {
- final List<String> procedures;
- CatalogManager catalogManager = ctx.getCatalogManager();
+ protected Collection<String> retrieveDataForTableResult(Context ctx) {
+ final CatalogManager catalogManager = ctx.getCatalogManager();
+ final String catalogName = catalogManager.qualifyCatalog(this.catalogName);
+ final String dbName = catalogManager.qualifyDatabase(this.databaseName);
try {
if (preposition == null) {
// it's to show current_catalog.current_database
- procedures =
- catalogManager
- .getCatalogOrError(catalogManager.getCurrentCatalog())
- .listProcedures(catalogManager.getCurrentDatabase());
+ return catalogManager
+ .getCatalogOrError(catalogManager.getCurrentCatalog())
Review Comment:
calls to `getCurrentCatalog()` and `getCurrentDatabase()` should not be required anymore?
##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/operations/converters/SqlShowViewsConverter.java:
##########
@@ -0,0 +1,52 @@
+/*
+ * 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.planner.operations.converters;
+
+import org.apache.flink.sql.parser.dql.SqlShowViews;
+import org.apache.flink.table.operations.Operation;
+import org.apache.flink.table.operations.ShowViewsOperation;
+import org.apache.flink.table.operations.utils.ShowLikeOperator;
+
+public class SqlShowViewsConverter extends AbstractSqlShowConverter<SqlShowViews> {
+ @Override
+ public Operation getOperationWithoutPrep(SqlShowViews sqlShowCall, ShowLikeOperator likeOp) {
+ return new ShowViewsOperation(likeOp);
+ }
+
+ @Override
+ public Operation getOperation(
+ SqlShowViews sqlShowCall,
+ String catalogName,
+ String databaseName,
+ String prep,
+ ShowLikeOperator likeOp) {
+ return new ShowViewsOperation(catalogName, databaseName, prep, likeOp);
+ }
+
+ @Override
+ public Operation convertSqlNode(SqlShowViews sqlShowViews, ConvertContext context) {
+ return convertShowOperation(
+ sqlShowViews,
+ sqlIdentifierNameList ->
+ String.format(
+ "show views from/in identifier [ %s ] format error",
Review Comment:
can we also deduplicate this code? isn't it always parameterized like "show XXXX from/in identifier [ %s ] format error"
##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/CatalogManager.java:
##########
@@ -951,40 +951,29 @@ private boolean permanentDatabaseExists(String catalogName, String databaseName)
*/
public ObjectIdentifier qualifyIdentifier(UnresolvedIdentifier identifier) {
return ObjectIdentifier.of(
- identifier
- .getCatalogName()
- .orElseGet(
- () -> {
- final String currentCatalog = getCurrentCatalog();
- if (StringUtils.isNullOrWhitespaceOnly(currentCatalog)) {
- throw new ValidationException(
- "A current catalog has not been set. Please use a"
- + " fully qualified identifier (such as"
- + " 'my_catalog.my_database.my_table') or"
- + " set a current catalog using"
- + " 'USE CATALOG my_catalog'.");
- }
- return currentCatalog;
- }),
+ identifier.getCatalogName().orElseGet(() -> validateCatalog(getCurrentCatalog())),
Review Comment:
we can slightly simplify the logic here:
```
qualifyCatalog(identifier.getCatalogName().orElse(null)),
qualifyDatabase(identifier.getDatabaseName().orElse(null)),
```
And validateCatalog/Database is not required:
```
public String qualifyCatalog(@Nullable String catalogName) {
if (!StringUtils.isNullOrWhitespaceOnly(catalogName)) {
return catalogName;
}
final String currentCatalog = getCurrentCatalog();
if (StringUtils.isNullOrWhitespaceOnly(currentCatalog)) {
throw new ValidationException(
"A current catalog has not been set. Please use a"
+ " fully qualified identifier (such as"
+ " 'my_catalog.my_database.my_table') or"
+ " set a current catalog using"
+ " 'USE CATALOG my_catalog'.");
}
return currentCatalog;
}
```
the reason why I'm suggesting this is because CatalogManager is complex enough and it is not obivous what the difference is between qualify and validate method.
##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/operations/converters/AbstractSqlShowConverter.java:
##########
@@ -0,0 +1,73 @@
+/*
+ * 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.planner.operations.converters;
+
+import org.apache.flink.sql.parser.dql.SqlShowCall;
+import org.apache.flink.table.api.ValidationException;
+import org.apache.flink.table.catalog.CatalogManager;
+import org.apache.flink.table.operations.Operation;
+import org.apache.flink.table.operations.utils.LikeType;
+import org.apache.flink.table.operations.utils.ShowLikeOperator;
+
+import java.util.List;
+import java.util.function.Function;
+
+public abstract class AbstractSqlShowConverter<T extends SqlShowCall>
+ implements SqlNodeConverter<T> {
+
+ protected Operation convertShowOperation(
+ T sqlShowCall, Function<List<String>, String> msg, ConvertContext context) {
+ final ShowLikeOperator likeOp = getLikeOp(sqlShowCall);
+ if (sqlShowCall.getPreposition() == null) {
+ return getOperationWithoutPrep(sqlShowCall, likeOp);
+ }
+ List<String> fullDatabaseName = sqlShowCall.getSqlIdentifierNameList();
+ if (fullDatabaseName.size() > 2) {
+ throw new ValidationException(msg.apply(fullDatabaseName));
+ }
+ CatalogManager catalogManager = context.getCatalogManager();
+ String catalogName =
+ fullDatabaseName.size() == 1
+ ? catalogManager.getCurrentCatalog()
Review Comment:
here `null` could enter the flow again. and `getOperation` is not marked as `@Nullable` in parameters
--
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36050][table] Support enhanced `SHOW VIEW` syntax [flink]
Posted by "twalthr (via GitHub)" <gi...@apache.org>.
twalthr commented on code in PR #25200:
URL: https://github.com/apache/flink/pull/25200#discussion_r1721680697
##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/ShowProceduresOperation.java:
##########
@@ -65,7 +65,7 @@ protected Collection<String> retrieveDataForTableResult(Context ctx) {
if (preposition == null) {
// it's to show current_catalog.current_database
return catalogManager
- .getCatalogOrError(catalogManager.getCurrentCatalog())
+ .getCatalogOrThrowException(catalogManager.getCurrentCatalog())
Review Comment:
there should be no call in this class to `catalogManager.getCurrentCatalog()`. Maybe I'm missing some context?
--
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36050][table] Support enhanced `SHOW VIEW` syntax [flink]
Posted by "jnh5y (via GitHub)" <gi...@apache.org>.
jnh5y commented on code in PR #25200:
URL: https://github.com/apache/flink/pull/25200#discussion_r1717551998
##########
docs/content.zh/docs/dev/table/sql/show.md:
##########
@@ -913,10 +913,17 @@ SHOW PROCEDURES [ ( FROM | IN ) [catalog_name.]database_name ] [ [NOT] (LIKE | I
## SHOW VIEWS
```sql
-SHOW VIEWS
+SHOW VIEWS [ ( FROM | IN ) [catalog_name.]database_name ] [ [NOT] LIKE <sql_like_pattern> ]
```
-展示当前 catalog 和当前 database 中所有的视图。
+Show all views for an optionally specified database. If no database is specified then the views are returned from the current database. Additionally, the output of this statement may be filtered by an optional matching pattern.
+
+**LIKE**
+Show all views with given view name and optional `LIKE` clause, whose name is whether similar to the `<sql_like_pattern>`.
+
+The syntax of sql pattern in `LIKE` clause is the same as that of `MySQL` dialect.
+* `%` matches any number of characters, even zero characters, `\%` matches one `%` character.
+* `_` matches exactly one character, `\_` matches one `_` character.
Review Comment:
Yeah, maybe that is obvious? Not sure how pedantic to be in docs.
--
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36050][table] Support enhanced `SHOW VIEW` syntax [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #25200:
URL: https://github.com/apache/flink/pull/25200#discussion_r1716954372
##########
flink-table/flink-sql-parser/src/main/java/org/apache/flink/sql/parser/dql/SqlShowTables.java:
##########
@@ -101,10 +101,8 @@ public List<SqlNode> getOperandList() {
: Collections.singletonList(databaseName);
}
- public String[] fullDatabaseName() {
- return Objects.isNull(this.databaseName)
- ? new String[] {}
Review Comment:
probably it's better to reuse lists rather than create arrays per call
--
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36050][table] Support enhanced `SHOW VIEW` syntax [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #25200:
URL: https://github.com/apache/flink/pull/25200#discussion_r1717251475
##########
docs/content.zh/docs/dev/table/sql/show.md:
##########
@@ -913,10 +913,17 @@ SHOW PROCEDURES [ ( FROM | IN ) [catalog_name.]database_name ] [ [NOT] (LIKE | I
## SHOW VIEWS
```sql
-SHOW VIEWS
+SHOW VIEWS [ ( FROM | IN ) [catalog_name.]database_name ] [ [NOT] LIKE <sql_like_pattern> ]
```
-展示当前 catalog 和当前 database 中所有的视图。
+Show all views for an optionally specified database. If no database is specified then the views are returned from the current database. Additionally, the output of this statement may be filtered by an optional matching pattern.
+
+**LIKE**
+Show all views with given view name and optional `LIKE` clause, whose name is whether similar to the `<sql_like_pattern>`.
+
+The syntax of sql pattern in `LIKE` clause is the same as that of `MySQL` dialect.
+* `%` matches any number of characters, even zero characters, `\%` matches one `%` character.
+* `_` matches exactly one character, `\_` matches one `_` character.
Review Comment:
>Or is it similar enough to SHOW TABLES that it'd be redundant?
yep, I had exactly this thought, may be we can explicitly say that `SHOW TABLES` examples could be also used as examples for `SHOW 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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36050][table] Support enhanced `SHOW VIEW` syntax [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #25200:
URL: https://github.com/apache/flink/pull/25200#discussion_r1721961659
##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/ShowProceduresOperation.java:
##########
@@ -65,7 +65,7 @@ protected Collection<String> retrieveDataForTableResult(Context ctx) {
if (preposition == null) {
// it's to show current_catalog.current_database
return catalogManager
- .getCatalogOrError(catalogManager.getCurrentCatalog())
+ .getCatalogOrThrowException(catalogManager.getCurrentCatalog())
Review Comment:
updated, now there is no `getCurrentCatalog`/`getCurrentDatabase` calls in operations
--
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36050][table] Support enhanced `SHOW VIEW` syntax [flink]
Posted by "jnh5y (via GitHub)" <gi...@apache.org>.
jnh5y commented on PR #25200:
URL: https://github.com/apache/flink/pull/25200#issuecomment-2289317826
From a read through, just found the one issue and asked the one question. Overall, this looks good and is consistent with https://github.com/apache/flink/pull/18361
--
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36050][table] Support enhanced `SHOW VIEW` syntax [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #25200:
URL: https://github.com/apache/flink/pull/25200#discussion_r1721673717
##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/ShowProceduresOperation.java:
##########
@@ -20,130 +20,83 @@
import org.apache.flink.annotation.Internal;
import org.apache.flink.table.api.TableException;
-import org.apache.flink.table.api.internal.TableResultInternal;
import org.apache.flink.table.catalog.Catalog;
import org.apache.flink.table.catalog.CatalogManager;
import org.apache.flink.table.catalog.exceptions.DatabaseNotExistException;
-import org.apache.flink.table.functions.SqlLikeUtils;
+import org.apache.flink.table.operations.utils.ShowLikeOperator;
import javax.annotation.Nullable;
-import java.util.List;
-
-import static java.util.Objects.requireNonNull;
-import static org.apache.flink.table.api.internal.TableResultUtils.buildStringArrayResult;
+import java.util.Collection;
/**
- * Operation to describe a SHOW PROCEDURES [ ( FROM | IN ) [catalog_name.]database_name ] [ [NOT]
- * (LIKE | ILIKE) <sql_like_pattern> ] statement.
+ * Operation to describe a SHOW PROCEDURES statement. The full syntax for SHOW PROCEDURES is as
+ * followings:
+ *
+ * <pre>{@code
+ * SHOW PROCEDURES [ ( FROM | IN ) [catalog_name.]database_name ] [ [NOT] (LIKE | ILIKE)
+ * <sql_like_pattern> ] statement
+ * }</pre>
*/
@Internal
-public class ShowProceduresOperation implements ExecutableOperation {
-
- private final @Nullable String catalogName;
+public class ShowProceduresOperation extends AbstractShowOperation {
private final @Nullable String databaseName;
- private final @Nullable String preposition;
-
- private final boolean notLike;
-
- // different like type such as like, ilike
- private final LikeType likeType;
-
- @Nullable private final String sqlLikePattern;
-
- public ShowProceduresOperation(boolean isNotLike, String likeType, String sqlLikePattern) {
- this(null, null, null, isNotLike, likeType, sqlLikePattern);
- }
public ShowProceduresOperation(
- @Nullable String preposition,
@Nullable String catalogName,
@Nullable String databaseName,
- boolean notLike,
- @Nullable String likeType,
- @Nullable String sqlLikePattern) {
- this.preposition = preposition;
- this.catalogName = catalogName;
+ @Nullable String preposition,
+ @Nullable ShowLikeOperator likeOp) {
+ super(catalogName, preposition, likeOp);
this.databaseName = databaseName;
-
- if (likeType != null) {
- this.likeType = LikeType.of(likeType);
- this.sqlLikePattern = requireNonNull(sqlLikePattern, "Like pattern must not be null");
- this.notLike = notLike;
- } else {
- this.likeType = null;
- this.sqlLikePattern = null;
- this.notLike = false;
- }
}
- public boolean isWithLike() {
- return likeType != null;
+ public ShowProceduresOperation(@Nullable ShowLikeOperator likeOp) {
+ this(null, null, null, likeOp);
}
@Override
- public TableResultInternal execute(Context ctx) {
- final List<String> procedures;
- CatalogManager catalogManager = ctx.getCatalogManager();
+ protected Collection<String> retrieveDataForTableResult(Context ctx) {
+ final CatalogManager catalogManager = ctx.getCatalogManager();
+ final String catalogName = catalogManager.qualifyCatalog(this.catalogName);
+ final String dbName = catalogManager.qualifyDatabase(this.databaseName);
try {
if (preposition == null) {
// it's to show current_catalog.current_database
- procedures =
- catalogManager
- .getCatalogOrError(catalogManager.getCurrentCatalog())
- .listProcedures(catalogManager.getCurrentDatabase());
+ return catalogManager
+ .getCatalogOrError(catalogManager.getCurrentCatalog())
Review Comment:
here it is a special case for these `SHOW` operations.
We have here `preposition == null` which means that we don't have `IN` or `FROM` in our `SHOW` query, so no catalog/database specified. In this case we assume that this `SHOW` operation should be done against current catalog/database
--
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36050][table] Support enhanced `SHOW VIEW` syntax [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #25200:
URL: https://github.com/apache/flink/pull/25200#discussion_r1721681790
##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/operations/converters/AbstractSqlShowConverter.java:
##########
@@ -0,0 +1,73 @@
+/*
+ * 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.planner.operations.converters;
+
+import org.apache.flink.sql.parser.dql.SqlShowCall;
+import org.apache.flink.table.api.ValidationException;
+import org.apache.flink.table.catalog.CatalogManager;
+import org.apache.flink.table.operations.Operation;
+import org.apache.flink.table.operations.utils.LikeType;
+import org.apache.flink.table.operations.utils.ShowLikeOperator;
+
+import java.util.List;
+import java.util.function.Function;
+
+public abstract class AbstractSqlShowConverter<T extends SqlShowCall>
+ implements SqlNodeConverter<T> {
+
+ protected Operation convertShowOperation(
+ T sqlShowCall, Function<List<String>, String> msg, ConvertContext context) {
+ final ShowLikeOperator likeOp = getLikeOp(sqlShowCall);
+ if (sqlShowCall.getPreposition() == null) {
+ return getOperationWithoutPrep(sqlShowCall, likeOp);
+ }
+ List<String> fullDatabaseName = sqlShowCall.getSqlIdentifierNameList();
+ if (fullDatabaseName.size() > 2) {
+ throw new ValidationException(msg.apply(fullDatabaseName));
+ }
+ CatalogManager catalogManager = context.getCatalogManager();
+ String catalogName =
+ fullDatabaseName.size() == 1
+ ? catalogManager.getCurrentCatalog()
Review Comment:
yep, depending on case catalog name and database name could be `null`, marked `@Nullable` in `getOperation`
example of such case
```sql
SHOW TABLES
```
here neither catalog nor database is specified and both will be `null`, then in `Operation` there will be `getCurrentCatalog()`/`getCurrentDatabase()` used
--
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36050][table] Support enhanced `SHOW VIEW` syntax [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36050][table] Support enhanced `SHOW VIEW` syntax [flink]
Posted by "jnh5y (via GitHub)" <gi...@apache.org>.
jnh5y commented on code in PR #25200:
URL: https://github.com/apache/flink/pull/25200#discussion_r1717264997
##########
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:
Ok, I think you want to return `builder.build()` instead of just `SHOW VIEWS`.
Is there a test that can be added to catch this?
--
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36050][table] Support enhanced `SHOW VIEW` syntax [flink]
Posted by "jnh5y (via GitHub)" <gi...@apache.org>.
jnh5y commented on code in PR #25200:
URL: https://github.com/apache/flink/pull/25200#discussion_r1717550570
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/operations/SqlOtherOperationConverterTest.java:
##########
@@ -222,26 +226,30 @@ void testShowViews() {
Operation operation = parse(sql);
assertThat(operation).isInstanceOf(ShowViewsOperation.class);
- ShowViewsOperation showTablesOperation = (ShowViewsOperation) operation;
Review Comment:
Nice! I missed this typo... Very natural given that one should be using the other PR to make this one!
--
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36050][table] Support enhanced `SHOW VIEW` syntax [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #25200:
URL: https://github.com/apache/flink/pull/25200#discussion_r1721682664
##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/operations/converters/SqlShowViewsConverter.java:
##########
@@ -0,0 +1,52 @@
+/*
+ * 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.planner.operations.converters;
+
+import org.apache.flink.sql.parser.dql.SqlShowViews;
+import org.apache.flink.table.operations.Operation;
+import org.apache.flink.table.operations.ShowViewsOperation;
+import org.apache.flink.table.operations.utils.ShowLikeOperator;
+
+public class SqlShowViewsConverter extends AbstractSqlShowConverter<SqlShowViews> {
+ @Override
+ public Operation getOperationWithoutPrep(SqlShowViews sqlShowCall, ShowLikeOperator likeOp) {
+ return new ShowViewsOperation(likeOp);
+ }
+
+ @Override
+ public Operation getOperation(
+ SqlShowViews sqlShowCall,
+ String catalogName,
+ String databaseName,
+ String prep,
+ ShowLikeOperator likeOp) {
+ return new ShowViewsOperation(catalogName, databaseName, prep, likeOp);
+ }
+
+ @Override
+ public Operation convertSqlNode(SqlShowViews sqlShowViews, ConvertContext context) {
+ return convertShowOperation(
+ sqlShowViews,
+ sqlIdentifierNameList ->
+ String.format(
+ "show views from/in identifier [ %s ] format error",
Review Comment:
done
--
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org