robinyqiu commented on a change in pull request #12550:
URL: https://github.com/apache/beam/pull/12550#discussion_r469466085
##########
File path:
sdks/java/extensions/sql/zetasql/src/main/java/org/apache/beam/sdk/extensions/sql/zetasql/ZetaSqlCalciteTranslationUtils.java
##########
@@ -180,12 +182,19 @@ private static RelDataType toCalciteStructType(
private static List<String> getFieldNameList(List<StructField> fields) {
ImmutableList.Builder<String> b = ImmutableList.builder();
+ Set<String> usedName = new HashSet<>();
for (int i = 0; i < fields.size(); i++) {
String name = fields.get(i).getName();
- if ("".equals(name)) {
- name = "$col" + i; // avoid empty field names because Beam does not
allow duplicate names
+ // Follow the same way that BigQuery handles unspecified or duplicate
field name
+ if ("".equals(name) || usedName.contains(name)) {
Review comment:
OK I got your point now. So I believe the condition should be
`"".equals(name) || name.startsWith("_field_") || usedName.contains(name)`.
This way we can avoid throwing the exception.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]