Skip to content

Tag the TFRecord write error output with the schema it actually emits - #39759

Open
PDGGK wants to merge 1 commit into
apache:masterfrom
PDGGK:fix-tfrecord-error-schema
Open

Tag the TFRecord write error output with the schema it actually emits#39759
PDGGK wants to merge 1 commit into
apache:masterfrom
PDGGK:fix-tfrecord-error-schema

Conversation

@PDGGK

@PDGGK PDGGK commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Please add a meaningful description for your change here

ErrorFn is constructed with errorSchema = ErrorHandling.errorSchema(inputSchema) and emits ErrorHandling.errorRecord(errorSchema, row, e), so every row on ERROR_TAG carries that schema. The collection was then tagged with the wrapper applied a second time:

Schema errorSchema = ErrorHandling.errorSchema(inputSchema);          // :162
...
new ErrorFn("TFRecord-write-error-counter", rowToBytesFn, errorSchema, handleErrors)
...
byteArrays.get(ERROR_TAG).setRowSchema(ErrorHandling.errorSchema(errorSchema));   // :188

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 the transform produces can match.

The sibling in the same package gets it right, five lines after an identical ErrorFn construction:

// TFRecordReadSchemaTransformProvider.java:140
PCollection<Row> errorOutput = outputTuple.get(ERROR_TAG).setRowSchema(errorSchema);

JavaFilterTransformProvider, JavaMapToFieldsTransformProvider, PubsubRowToMessage, PubsubWriteSchemaTransformProvider and BigQueryStorageWriteApiSchemaTransformProvider all do the same.

Test

One, and it needs no runner — the schema is fixed when the graph is built, so it runs in the ordinary :sdks:java:core:test task rather than under NeedsRunner.

Restoring the second wrap fails it and nothing else:

tests: 8, failures: 1
  FAILED: testWriteErrorSchemaMatchesTheRowsErrorFnEmits

spotlessJavaCheck, checkstyleMain and checkstyleTest on :sdks:java:core are clean.

Not in this PR

KafkaWriteSchemaTransformProvider.java:301 has the identical double wrap. It is in a different module with its own CI, so I have kept it separate rather than folding it in.


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

ErrorFn is constructed with errorSchema = ErrorHandling.errorSchema(
inputSchema) and emits ErrorHandling.errorRecord(errorSchema, ..), so
every row on ERROR_TAG carries that schema. The collection was then
tagged with ErrorHandling.errorSchema(errorSchema) -- the wrapper
applied twice -- declaring {failed_row: {failed_row: .., error_message},
error_message} which no element it produces can match.

The sibling in the same package gets it right five lines after the same
ErrorFn construction: TFRecordReadSchemaTransformProvider:140 does
setRowSchema(errorSchema). JavaFilter, JavaMapToFields, PubsubRowToMessage
and BigQueryStorageWriteApi all do the same.

One test, and it needs no runner -- the schema is fixed when the graph is
built. Restoring the second wrap fails it and nothing else: 8 tests, 1
failure.

KafkaWriteSchemaTransformProvider:301 has the identical double wrap. It
is a different module, so it is a separate change rather than folded in
here.
@codecov

codecov Bot commented Aug 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 57.13%. Comparing base (dd896e2) to head (7b97a22).
⚠️ Report is 24 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #39759      +/-   ##
============================================
+ Coverage     56.57%   57.13%   +0.56%     
+ Complexity     3999     3641     -358     
============================================
  Files          1329     1191     -138     
  Lines        185231   192731    +7500     
  Branches       2729     3816    +1087     
============================================
+ Hits         104796   110125    +5329     
- Misses        77466    79038    +1572     
- Partials       2969     3568     +599     
Flag Coverage Δ
java 72.15% <ø> (-0.35%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown
Contributor

Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment assign set of reviewers

@PDGGK

PDGGK commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

Run Java_IOs_Direct PreCommit

@github-actions

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @kennknowles for label java.

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant