beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Work logged] (BEAM-5056) [SQL] Nullability of aggregation expressions isn't inferred properly
Date Thu, 02 Aug 2018 07:24:00 GMT

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

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

                Author: ASF GitHub Bot
            Created on: 02/Aug/18 07:23
            Start Date: 02/Aug/18 07:23
    Worklog Time Spent: 10m 
      Work Description: kanterov commented on a change in pull request #6118: [BEAM-5056]
[SQL] Fix nullability in output schema
URL: https://github.com/apache/beam/pull/6118#discussion_r207124417
 
 

 ##########
 File path: sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamJoinRel.java
 ##########
 @@ -257,25 +257,52 @@ private boolean triggersOncePerWindow(WindowingStrategy windowingStrategy)
{
   private PCollection<Row> standardJoin(
       PCollection<KV<Row, Row>> extractedLeftRows,
       PCollection<KV<Row, Row>> extractedRightRows,
-      Row leftNullRow,
-      Row rightNullRow) {
+      Schema leftSchema,
+      Schema rightSchema) {
     PCollection<KV<Row, KV<Row, Row>>> joinedRows = null;
+
     switch (joinType) {
       case LEFT:
-        joinedRows =
-            org.apache.beam.sdk.extensions.joinlibrary.Join.leftOuterJoin(
-                extractedLeftRows, extractedRightRows, rightNullRow);
-        break;
+        {
+          Schema rigthNullSchema = buildNullSchema(rightSchema);
+          Row rightNullRow = Row.nullRow(rigthNullSchema);
+
+          setValueCoder(extractedRightRows, SchemaCoder.of(rigthNullSchema));
+
+          joinedRows =
+              org.apache.beam.sdk.extensions.joinlibrary.Join.leftOuterJoin(
+                  extractedLeftRows, extractedRightRows, rightNullRow);
+
+          break;
+        }
       case RIGHT:
-        joinedRows =
-            org.apache.beam.sdk.extensions.joinlibrary.Join.rightOuterJoin(
-                extractedLeftRows, extractedRightRows, leftNullRow);
-        break;
+        {
+          Schema leftNullSchema = buildNullSchema(leftSchema);
+          Row leftNullRow = Row.nullRow(leftNullSchema);
+
+          setValueCoder(extractedLeftRows, SchemaCoder.of(leftNullSchema));
 
 Review comment:
   I adjusted usages of `setValueCoder` to assign return value back to PCollection. It makes
the code a bit longer, but I think it's the right thing to do, given that not everyone knows
that PCollections are mutable.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


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

    Worklog Id:     (was: 130166)
    Time Spent: 2h  (was: 1h 50m)

> [SQL] Nullability of aggregation expressions isn't inferred properly
> --------------------------------------------------------------------
>
>                 Key: BEAM-5056
>                 URL: https://issues.apache.org/jira/browse/BEAM-5056
>             Project: Beam
>          Issue Type: Bug
>          Components: dsl-sql
>            Reporter: Gleb Kanterov
>            Assignee: Xu Mingmin
>            Priority: Major
>          Time Spent: 2h
>  Remaining Estimate: 0h
>
> Given schema and rows:
> {code:java}
> Schema schema =
>     Schema.builder()
>         .addNullableField("f_int1", Schema.FieldType.INT32)
>         .addNullableField("f_int2", Schema.FieldType.INT32)
>         .build();
> List<Row> rows =
>     TestUtils.RowsBuilder.of(schema)
>         .addRows(null, null)
>         .getRows();
> {code}
> Following query fails:
> {code:sql}
> SELECT AVG(f_int1) FROM PCOLLECTION GROUP BY f_int2
> {code}
> {code:java}
> Caused by: java.lang.IllegalArgumentException: Field EXPR$0 is not nullable{code}
>  
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message