damondouglas commented on code in PR #28274:
URL: https://github.com/apache/beam/pull/28274#discussion_r1322096281
##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryIO.java:
##########
@@ -721,16 +728,9 @@ public static <T> TypedRead<T>
read(SerializableFunction<SchemaAndRecord, T> par
.setDatumReaderFactory(
(SerializableFunction<TableSchema,
AvroSource.DatumReaderFactory<T>>)
input -> {
- try {
- String jsonTableSchema =
BigQueryIO.JSON_FACTORY.toString(input);
- return (AvroSource.DatumReaderFactory<T>)
- (writer, reader) ->
- new GenericDatumTransformer<>(parseFn,
jsonTableSchema, writer);
- } catch (IOException e) {
- LOG.warn(
- String.format("Error while converting table schema %s
to JSON!", input), e);
- return null;
- }
+ TableSchema safeInput = checkStateNotNull(input);
+ return (AvroSource.DatumReaderFactory<T>)
+ (writer, reader) -> new
GenericDatumTransformer<>(parseFn, safeInput, writer);
Review Comment:
This uses the new GenericDatumTransformer constructor that just takes the
TableSchema input directly instead of needing to convert to JSON and then back
again to the TableSchema later.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]