prodriguezdefino commented on code in PR #32529:
URL: https://github.com/apache/beam/pull/32529#discussion_r1777919478
##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/providers/BigQueryStorageWriteApiSchemaTransformProvider.java:
##########
@@ -498,5 +555,40 @@ BigQueryIO.Write<Row>
createStorageWriteApiTransform(Schema schema) {
return write;
}
+
+ boolean isCdcConfigured() {
+ return
!Optional.ofNullable(configuration.getUseCdcWritesWithPrimaryKey())
+ .orElse(ImmutableList.of())
+ .isEmpty();
+ }
+
+ BigQueryIO.Write<Row> validateAndIncludeCDCInformation(
+ BigQueryIO.Write<Row> write, Schema schema) {
+ checkArgument(
+ schema.getFieldNames().containsAll(Arrays.asList("cdc_info",
"record")),
+ "When writing using CDC functionality, we expect Row Schema with a "
+ + "\"cdc_info\" Row field and a \"record\" Row field.");
+ checkArgument(
+ schema
+ .getField("cdc_info")
+ .getType()
+ .getRowSchema()
+ .equals(
+ Schema.builder()
+ .addStringField("mutation_type")
+ .addStringField("change_sequence_number")
+ .build()),
+ "When writing using CDC functionality, we expect a \"cdc_info\"
field of Row type "
+ + "with fields \"mutation_type\" and \"change_sequence_number\"
of type string.");
+ return write
+ .withMethod(Method.STORAGE_API_AT_LEAST_ONCE)
Review Comment:
added the error message.
--
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]