Repository navigation
Name the grouping key in PAssert.GroupGlobally - #41734
harshilv17 wants to merge 1 commit 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"; |
Fixes #18257.
PAssert.GroupGloballygrouped every element under a localfinal int combinedKey = 42;, which reads as if the value mattered when debugging ValidatesRunner tests. It is now a documentedprivate static final int SINGLETON_KEYonGroupGlobally, used at the same three places. The value stays 42, so the pipeline PAssert builds is unchanged.Ran
PAssertTestlocally with JDK 17;compileJavaandcheckstyleMainare clean.Fixes #18257).CHANGES.md: not needed, no behavior change.