Skip to content

Check PAssert.thatMap and thatMultimap without side inputs - #41878

Open
harshilv17 wants to merge 1 commit into
apache:masterfrom
harshilv17:fix/19351-passert-map-off-side-inputs
Open

harshilv17 wants to merge 1 commit into
apache:masterfrom
harshilv17:fix/19351-passert-map-off-side-inputs

Conversation

@harshilv17

Copy link
Copy Markdown
Contributor

Fixes #19351

PAssert.thatMap and PAssert.thatMultimap were the only PAssert entry points still built on a side input: PCollectionViewAssert materialized View.asMap() / View.asMultimap() and read it in OneSideInputAssert. Every other assertion groups the contents with GroupThenAssert.

Changes:

  • PCollectionViewAssert now takes a function that builds the map from the grouped contents (GroupedToMap, GroupedToMultimap) and applies GroupThenAssert, so windowing and pane selection (inWindow, inOnlyPane, ...) go through the same path as the other asserts.
  • Duplicate keys in thatMap still fail ("Duplicate values for key ..."), now as an assertion failure, not a side input error.
  • The private CreateActual is removed. OneSideInputAssert is public, so it is marked @Deprecated instead of removed; it can go in a later release along with its checks in TestPipeline and countAsserts.
  • CHANGES.md: Deprecations entry.

Tests:

  • New in PAssertTest: testThatMap, testThatMapNotEqualFails, testThatMapDuplicateKeysFails, testThatMultimap, and testThatMapDoesNotUseSideInputs, which fails on master (PAssert$0/CreateActual/View.AsMap/View.CreatePCollectionView).
  • PAssertTest passes on the direct runner (needsRunnerTests) and as unit tests.
  • Existing thatMap/thatMultimap callers pass: CoGroupByKeyTest, DirectRunnerTest, the DataflowRunnerTest GroupIntoBatches override tests, and LeaderBoardTest.

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.
@github-actions github-actions Bot added java core size/m M: 50-249 lines changed labels Dec 2, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📋 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 OneSideInputAssert to GroupThenAssert via GroupedToMap and GroupedToMultimap simplifies the pipeline graph for map assertions and unifies window/pane extraction across all PAssert entry points.
  • Minor cleanup: the class-level Javadoc on PCollectionViewAssert still 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 on PCollectionViewAssert still states This requires side input support from the runner., which is no longer true after this change. Consider updating it to match PCollectionContentsAssert / PCollectionSingletonAssert (This does not require the runner to support side inputs.).
   * type {@code ViewT}. This does not require the runner to support side inputs.

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @ahmedabu98 for label java.
Backup reviewer: kennknowles (if the main reviewer is unresponsive, you can escalate to them by tagging their username)

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 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.

Can we deprecate the side input paths through PAssert?

1 participant