You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@beam.apache.org by "Graham Polley (JIRA)" <ji...@apache.org> on 2019/01/21 01:28:00 UTC

[jira] [Created] (BEAM-6474) Cannot reference field when using SqlTransform (need to use "EXPR$N" instead)

Graham Polley created BEAM-6474:
-----------------------------------

             Summary: Cannot reference field when using SqlTransform (need to use "EXPR$N" instead)
                 Key: BEAM-6474
                 URL: https://issues.apache.org/jira/browse/BEAM-6474
             Project: Beam
          Issue Type: Bug
          Components: beam-model, dsl-sql, runner-dataflow
    Affects Versions: 2.9.0
         Environment: MacOS
            Reporter: Graham Polley
            Assignee: Kenneth Knowles


Maybe I've done something wrong, but when you try to access a field this has been generated in a SqlTransform it throws an exception:

 
{code:java}
java.lang.RuntimeException: org.apache.beam.sdk.util.UserCodeException: java.lang.IllegalArgumentException: Cannot find field views in schema Fields: Field{name=wikimedia_project, description=, type=FieldType{typeName=STRING, collectionElementType=null, collectionElementTypeNullable=null, mapKeyType=null, mapValueType=null, mapValueTypeNullable=null, rowSchema=null, metadata=null}, nullable=false} Field{name=EXPR$1, description=, type=FieldType{typeName=INT32, collectionElementType=null, collectionElementTypeNullable=null, mapKeyType=null, mapValueType=null, mapValueTypeNullable=null, rowSchema=null, metadata=null}, nullable=false}{code}
Instead of being able to access the `views` field, it has been named `EXPR$1` by Beam/Dataflow. So, to get the value of the field I need to do this:
{code:java}
bqRow.set("views", row.getInt32("EXPR$1"));{code}
instead of:
{code:java}
bqRow.set("views", row.getInt32("views"));{code}
Pipeline is reading a file from GCS, transforming it (using SqlTransform) and writing to BigQuery. Code can be found here:

https://github.com/polleyg/gcp-batch-ingestion-bigquery/blob/beam_sql/src/main/java/org/polleyg/TemplatePipeline.java

 



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