Skip to content

Name the grouping key in PAssert.GroupGlobally - #41734

Open
harshilv17 wants to merge 1 commit into
apache:masterfrom
harshilv17:fix/18257-passert-grouping-key
Open

harshilv17 wants to merge 1 commit into
apache:masterfrom
harshilv17:fix/18257-passert-grouping-key

Conversation

@harshilv17

Copy link
Copy Markdown
Contributor

Fixes #18257.

PAssert.GroupGlobally grouped every element under a local final int combinedKey = 42;, which reads as if the value mattered when debugging ValidatesRunner tests. It is now a documented private static final int SINGLETON_KEY on GroupGlobally, used at the same three places. The value stays 42, so the pipeline PAssert builds is unchanged.

Ran PAssertTest locally with JDK 17; compileJava and checkstyleMain are clean.

  • Small/focused contribution (ICLA not required).
  • Mentions the issue (Fixes #18257).
  • CHANGES.md: not needed, no behavior change.

PAssert grouped every element under the bare literal 42, which reads as
if the value mattered when debugging ValidatesRunner tests. Make it a
documented SINGLETON_KEY constant. The value is unchanged.

Fixes apache#18257
@github-actions github-actions Bot added java core size/s S: 10-49 lines changed labels Nov 28, 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 extracts the local variable combinedKey = 42 in PAssert.GroupGlobally into a private static final int SINGLETON_KEY = 42 constant. However, this does not actually address the root cause of #18257 (originally BEAM-1854), which is that the runtime key value 42 itself causes confusion when inspecting keyed elements while debugging ValidatesRunner tests.

🔍 General Feedback

  • In BEAM-1854, the reporter noted that seeing 42 as the key during runtime debugging of ValidatesRunner tests is confusing, and suggested replacing the integer key 42 with a descriptive string key such as "PAssert-global-key" (updating the corresponding PCollection<KV<String, ...>> types in GroupGlobally). Simply renaming the variable in source code while keeping the runtime value 42 leaves the debugging experience unchanged.

💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.

* The single key all elements are grouped under so the assertion sees them together. Its value
* has no meaning.
*/
private static final int SINGLETON_KEY = 42;

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.

🟠 High: Per the original issue context in BEAM-1854, the confusion when debugging ValidatesRunner tests comes from seeing the runtime key value 42 in KV<Integer, ...> elements during pipeline execution, rather than the local variable name in PAssert.java.

As suggested by the issue author in BEAM-1854, please replace the integer 42 with a self-explanatory string constant (e.g., "PAssert-global-key") and update the corresponding KV<Integer, ...> type parameters in GroupGlobally#expand to KV<String, ...>.

Suggested change
private static final int SINGLETON_KEY = 42;
private static final String SINGLETON_KEY = "PAssert-global-key";

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

Labels

core java size/s S: 10-49 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace the magic number 42 in PAssert.

1 participant