MiguelAnzoWizeline commented on a change in pull request #14586:
URL: https://github.com/apache/beam/pull/14586#discussion_r625296959
##########
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:
So, the idea would be to have this apply function to only use `Row` from
`SchemaAndRecord,` and have a function that encapsulates converting
`GenericRecord` and `RecordBatch` to `Row` to use that before this apply?
--
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]