liyubin117 commented on a change in pull request #18361:
URL: https://github.com/apache/flink/pull/18361#discussion_r812502802
##########
File path:
flink-table/flink-sql-parser/src/test/java/org/apache/flink/sql/parser/FlinkSqlParserImplTest.java
##########
@@ -189,6 +189,28 @@ public void testShowFunctions() {
@Test
public void testShowTables() {
sql("show tables").ok("SHOW TABLES");
+ sql("show tables not like '%'").ok("SHOW TABLES NOT LIKE '%'");
+
+ sql("show tables from db1").ok("SHOW TABLES FROM `DB1`");
+ sql("show tables in db1").ok("SHOW TABLES IN `DB1`");
+
+ sql("show tables from catalog1.db1").ok("SHOW TABLES FROM
`CATALOG1`.`DB1`");
+ sql("show tables in catalog1.db1").ok("SHOW TABLES IN
`CATALOG1`.`DB1`");
+
+ sql("show tables from db1 like '%'").ok("SHOW TABLES FROM `DB1` LIKE
'%'");
+ sql("show tables in db1 like '%'").ok("SHOW TABLES IN `DB1` LIKE '%'");
+
+ sql("show tables from catalog1.db1 like '%'")
+ .ok("SHOW TABLES FROM `CATALOG1`.`DB1` LIKE '%'");
+ sql("show tables in catalog1.db1 like '%'").ok("SHOW TABLES IN
`CATALOG1`.`DB1` LIKE '%'");
+
+ sql("show tables from db1 not like '%'").ok("SHOW TABLES FROM `DB1`
NOT LIKE '%'");
+ sql("show tables in db1 not like '%'").ok("SHOW TABLES IN `DB1` NOT
LIKE '%'");
+
+ sql("show tables from catalog1.db1 not like '%'")
+ .ok("SHOW TABLES FROM `CATALOG1`.`DB1` NOT LIKE '%'");
+ sql("show tables in catalog1.db1 not like '%'")
+ .ok("SHOW TABLES IN `CATALOG1`.`DB1` NOT LIKE '%'");
Review comment:
done
##########
File path:
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/ShowTablesOperation.java
##########
@@ -21,8 +21,83 @@
/** Operation to describe a SHOW TABLES statement. */
public class ShowTablesOperation 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 ShowTablesOperation() {
+ this.catalogName = null;
+ this.databaseName = null;
+ this.likePattern = null;
+ this.useLike = false;
+ this.notLike = false;
+ this.preposition = null;
+ }
+
+ public ShowTablesOperation(String likePattern, boolean useLike, boolean
notLike) {
+ this.catalogName = null;
+ this.databaseName = null;
+ this.likePattern = likePattern;
+ this.useLike = useLike;
+ this.notLike = notLike;
+ this.preposition = null;
+ }
+
+ public ShowTablesOperation(
+ String catalogName,
+ String databaseName,
+ String likePattern,
+ boolean useLike,
+ boolean notLike,
+ String preposition) {
+ this.catalogName = catalogName;
+ this.databaseName = databaseName;
+ this.likePattern = likePattern;
+ this.useLike = useLike;
+ this.notLike = notLike;
Review comment:
done
##########
File path:
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/operations/SqlToOperationConverter.java
##########
@@ -906,7 +906,29 @@ private Operation
convertShowCurrentDatabase(SqlShowCurrentDatabase sqlShowCurre
/** Convert SHOW TABLES statement. */
private Operation convertShowTables(SqlShowTables sqlShowTables) {
- return new ShowTablesOperation();
+ if (sqlShowTables.getPreposition() == null) {
+ return new ShowTablesOperation(
+ sqlShowTables.getLikeSqlPattern(),
+ sqlShowTables.isWithLike(),
+ sqlShowTables.isNotLike());
+ }
+ String[] fullDatabaseName = sqlShowTables.fullDatabaseName();
+ if (fullDatabaseName.length > 2) {
+ throw new ValidationException("show tables from/in identifier
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]