Tag the Kafka write error output with the schema it actually emits - #39760
Open
PDGGK wants to merge 1 commit into
Open
Tag the Kafka write error output with the schema it actually emits#39760PDGGK wants to merge 1 commit into
PDGGK 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>
Contributor
|
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). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.