xuyangzhong commented on a change in pull request #18017: URL: https://github.com/apache/flink/pull/18017#discussion_r765486095
########## File path: flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/plan/stream/sql/UnionTest.scala ########## @@ -40,10 +40,9 @@ class UnionTest extends TableTestBase { |CREATE TABLE t1 ( | id int, | ts bigint, - | name string, + | name varchar(32), Review comment: If you want to delete one of them, I think it's better to keep the one that has the same type with other tables. ########## File path: flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/operations/MergeTableLikeUtil.java ########## @@ -494,7 +494,13 @@ private void collectPhysicalFieldsTypes(List<SqlNode> derivedColumns) { boolean nullable = type.getNullable() == null ? true : type.getNullable(); RelDataType relType = type.deriveType(sqlValidator, nullable); // add field name and field type to physical field list - physicalFieldNamesToTypes.put(name, relType); + RelDataType oldType = physicalFieldNamesToTypes.put(name, relType); + if (oldType != null) { + throw new ValidationException( + String.format( + "A column named '%s' already exists in the derived table.", Review comment: The exception message is confusing where the derived table is, because users maybe only use "create table ..." instead of "create table ... like ...". But the previous one can also cause this bug. IMO, you can delete the word 'derived'. -- 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