xuyangzhong commented on code in PR #23760: URL: https://github.com/apache/flink/pull/23760#discussion_r1401572450
########## flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/operations/converters/SqlNodeConvertUtils.java: ########## @@ -63,6 +69,32 @@ static CatalogView toCatalogView( // This bug is fixed in CALCITE-3877 of Calcite 1.23.0. String originalQuery = context.toQuotedSqlString(query); SqlNode validateQuery = context.getSqlValidator().validate(query); + + // Check name is unique. + // Don't rely on the calcite because if the field names are duplicate, calcite will add + // index to identify the duplicate names. + SqlValidatorNamespace namespace = context.getSqlValidator().getNamespace(validateQuery); + Map<String, Integer> nameToPos = new HashMap<>(); + for (int i = 0; + i < Objects.requireNonNull(namespace).getType().getFieldList().size(); + i++) { + String columnName = namespace.getType().getFieldList().get(i).getName(); Review Comment: Yes, I'll change the title of this pr to make it clearer. -- 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