Repository navigation
Name the grouping key in PAssert.GroupGlobally - #41734
harshilv17 wants to merge 2 commits into
Conversation
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
There was a problem hiding this comment.
📋 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
42as the key during runtime debugging ofValidatesRunnertests is confusing, and suggested replacing the integer key42with a descriptive string key such as"PAssert-global-key"(updating the correspondingPCollection<KV<String, ...>>types inGroupGlobally). Simply renaming the variable in source code while keeping the runtime value42leaves 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; |
There was a problem hiding this comment.
🟠 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, ...>.
| private static final int SINGLETON_KEY = 42; | |
| private static final String SINGLETON_KEY = "PAssert-global-key"; |
There was a problem hiding this comment.
Good point, the value is what shows up in the elements. Changed in the latest commit: SINGLETON_KEY is now the string "PAssert-global-key" and GroupGlobally uses KV<String, ...> throughout. PAssertTest (including its 26 NeedsRunner tests on the direct runner) passes.
|
Assigning reviewers: R: @damccorm 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). |
The confusion in apache#18257 comes from seeing the key 42 in the elements of a running pipeline. Key GroupGlobally on the string "PAssert-global-key" instead, so the grouped elements say what they are.
Fixes #18257.
PAssert.GroupGloballygrouped every element under a localfinal int combinedKey = 42;. When debugging ValidatesRunner tests the bare42shows up in the groupedKVelements and reads as if it meant something. It is now a documentedprivate static final String SINGLETON_KEY = "PAssert-global-key"onGroupGlobally, and the grouped collections areKV<String, ...>instead ofKV<Integer, ...>.Ran
PAssertTestlocally with JDK 17, including its 26 NeedsRunner tests on the direct runner (:runners:direct-java:needsRunnerTests);compileJavaandcheckstyleMainare clean.Fixes #18257).CHANGES.md: not needed, no behavior change.