MiguelAnzoWizeline commented on a change in pull request #14586:
URL: https://github.com/apache/beam/pull/14586#discussion_r627659036



##########
File path: 
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryIO.java
##########
@@ -601,8 +602,17 @@ public static Read read() {
 
     @Override
     public TableRow apply(SchemaAndRecord schemaAndRecord) {
-      return BigQueryAvroUtils.convertGenericRecordToTableRow(
-          schemaAndRecord.getRecord(), schemaAndRecord.getTableSchema());
+      // TODO(BEAM-9114): Implement a function to encapsulate row conversion 
logic.
+      try {
+        return BigQueryAvroUtils.convertGenericRecordToTableRow(
+            schemaAndRecord.getRecord(), schemaAndRecord.getTableSchema());
+      } catch (IllegalStateException i) {
+        if (schemaAndRecord.getRow() != null) {
+          return BigQueryUtils.toTableRow().apply(schemaAndRecord.getRow());
+        }
+        throw new IllegalStateException(
+            "Record should be of instance GenericRecord (for Avro format) or 
of instance Row (for Arrow format), but it is not.");
+      }

Review comment:
       Hi, I made the other changes but I'm struggling with this one, so Arrow 
`RecordBatch` should be mapped to a single `Row`? or is it `ArrowRecordBatch`? 
I'm a bit confused about the right data type. Also, is there any example on how 
to map the data, I saw that there is a `VectorSchemaRoot` to `Iterable<Row>` 
conversion already that uses a Factory of ListValueGetters to do the mapping, 
would something similar be needed?




-- 
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]


Reply via email to