MiguelAnzoWizeline commented on a change in pull request #14586:
URL: https://github.com/apache/beam/pull/14586#discussion_r638015299
##########
File path:
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/SchemaAndRecord.java
##########
@@ -18,23 +18,32 @@
package org.apache.beam.sdk.io.gcp.bigquery;
import com.google.api.services.bigquery.model.TableSchema;
+import javax.annotation.Nullable;
import org.apache.avro.generic.GenericRecord;
+import org.apache.beam.sdk.values.Row;
/**
* A wrapper for a {@link GenericRecord} and the {@link TableSchema}
representing the schema of the
* table (or query) it was generated from.
*/
public class SchemaAndRecord {
- private final GenericRecord record;
+ private final Object record;
private final TableSchema tableSchema;
- public SchemaAndRecord(GenericRecord record, TableSchema tableSchema) {
+ public SchemaAndRecord(Object record, TableSchema tableSchema) {
this.record = record;
this.tableSchema = tableSchema;
}
public GenericRecord getRecord() {
- return record;
+ if (!(record instanceof GenericRecord)) {
+ throw new IllegalStateException("Object is not GenericRecord");
+ }
+ return (GenericRecord) record;
+ }
Review comment:
R: @TheNeuralBit It seems that I was mistaken here, there is a lot of
previous code that still backups the `Object` in `SchemaAndRecord` with an Avro
`GenericRecord`, would it be better here to find and change those use cases and
make the conversion to `Row`, or would it be better to leave the `getRecord`
method to leave that compatibility open and avoid the possibility of breaking
something?
--
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]