Repository navigation
Check PAssert.thatMap and thatMultimap without side inputs - #41878
harshilv17 wants to merge 1 commit into
Conversation
thatMap and thatMultimap were the only PAssert entry points still built on a side input (View.asMap/asMultimap read by OneSideInputAssert). Build the map from the grouped contents on the same GroupThenAssert path as the other assertions, so they no longer need side input support from the runner. Duplicate keys in thatMap still fail, now as an assertion failure. OneSideInputAssert is public, so it is deprecated rather than removed.
There was a problem hiding this comment.
📋 Review Summary
This PR refactors PAssert.thatMap and PAssert.thatMultimap to use GroupThenAssert instead of View.asMap() / View.asMultimap() with OneSideInputAssert, eliminating the side-input requirement for map assertions and deprecating OneSideInputAssert. The implementation is clean, well-aligned with the rest of PAssert, and includes comprehensive unit and runner tests.
🔍 General Feedback
- The transition from
OneSideInputAsserttoGroupThenAssertviaGroupedToMapandGroupedToMultimapsimplifies the pipeline graph for map assertions and unifies window/pane extraction across allPAssertentry points. - Minor cleanup: the class-level Javadoc on
PCollectionViewAssertstill mentions that side input support is required from the runner.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
💬 Inline Findings
sdks/java/core/src/main/java/org/apache/beam/sdk/testing/PAssert.java(line 1092): 🟢 Nit: The Javadoc onPCollectionViewAssertstill statesThis requires side input support from the runner., which is no longer true after this change. Consider updating it to matchPCollectionContentsAssert/PCollectionSingletonAssert(This does not require the runner to support side inputs.).
* type {@code ViewT}. This does not require the runner to support side inputs.
|
Assigning reviewers: R: @ahmedabu98 for label java. This pull request likely touches a core component ("core" label). Please review with scrutiny. 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). |
Fixes #19351
PAssert.thatMapandPAssert.thatMultimapwere the only PAssert entry points still built on a side input:PCollectionViewAssertmaterializedView.asMap()/View.asMultimap()and read it inOneSideInputAssert. Every other assertion groups the contents withGroupThenAssert.Changes:
PCollectionViewAssertnow takes a function that builds the map from the grouped contents (GroupedToMap,GroupedToMultimap) and appliesGroupThenAssert, so windowing and pane selection (inWindow,inOnlyPane, ...) go through the same path as the other asserts.thatMapstill fail ("Duplicate values for key ..."), now as an assertion failure, not a side input error.CreateActualis removed.OneSideInputAssertis public, so it is marked@Deprecatedinstead of removed; it can go in a later release along with its checks inTestPipelineandcountAsserts.Tests:
PAssertTest:testThatMap,testThatMapNotEqualFails,testThatMapDuplicateKeysFails,testThatMultimap, andtestThatMapDoesNotUseSideInputs, which fails on master (PAssert$0/CreateActual/View.AsMap/View.CreatePCollectionView).PAssertTestpasses on the direct runner (needsRunnerTests) and as unit tests.thatMap/thatMultimapcallers pass:CoGroupByKeyTest,DirectRunnerTest, theDataflowRunnerTestGroupIntoBatches override tests, andLeaderBoardTest.