[ 
https://issues.apache.org/jira/browse/BEAM-10895?focusedWorklogId=487566&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-487566
 ]

ASF GitHub Bot logged work on BEAM-10895:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 22/Sep/20 03:16
            Start Date: 22/Sep/20 03:16
    Worklog Time Spent: 10m 
      Work Description: robinyqiu commented on a change in pull request #12843:
URL: https://github.com/apache/beam/pull/12843#discussion_r492322185



##########
File path: 
sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamUnnestRel.java
##########
@@ -111,31 +112,41 @@ public RelWriter explainTerms(RelWriter pw) {
       Schema joinedSchema = CalciteUtils.toSchema(getRowType());
 
       return outer
-          .apply(ParDo.of(new UnnestFn(joinedSchema, unnestIndex)))
+          .apply(ParDo.of(new UnnestFn(joinedSchema, unnestIndices)))
           .setRowSchema(joinedSchema);
     }
   }
 
   private static class UnnestFn extends DoFn<Row, Row> {
 
     private final Schema outputSchema;
-    private final int unnestIndex;
+    private final List<Integer> unnestIndices;
 
-    private UnnestFn(Schema outputSchema, int unnestIndex) {
+    private UnnestFn(Schema outputSchema, List<Integer> unnestIndices) {
       this.outputSchema = outputSchema;
-      this.unnestIndex = unnestIndex;
+      this.unnestIndices = unnestIndices;
     }
 
     @ProcessElement
     public void process(@Element Row row, OutputReceiver<Row> out) {
-
-      @Nullable Collection<Object> rawValues = row.getArray(unnestIndex);
+      Row rowWithArrayField = row;
+      Schema schemaWithArrayField = outputSchema;
+      for (int i = unnestIndices.size() - 1; i > 0; i--) {
+        rowWithArrayField = rowWithArrayField.getRow(unnestIndices.get(i));

Review comment:
       I believe the updated code in `BeamUnnestRule.java` will guarantee this.




----------------------------------------------------------------
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]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 487566)
    Time Spent: 1h 10m  (was: 1h)

> Support UNNEST an (possibly nested) array field of an struct column
> -------------------------------------------------------------------
>
>                 Key: BEAM-10895
>                 URL: https://issues.apache.org/jira/browse/BEAM-10895
>             Project: Beam
>          Issue Type: New Feature
>          Components: dsl-sql-zetasql
>            Reporter: Robin Qiu
>            Assignee: Robin Qiu
>            Priority: P2
>             Fix For: 2.25.0
>
>          Time Spent: 1h 10m
>  Remaining Estimate: 0h
>
> Currently Beam ZetaSQL only support UNNEST an array column of a table:
>  
> e.g. SELECT * FROM table, UNNEST(table.array_col)
>  
> From the ZetaSQL spec, UNNEST should also work on (possibly nested) array 
> field of an struct column:
>  
> e.g. 1: SELECT * FROM table, UNNEST(table.struct_col.array_field)
> e.g. 2: SELECT * FROM table, UNNEST(table.struct_col.struct_field.array_field)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to