jelly-1203 commented on a change in pull request #18017: URL: https://github.com/apache/flink/pull/18017#discussion_r769618300
########## File path: flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/operations/MergeTableLikeUtilTest.java ########## @@ -126,6 +126,72 @@ public void mergeWithIncludeFailsOnDuplicateColumn() { null); } + @Test + public void mergeWithIncludeFailsOnDuplicateRegularColumn() { + TableSchema sourceSchema = + TableSchema.builder().add(TableColumn.physical("one", DataTypes.INT())).build(); + + List<SqlNode> derivedColumns = + Arrays.asList( + regularColumn("two", DataTypes.INT()), + regularColumn("two", DataTypes.INT()), + regularColumn("four", DataTypes.STRING())); + + thrown.expect(ValidationException.class); + thrown.expectMessage("A regular Column named 'two' already exists in the table."); + util.mergeTables( + getDefaultMergingStrategies(), + sourceSchema, + derivedColumns, + Collections.emptyList(), + null); + } + + @Test + public void mergeWithIncludeFailsOnDuplicateRegularColumnAndComputeColumn() { + TableSchema sourceSchema = + TableSchema.builder().add(TableColumn.physical("one", DataTypes.INT())).build(); + + List<SqlNode> derivedColumns = + Arrays.asList( + regularColumn("two", DataTypes.INT()), + computedColumn("three", plus("two", "3")), + regularColumn("three", DataTypes.INT()), + regularColumn("four", DataTypes.STRING())); + + thrown.expect(ValidationException.class); + thrown.expectMessage("A column named 'three' already exists in the table."); + util.mergeTables( + getDefaultMergingStrategies(), + sourceSchema, + derivedColumns, + Collections.emptyList(), + null); + } + + @Test + public void mergeWithIncludeFailsOnDuplicateRegularColumnAndMetadataColumn() { + TableSchema sourceSchema = + TableSchema.builder().add(TableColumn.physical("one", DataTypes.INT())).build(); + + List<SqlNode> derivedColumns = + Arrays.asList( + metadataColumn("two", DataTypes.INT(), true), + computedColumn("three", plus("two", "3")), + regularColumn("two", DataTypes.INT()), + regularColumn("four", DataTypes.STRING())); + + thrown.expect(ValidationException.class); + thrown.expectMessage( Review comment: > Contributor Ok, I'll return this error message more explicitly -- 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-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org