Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[java] BQ: use logical type in avro schema factory on write #33163

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -626,9 +626,6 @@ public class BigQueryIO {
static final SerializableFunction<org.apache.avro.Schema, DatumWriter<GenericRecord>>
GENERIC_DATUM_WRITER_FACTORY = schema -> new GenericDatumWriter<>();

private static final SerializableFunction<TableSchema, org.apache.avro.Schema>
DEFAULT_AVRO_SCHEMA_FACTORY = BigQueryAvroUtils::toGenericAvroSchema;

/**
* @deprecated Use {@link #read(SerializableFunction)} or {@link #readTableRows} instead. {@link
* #readTableRows()} does exactly the same as {@link #read}, however {@link
Expand Down Expand Up @@ -3625,7 +3622,8 @@ private <DestinationT> WriteResult expandTyped(
hasSchema,
"A schema must be provided if an avroFormatFunction "
+ "is set but no avroSchemaFactory is defined.");
avroSchemaFactory = DEFAULT_AVRO_SCHEMA_FACTORY;
avroSchemaFactory =
(tableSchema) -> BigQueryUtils.toGenericAvroSchema(tableSchema, true);
}
rowWriterFactory = avroRowWriterFactory.prepare(dynamicDestinations, avroSchemaFactory);
} else if (formatFunction != null) {
Expand Down Expand Up @@ -3857,7 +3855,8 @@ private <DestinationT> WriteResult continueExpandTyped(
(RowWriterFactory.AvroRowWriterFactory<T, GenericRecord, DestinationT>)
rowWriterFactory;
SerializableFunction<@Nullable TableSchema, org.apache.avro.Schema> avroSchemaFactory =
Optional.ofNullable(getAvroSchemaFactory()).orElse(DEFAULT_AVRO_SCHEMA_FACTORY);
Optional.ofNullable(getAvroSchemaFactory())
.orElse(ts -> BigQueryAvroUtils.toGenericAvroSchema(ts, true));

storageApiDynamicDestinations =
new StorageApiDynamicDestinationsGenericRecord<>(
Expand Down
Loading