Force portable TestStream to use the Nested Coder context throughout. #33334
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.
Coder Contexts are largely deprecated as a notion in Beam, and aren't used, with the default being the "nested" coder context instead of the Outer context. There are a few places though that still set "outer coder context" by default, notably in the CoderUtils helper methods.
Where this manifests for TestStream is that CoderUtils is used to take elements and convert them into byte buffers when moved portably. While most coders now ignore the difference, for various legacy reasons, the KVCoder still pipes the context to the value coder, and some coders still understand and use the difference. In this case, the StringUTF8 coder, when given the Outer context, doesn't length prefix the string.
This leads to TestStream values being encoded in weird ways, that don't translate portably. eg. If the values are KV<String, String> the Key will be length prefixed, but the value will not be. This will ultimately cause a break at test run time, because the CoderUtils path isn't used in decoding over Beam Portability, but the normal decoder path, which wouldn't provide the Outer context.
This is likely what's caused difficulty in using TestStream in non-Java SDKs, such as Go on Flink.
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
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, commentfixes #<ISSUE NUMBER>
instead.CHANGES.md
with noteworthy changes.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.