Skip to content

Commit 5128fe8

Browse files
LadyForestzhaoxing
authored andcommitted
[FLINK-16384][table][sql-client] Improve implementation of 'SHOW CREATE TABLE' statement.
This commit tries to 1. resolve the conflicts 2. revert the changes made on old planner 3. apply spotless formatting 4. fix DDL missing `TEMPORARY` keyword for temporary table 5. display table's full object path as catalog.db.table 6. support displaying the expanded query for view 7. add view test in CatalogTableITCase, and adapt sql client test to the new test framework 8. adapt docs This closes apache#13011
1 parent 6a2b04b commit 5128fe8

File tree

12 files changed

+2
-143
lines changed

12 files changed

+2
-143
lines changed

docs/dev/table/hive/hive_dialect.md

Whitespace-only changes.

docs/dev/table/hive/hive_dialect.zh.md

Whitespace-only changes.

docs/dev/table/sql/show.md

Whitespace-only changes.

docs/dev/table/sql/show.zh.md

Whitespace-only changes.

flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/SqlCommandParser.java

Whitespace-only changes.

flink-table/flink-sql-client/src/test/java/org/apache/flink/table/client/cli/SqlCommandParserTest.java

Whitespace-only changes.

flink-table/flink-sql-parser-hive/src/main/codegen/data/Parser.tdd

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@
8787
"org.apache.flink.sql.parser.dql.SqlShowFunctions"
8888
"org.apache.flink.sql.parser.dql.SqlShowModules"
8989
"org.apache.flink.sql.parser.dql.SqlShowTables"
90-
"org.apache.flink.sql.parser.dql.SqlShowCreateTable"
9190
"org.apache.flink.sql.parser.dql.SqlShowPartitions"
9291
"org.apache.flink.sql.parser.dql.SqlRichDescribeTable"
9392
"org.apache.flink.sql.parser.dql.SqlRichExplain"
@@ -531,7 +530,6 @@
531530
"SqlAlterDatabase()"
532531
"SqlDescribeDatabase()"
533532
"SqlShowTables()"
534-
"SqlShowCreateTable()"
535533
"SqlRichDescribeTable()"
536534
"SqlShowFunctions()"
537535
"SqlAlterTable()"

flink-table/flink-sql-parser-hive/src/main/codegen/includes/parserImpls.ftl

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -252,22 +252,6 @@ SqlShowTables SqlShowTables() :
252252
}
253253
}
254254

255-
/**
256-
* Parse a "Show Create Table" query command.
257-
*/
258-
SqlShowCreateTable SqlShowCreateTable() :
259-
{
260-
SqlIdentifier tableName;
261-
SqlParserPos pos;
262-
}
263-
{
264-
<SHOW> <CREATE> <TABLE> { pos = getPos();}
265-
tableName = CompoundIdentifier()
266-
{
267-
return new SqlShowCreateTable(pos, tableName);
268-
}
269-
}
270-
271255
/**
272256
* Here we add Rich in className to distinguish from calcite's original SqlDescribeTable.
273257
*/

flink-table/flink-sql-parser-hive/src/test/java/org/apache/flink/sql/parser/hive/FlinkHiveSqlParserImplTest.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,6 @@ public void testShowTables() {
111111
sql("show tables").ok("SHOW TABLES");
112112
}
113113

114-
@Test
115-
public void testShowCreateTable() {
116-
sql("show create table tbl").ok("SHOW CREATE TABLE `TBL`");
117-
sql("show create table catalog1.db1.tbl").ok("SHOW CREATE TABLE `CATALOG1`.`DB1`.`TBL`");
118-
}
119-
120114
@Test
121115
public void testDescribeTable() {
122116
// TODO: support describe partition and columns

flink-table/flink-table-planner/src/main/java/org/apache/flink/table/sqlexec/SqlToOperationConverter.java

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@
3939
import org.apache.flink.sql.parser.dql.SqlRichDescribeTable;
4040
import org.apache.flink.sql.parser.dql.SqlRichExplain;
4141
import org.apache.flink.sql.parser.dql.SqlShowCatalogs;
42-
import org.apache.flink.sql.parser.dql.SqlShowCreateTable;
43-
import org.apache.flink.sql.parser.dql.SqlShowCreateTable;
4442
import org.apache.flink.sql.parser.dql.SqlShowCurrentCatalog;
4543
import org.apache.flink.sql.parser.dql.SqlShowCurrentDatabase;
4644
import org.apache.flink.sql.parser.dql.SqlShowDatabases;
@@ -73,8 +71,6 @@
7371
import org.apache.flink.table.operations.Operation;
7472
import org.apache.flink.table.operations.PlannerQueryOperation;
7573
import org.apache.flink.table.operations.ShowCatalogsOperation;
76-
import org.apache.flink.table.operations.ShowCreateTableOperation;
77-
import org.apache.flink.table.operations.ShowCreateTableOperation;
7874
import org.apache.flink.table.operations.ShowCurrentCatalogOperation;
7975
import org.apache.flink.table.operations.ShowCurrentDatabaseOperation;
8076
import org.apache.flink.table.operations.ShowDatabasesOperation;
@@ -184,9 +180,7 @@ public static Optional<Operation> convert(
184180
return Optional.of(converter.convertAlterTable((SqlAlterTable) validated));
185181
} else if (validated instanceof SqlShowTables) {
186182
return Optional.of(converter.convertShowTables((SqlShowTables) validated));
187-
} else if (validated instanceof SqlShowCreateTable) {
188-
return Optional.of(converter.convertShowCreateTable((SqlShowCreateTable) validated));
189-
} else if (validated instanceof SqlCreateView) {
183+
} else if (validated instanceof SqlCreateView) {
190184
return Optional.of(converter.convertCreateView((SqlCreateView) validated));
191185
} else if (validated instanceof SqlDropView) {
192186
return Optional.of(converter.convertDropView((SqlDropView) validated));
@@ -577,14 +571,7 @@ private Operation convertShowTables(SqlShowTables sqlShowTables) {
577571
return new ShowTablesOperation();
578572
}
579573

580-
/** Convert SHOW CREATE TABLE statement. */
581-
private Operation convertShowCreateTable(SqlShowCreateTable sqlShowCreateTable) {
582-
UnresolvedIdentifier unresolvedIdentifier = UnresolvedIdentifier.of(sqlShowCreateTable.getFullTableName());
583-
ObjectIdentifier identifier = catalogManager.qualifyIdentifier(unresolvedIdentifier);
584-
return new ShowCreateTableOperation(identifier);
585-
}
586-
587-
/** Convert SHOW FUNCTIONS statement. */
574+
/** Convert SHOW FUNCTIONS statement. */
588575
private Operation convertShowFunctions(SqlShowFunctions sqlShowFunctions) {
589576
return new ShowFunctionsOperation(
590577
sqlShowFunctions.requireUser() ? FunctionScope.USER : FunctionScope.ALL);

0 commit comments

Comments
 (0)