You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2020/08/12 18:38:14 UTC

[GitHub] [beam] robinyqiu commented on a change in pull request #12550: Follow the same way that BigQuery handles unspecified or duplicate ZetaSQL STRUCT field name

robinyqiu commented on a change in pull request #12550:
URL: https://github.com/apache/beam/pull/12550#discussion_r469463169



##########
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:
       I run `SELECT STRUCT("abc" as a, 3 as a)` on BigQuery. The result is a row of 2 fields whose names are `f0_.a` and `f0_._field_2`




----------------------------------------------------------------
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:
users@infra.apache.org