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

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

                Author: ASF GitHub Bot
            Created on: 25/Jul/19 19:21
            Start Date: 25/Jul/19 19:21
    Worklog Time Spent: 10m 
      Work Description: kennknowles commented on pull request #9089: 
[BEAM-7755] adding repeated row implementation that worked on a simple case
URL: https://github.com/apache/beam/pull/9089#discussion_r307461632
 
 

 ##########
 File path: 
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryUtils.java
 ##########
 @@ -553,14 +554,20 @@ private static ReadableInstant truncateToMillis(Object 
value) {
     return new Instant((long) value / 1000);
   }
 
-  private static Object convertAvroArray(Field beamField, Object value) {
+  private static Object convertAvroArray(
+      Field beamField, Object value, BigQueryUtils.ConversionOptions options) {
     // Check whether the type of array element is equal.
     List<Object> values = (List<Object>) value;
     List<Object> ret = new ArrayList();
     for (Object v : values) {
-      ret.add(
-          convertAvroPrimitiveTypes(
-              beamField.getType().getCollectionElementType().getTypeName(), 
v));
+      FieldType arrayElementType = 
beamField.getType().getCollectionElementType();
+      TypeName elementTypeName = arrayElementType.getTypeName();
+      if (elementTypeName.equals(TypeName.ROW)) {
+        GenericData.Record record = (GenericData.Record) v;
+        ret.add(toBeamRow(record, arrayElementType.getRowSchema(), options));
+      } else {
+        ret.add(convertAvroPrimitiveTypes(elementTypeName, v));
 
 Review comment:
   I think this `if` / `else` piece should just be a recursive call into 
`convertAvroFormat`. You will need to update it to only need the `FieldType` 
and not the whole `Field`. This should be easy, I think. I just read the code 
and it does not seem to actually need the whole `Field`.
 
----------------------------------------------------------------
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: 282868)
    Time Spent: 40m  (was: 0.5h)

> BigQuery Repeated Records do not seem to work
> ---------------------------------------------
>
>                 Key: BEAM-7755
>                 URL: https://issues.apache.org/jira/browse/BEAM-7755
>             Project: Beam
>          Issue Type: Bug
>          Components: io-java-avro, io-java-gcp
>    Affects Versions: 2.12.0, 2.13.0
>            Reporter: Sahith Nallapareddy
>            Assignee: Sahith Nallapareddy
>            Priority: Major
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> When translating BigQuery rows to beam rows, specifically using theĀ  
> BigQueryUtils.toBeamRow(record, beamSchema) method, REPEATEDĀ RECORDS causes 
> an error. This seems to be caused that avro arrays are thought to only have 
> primitive types but these are arrays with a ROW type:
> {noformat}
> Caused by: java.lang.RuntimeException: ROW is not primitive type.
>       at 
> org.apache.beam.sdk.io.gcp.bigquery.BigQueryUtils.convertAvroPrimitiveTypes(BigQueryUtils.java:467)
>       at 
> org.apache.beam.sdk.io.gcp.bigquery.BigQueryUtils.convertAvroArray(BigQueryUtils.java:427)
>       at 
> org.apache.beam.sdk.io.gcp.bigquery.BigQueryUtils.convertAvroFormat(BigQueryUtils.java:373)
>       at 
> org.apache.beam.sdk.io.gcp.bigquery.BigQueryUtils.lambda$toBeamRow$2(BigQueryUtils.java:222)
>       at 
> java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
>       at 
> java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1376)
>       at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
>       at 
> java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
>       at 
> java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
>       at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
>       at 
> java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
>       at 
> org.apache.beam.sdk.io.gcp.bigquery.BigQueryUtils.toBeamRow(BigQueryUtils.java:223)
>       at 
> com.spotify.data.sql.RowSource.lambda$bigquery$120a5f9f$1(RowSource.java:55)
>       at 
> org.apache.beam.sdk.io.gcp.bigquery.BigQuerySourceBase$1.apply(BigQuerySourceBase.java:242)
>       at 
> org.apache.beam.sdk.io.gcp.bigquery.BigQuerySourceBase$1.apply(BigQuerySourceBase.java:235)
>       at 
> org.apache.beam.sdk.io.AvroSource$AvroBlock.readNextRecord(AvroSource.java:597)
>       at 
> org.apache.beam.sdk.io.BlockBasedSource$BlockBasedReader.readNextRecord(BlockBasedSource.java:209)
>       at 
> org.apache.beam.sdk.io.FileBasedSource$FileBasedReader.advanceImpl(FileBasedSource.java:484)
>       at 
> org.apache.beam.sdk.io.FileBasedSource$FileBasedReader.startImpl(FileBasedSource.java:479)
>       at 
> org.apache.beam.sdk.io.OffsetBasedSource$OffsetBasedReader.start(OffsetBasedSource.java:249)
>       at 
> org.apache.beam.runners.dataflow.worker.WorkerCustomSources$BoundedReaderIterator.start(WorkerCustomSources.java:601)
> {noformat}



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

Reply via email to