fsk119 commented on code in PR #19490:
URL: https://github.com/apache/flink/pull/19490#discussion_r852764442
##########
flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/api/TableEnvironmentTest.scala:
##########
@@ -215,6 +215,87 @@ class TableEnvironmentTest {
TableTestUtil.replaceNodeIdInOperator(TableTestUtil.replaceStreamNodeId(actual)))
}
+ @Test
+ def testCreateTableWithMultipleColumnsFromSameMetadataKey(): Unit = {
Review Comment:
Move to the TableScanTest.
##########
flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/api/TableEnvironmentTest.scala:
##########
@@ -215,6 +215,87 @@ class TableEnvironmentTest {
TableTestUtil.replaceNodeIdInOperator(TableTestUtil.replaceStreamNodeId(actual)))
}
+ @Test
+ def testCreateTableWithMultipleColumnsFromSameMetadataKey(): Unit = {
+ assertThatThrownBy(() =>
+ tableEnv.executeSql(
+ """
+ |CREATE TABLE source (
+ | a INT METADATA,
+ | b INT METADATA FROM 'a'
+ |) WITH (
+ | 'connector' = 'COLLECTION'
+ |)
+ |""".stripMargin)).satisfies(
+ FlinkAssertions.anyCauseMatches(
+ classOf[ValidationException],
+ "The column `a` and `b` in the table are both from the same metadata
key 'a'. " +
+ "Please specify one of the columns as the metadata column and use
the computed column" +
+ " syntax to specify the others."))
+ }
+
+ @Test
+ def testCreateTableLikeWithMultipleColumnsFromSameMetadataKey(): Unit = {
+ tableEnv.executeSql(
+ """
+ |CREATE TABLE source (
+ | a INT METADATA
+ |) WITH (
+ | 'connector' = 'COLLECTION'
+ |)
+ |""".stripMargin)
+ assertThatThrownBy(() =>
+ tableEnv.executeSql(
+ """
+ |CREATE TABLE like_source (
+ | b INT METADATA FROM 'a'
+ |)
+ |WITH (
+ | 'connector' = 'COLLECTION'
+ |) LIKE source (
+ | INCLUDING METADATA
+ |)
+ |""".stripMargin
+ )).satisfies(FlinkAssertions.anyCauseMatches(
+ "The column `a` and `b` in the table are both from the same metadata key
'a'. " +
+ "Please specify one of the columns as the metadata column and use the
computed column" +
+ " syntax to specify the others."
+ ))
+ }
+
+ @Test
+ def testCreateTableLikeExcludeColumnsFromSameMetadataKey(): Unit = {
+ tableEnv.executeSql(
+ """
+ |CREATE TABLE source (
+ | a INT METADATA
+ |) WITH (
+ | 'connector' = 'COLLECTION'
+ |)
+ |""".stripMargin)
+ tableEnv.executeSql(
+ """
+ |CREATE TABLE like_source (
+ | b INT METADATA FROM 'a'
+ |)
+ |WITH (
+ | 'connector' = 'COLLECTION'
+ |) LIKE source (
+ | EXCLUDING METADATA
+ |)
+ |""".stripMargin
+ )
+ assertEquals(
Review Comment:
Remove the test.
--
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]