Tag the Kafka write error output with the schema it actually emits - #39760
Tag the Kafka write error output with the schema it actually emits#39760PDGGK wants to merge 1 commit into
Conversation
ErrorCounterFn emits ErrorHandling.errorRecord(errorSchema, ...), where errorSchema is already ErrorHandling.errorSchema(inputSchema). The error PCollection was tagged with the wrapper applied a second time, declaring a shape no emitted element can match. Same defect as apache#39759 in TFRecordWriteSchemaTransformProvider. The existing tests apply ErrorCounterFn directly and tag the output themselves, so none of them reach the transform's expand(). Signed-off-by: Zihan Dai <dzh1436286758@gmail.com>
|
Assigning reviewers: R: @chamikaramj for label java. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
|
Looks good to me at first glance, but I need to take a moment to figure out if we need to add support for this breaking change in KafkaIO's upgrade compatibility module too. |
|
Thanks — I went and looked, since it is a fair thing to want settled before merging. Short answer: the upgrade module is not affected.
The schema transform's upgrade path is @Override
public Row toConfigRow(KafkaWriteSchemaTransform transform) {
return transform.getConfigurationRow();
}
One thing worth naming, since it is adjacent and I would rather raise it than have you find it: this does change the coder of the error output for a pipeline update of a running streaming job. I do not think that can bite anyone in practice, because the old declared shape was Happy to add a |
Please add a meaningful description for your change here
Follow-up to #39759, which fixed the identical defect in
TFRecordWriteSchemaTransformProvider. Same bug, different module, so it is a separate PR.ErrorCounterFn(andGenericRecordErrorCounterFn) are handederrorSchema = ErrorHandling.errorSchema(inputSchema)and emitErrorHandling.errorRecord(errorSchema, row, e), so every row onERROR_TAGcarries exactly that schema. The collection was then tagged with the wrapper applied a second time:errorSchema(x)is{failed_row: Row(x), error_message: STRING}, so the declared shape becomes{failed_row: {failed_row: …, error_message: …}, error_message: …}— which no element this transform produces can match.KafkaReadSchemaTransformProvidergets it right in the same package, and so doJavaFilterTransformProvider,JavaMapToFieldsTransformProvider,PubsubRowToMessage,PubsubWriteSchemaTransformProviderandBigQueryStorageWriteApiSchemaTransformProvider.Why the existing tests did not catch it
KafkaWriteSchemaTransformProviderTestexercisesErrorCounterFnby applying theParDodirectly and then callingsetRowSchema(errorSchema)itself:So the four
ErrorFntests never reach line 301. The one test that does build the whole transform,testBuildTransformWithManaged, does not look at the output schema.Test
One, and it needs no runner — the schema is fixed while the graph is built, so it runs in the ordinary
:sdks:java:io:kafka:testtask. It goes throughexpand(), which is the gap above.Restoring the second wrap fails it and nothing else:
Note this needs a clean recompile to reproduce — running it incrementally on top of a previous build makes
KafkaIO.writeRecordsthrowNullPointerException: Null eosTriggerTimeoutin both this test andtestBuildTransformWithManaged, from stale AutoValue output rather than from the change. With--rerun-tasksonly the one test fails.spotlessJavaCheck,checkstyleMainandcheckstyleTeston:sdks:java:io:kafkaare clean.Are there user-facing changes?
Yes, for anyone reading the
errorsoutput of the Kafka writeSchemaTransform: it is now tagged with the schema its rows actually have. Code that hardcoded the doubly-nested shape to work around this would need updating, but such code could not have been reading real rows successfully.