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

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

                Author: ASF GitHub Bot
            Created on: 11/Jul/19 19:25
            Start Date: 11/Jul/19 19:25
    Worklog Time Spent: 10m 
      Work Description: apilloud commented on issue #8930: [BEAM-7621] Null 
pointer exception when accessing null row fields in BeamSql
URL: https://github.com/apache/beam/pull/8930#issuecomment-510621013
 
 
   retest this please
 
----------------------------------------------------------------
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: 275476)
    Time Spent: 2h 50m  (was: 2h 40m)

> Selecting null row field's causes Null pointer Exception with BeamSql
> ---------------------------------------------------------------------
>
>                 Key: BEAM-7621
>                 URL: https://issues.apache.org/jira/browse/BEAM-7621
>             Project: Beam
>          Issue Type: Bug
>          Components: dsl-sql
>    Affects Versions: 2.14.0
>            Reporter: Vishwas
>            Priority: Major
>          Time Spent: 2h 50m
>  Remaining Estimate: 0h
>
> I have below schema of the row:
>   private static final Schema innerRowWithArraySchema =
>       Schema.builder()
>           .addStringField("string_field")
>           .addArrayField("array_field", FieldType.INT64)
>           .build();
> private static final Schema nullableNestedRowWithArraySchema =
>           Schema.builder()
>               
> .addNullableField("field1",FieldType.row(innerRowWithArraySchema))
>               .addNullableField("field2", 
> FieldType.array(FieldType.row(innerRowWithArraySchema)))
>               .build();
>  
> *// Create a row with null values*
> Row nullRow = Row.nullRow(nullableNestedRowWithArraySchema);
>  
> Now when we try to select nested row field's NPE is thrown:
> .apply(SqlTransform.query("select PCOLLECTION.field1.string_field as 
> row_string_field, PCOLLECTION.field2[2].string_field as array_string_field 
> from PCOLLECTION"));
>  
> Below is the exception thrown:
> Caused by: java.lang.RuntimeException: CalcFn failed to evaluate: {
>   final org.apache.beam.sdk.values.Row current = 
> (org.apache.beam.sdk.values.Row) c.element();
>   *final java.util.List inp1_ = 
> org.apache.beam.sdk.extensions.sql.impl.rel.BeamCalcRel.WrappedList.of(current.getRow(1));*
>   *final java.util.List inp2_ = 
> org.apache.beam.sdk.extensions.sql.impl.rel.BeamCalcRel.WrappedList.of(current.getArray(2));*
>   
> c.output(org.apache.beam.sdk.values.Row.withSchema(outputSchema).addValue(inp1_
>  == null ? (String) null : (String) 
> org.apache.beam.repackaged.beam_sdks_java_extensions_sql.org.apache.calcite.runtime.SqlFunctions.structAccess(inp1_,
>  0, 
> "string_field")).addValue(org.apache.beam.repackaged.beam_sdks_java_extensions_sql.org.apache.calcite.runtime.SqlFunctions.arrayItemOptional(inp2_,
>  2) == null ? (String) null : (String) 
> org.apache.beam.repackaged.beam_sdks_java_extensions_sql.org.apache.calcite.runtime.SqlFunctions.structAccess(org.apache.beam.repackaged.beam_sdks_java_extensions_sql.org.apache.calcite.runtime.SqlFunctions.arrayItemOptional(inp2_,
>  2), 0, "string_field")).build());
> }
>     at 
> org.apache.beam.sdk.extensions.sql.impl.rel.BeamCalcRel$CalcFn.processElement(BeamCalcRel.java:253)
> Caused by: java.lang.NullPointerException
>     at 
> org.apache.beam.sdk.extensions.sql.impl.rel.BeamCalcRel$WrappedList.of(BeamCalcRel.java:459)
>     at SC.eval0(Unknown Source)
>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>  
> In BeamCalcRel.class *field* method, null values are not handled for 
> composite types.
>     public Expression field(BlockBuilder list, int index, Type storageType) {
>      ....
>       } else if (fromType.getTypeName().isCompositeType()
>           || (fromType.getTypeName().isCollectionType()
>               && 
> fromType.getCollectionElementType().getTypeName().isCompositeType())) {
>         field = Expressions.call(WrappedList.class, "of", field);  // 
> List.of() is passed with null values
>       }
>       ... 
>     }
>  
>  



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

Reply via email to