You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/04/19 08:43:25 UTC

[GitHub] [flink] fsk119 commented on a diff in pull request #19490: [FLINK-27263][table] Rename the metadata column to the user specified…

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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org