prodriguezdefino commented on code in PR #32529:
URL: https://github.com/apache/beam/pull/32529#discussion_r1799871523
##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/providers/BigQueryStorageWriteApiSchemaTransformProvider.java:
##########
@@ -466,11 +530,11 @@ BigQueryIO.Write<Row>
createStorageWriteApiTransform(Schema schema) {
.withFormatFunction(BigQueryUtils.toTableRow())
.withWriteDisposition(WriteDisposition.WRITE_APPEND);
- if (configuration.getTable().equals(DYNAMIC_DESTINATIONS)) {
- checkArgument(
- schema.getFieldNames().equals(Arrays.asList("destination",
"record")),
- "When writing to dynamic destinations, we expect Row Schema with a
"
- + "\"destination\" string field and a \"record\" Row field.");
+ // in case CDC writes are configured we validate and include them in the
configuration
+ if (Optional.ofNullable(configuration.getUseCdcWrites()).orElse(false)) {
+ write = validateAndIncludeCDCInformation(write, schema);
Review Comment:
I tried building this logic previously but is not possible given this
existing
[check](https://github.com/apache/beam/blob/master/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryIO.java#L3367).
Setting a dynamic destination does not clear a previously set table
reference or serializable function. So when that logic is implemented as you
recommend and CDC is configured the existing check can make it fail because CDC
uses a DD to provide a schema for records and, when no DD is configured,
setting the `RowDynamicDestinations` does not clear the previously set table
reference.
The current logic is the simplest/cleanest way I found to resolve the
problem of having those 3 possible branches: CDC with(out) DD, only DD, or just
table reference.
--
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]