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

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

                Author: ASF GitHub Bot
            Created on: 24/Nov/20 00:18
            Start Date: 24/Nov/20 00:18
    Worklog Time Spent: 10m 
      Work Description: apilloud commented on a change in pull request #13377:
URL: https://github.com/apache/beam/pull/13377#discussion_r529080156



##########
File path: 
sdks/java/extensions/sql/zetasql/src/main/java/org/apache/beam/sdk/extensions/sql/zetasql/ZetaSqlUnnest.java
##########
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.sdk.extensions.sql.zetasql;

Review comment:
       (And by this, I mean all the stuff in this PR that is copied and planned 
for deletion.)




----------------------------------------------------------------
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: 515837)
    Time Spent: 40m  (was: 0.5h)

> Support UNNEST an array of structs
> ----------------------------------
>
>                 Key: BEAM-10896
>                 URL: https://issues.apache.org/jira/browse/BEAM-10896
>             Project: Beam
>          Issue Type: New Feature
>          Components: dsl-sql-zetasql
>            Reporter: Robin Qiu
>            Assignee: Robin Qiu
>            Priority: P2
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> Currently UNNEST an array of structs does not work properly in Beam ZetaSQL:
>  
> e.g. SELECT p.some_field FROM table, UNNEST(table.array_of_structs) AS p
>  
> Execution of such queries will crash with error in ProjectScanConverter:
> Exception in thread "main" java.lang.AssertionError: Field ordinal 1 is 
> invalid for  type 'RecordType(VARCHAR id)'Exception in thread "main" 
> java.lang.AssertionError: Field ordinal 1 is invalid for  type 
> 'RecordType(VARCHAR id)' at 
> org.apache.beam.vendor.calcite.v1_20_0.org.apache.calcite.rex.RexBuilder.makeFieldAccess(RexBuilder.java:197)
>  at 
> org.apache.beam.sdk.extensions.sql.zetasql.translation.ExpressionConverter.convertResolvedStructFieldAccessInternal(ExpressionConverter.java:881)
>  at 
> org.apache.beam.sdk.extensions.sql.zetasql.translation.ExpressionConverter.convertResolvedStructFieldAccess(ExpressionConverter.java:871)
>  at 
> org.apache.beam.sdk.extensions.sql.zetasql.translation.ExpressionConverter.convertRexNodeFromResolvedExpr(ExpressionConverter.java:309)
>  at 
> org.apache.beam.sdk.extensions.sql.zetasql.translation.ExpressionConverter.convertResolvedStructFieldAccess(ExpressionConverter.java:869)
>  at 
> org.apache.beam.sdk.extensions.sql.zetasql.translation.ExpressionConverter.convertRexNodeFromResolvedExpr(ExpressionConverter.java:309)
>  at 
> org.apache.beam.sdk.extensions.sql.zetasql.translation.ExpressionConverter.convertResolvedStructFieldAccess(ExpressionConverter.java:869)
>  at 
> org.apache.beam.sdk.extensions.sql.zetasql.translation.ExpressionConverter.convertRexNodeFromResolvedExpr(ExpressionConverter.java:309)
>  at 
> org.apache.beam.sdk.extensions.sql.zetasql.translation.ExpressionConverter.convertRexNodeFromComputedColumnWithFieldList(ExpressionConverter.java:368)
>  at 
> org.apache.beam.sdk.extensions.sql.zetasql.translation.ExpressionConverter.retrieveRexNode(ExpressionConverter.java:196)
>  at 
> org.apache.beam.sdk.extensions.sql.zetasql.translation.ProjectScanConverter.convert(ProjectScanConverter.java:45)
>  at 
> org.apache.beam.sdk.extensions.sql.zetasql.translation.ProjectScanConverter.convert(ProjectScanConverter.java:29)
>  at 
> org.apache.beam.sdk.extensions.sql.zetasql.translation.QueryStatementConverter.convertNode(QueryStatementConverter.java:99)
>  
> The root cause is that Calcite 1.20.0 Uncollect will "unwrap" the struct/row 
> in an array being unnested: 
> [https://github.com/apache/calcite/blob/calcite-1.20.0/core/src/main/java/org/apache/calcite/rel/core/Uncollect.java#L146-L152]
>  
> The Calcite Uncollect API has a change in 1.23.0 that could provide us a way 
> to bypass this "unwrapping": 
> https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/rel/core/Uncollect.java#L171-L172



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

Reply via email to