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



##########
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, yes, that makes more sense, thanks, I will be making the change and 
updating.




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