LadyForest commented on a change in pull request #13011:
URL: https://github.com/apache/flink/pull/13011#discussion_r614592983
##########
File path:
flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/planner/catalog/CatalogTableITCase.scala
##########
@@ -985,6 +984,83 @@ class CatalogTableITCase(isStreamingMode: Boolean) extends
AbstractTestBase {
assertEquals(false, tableSchema2.getPrimaryKey.isPresent)
}
+ @Test
+ def testCreateTableAndShowCreateTable(): Unit = {
+ val executedDDL =
+ """
+ |create temporary table TBL1 (
+ | a bigint not null,
+ | h string,
+ | g as 2*(a+1),
+ | b string not null,
+ | c bigint metadata virtual,
+ | ts timestamp(3),
+ | proc as proctime(),
+ | watermark for ts as ts - interval '5' second,
+ | constraint test_constraint primary key (a, b) not enforced
+ |) comment 'test show create table statement'
+ |partitioned by (b,h)
+ |with (
+ | 'connector' = 'kafka',
+ | 'kafka.topic' = 'log.test'
+ |)
+ |""".stripMargin
+
+ val expectedDDL =
+ """ |CREATE TEMPORARY TABLE `default_catalog`.`default_database`.`TBL1` (
+ | `a` BIGINT NOT NULL,
+ | `h` STRING,
+ | `g` AS 2 * (`a` + 1),
+ | `b` STRING NOT NULL,
+ | `c` BIGINT METADATA VIRTUAL,
+ | `ts` TIMESTAMP(3),
+ | `proc` AS PROCTIME(),
+ | WATERMARK FOR `ts` AS `ts` - INTERVAL '5' SECOND,
+ | CONSTRAINT `test_constraint` PRIMARY KEY (`a`, `b`) NOT ENFORCED
+ |) COMMENT 'test show create table statement'
+ |PARTITIONED BY (`b`, `h`)
+ |WITH (
+ | 'connector' = 'kafka',
+ | 'kafka.topic' = 'log.test'
+ |)
+ |""".stripMargin
+ tableEnv.executeSql(executedDDL)
+ val row = tableEnv.executeSql("SHOW CREATE TABLE `TBL1`").collect().next()
+ assertEquals(expectedDDL, row.getField(0))
+
+ expectedEx.expect(classOf[ValidationException])
+ expectedEx.expectMessage(
+ "Could not execute SHOW CREATE TABLE. " +
+ "Table with identifier `default_catalog`.`default_database`.`tmp` does
not exist.")
+ tableEnv.executeSql("SHOW CREATE TABLE `tmp`")
+ }
+
+ @Test
+ def testCreateViewAndShowCreateTable(): Unit = {
+ val createTableDDL =
+ """ |create table `source` (
+ | `id` bigint not null,
+ | `group` string not null,
+ | `score` double
+ |) with (
+ | 'connector' = 'source-only'
+ |)
+ |""".stripMargin
+ val createViewDDL =
+ """ |create view `tmp` as
+ |select `group`, avg(`score`) as avg_score
+ |from `source`
+ |group by `group`
+ |""".stripMargin
+ tableEnv.executeSql(createTableDDL)
+ tableEnv.executeSql(createViewDDL)
+ expectedEx.expect(classOf[TableException])
+ expectedEx.expectMessage(
+ "Could not execute SHOW CREATE TABLE. " +
+ "View with identifier `default_catalog`.`default_database`.`tmp` is
not supported.")
Review comment:
I'm fine with this. nit: `support showing`
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]