[Java SDK] Warn when ValueState contains collection types#37523
[Java SDK] Warn when ValueState contains collection types#37523PDGGK wants to merge 4 commits intoapache:masterfrom
Conversation
This change fixes the validation logic in IcebergScanConfig to support nested column paths using dot notation (e.g., "data.name"). Previously, the validation only checked top-level column names, causing nested paths like "colA.colB" to fail with "unknown field(s)" error. The fix uses Iceberg's Schema.findField() which natively resolves dot-notation paths for nested fields. Fixes apache#37486
- Use TypeUtil.indexByName() to enumerate all field paths - Only select leaf fields to prevent parent struct from including dropped children - Add test for nested drop validation
When users declare ValueState<Map>, ValueState<List>, or ValueState<Set>, log a warning suggesting they use MapState, BagState, or SetState instead. Storing collections in ValueState requires reading and writing the entire collection on each access, which can cause performance issues for large collections. The specialized state types provide better performance. Fixes apache#36746
Summary of ChangesHello @PDGGK, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request improves developer guidance in the Apache Beam Java SDK by introducing a warning for inefficient Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment |
|
Closing to recreate with clean branch (previous branch had unrelated Iceberg changes mixed in) |
Summary
This PR adds a warning when users declare
ValueStatewith collection types (Map,List,Set) that could benefit from using specialized state types for better performance.Problem:
When users store collections in
ValueState, the entire collection must be read and written on each access. This can cause significant performance issues for large collections.Solution:
Log a warning during pipeline construction suggesting:
ValueState<Map>→ UseMapStateinsteadValueState<List>→ UseBagStateorOrderedListStateinsteadValueState<Set>→ UseSetStateinsteadChanges:
DoFnSignatures.java: AddedwarnIfValueStateContainsCollection()method that inspects state declarations and logs warnings for collection typesDoFnSignaturesTest.java: Added test cases to verify the warning logic works correctlyFixes #36746
Test plan
ValueState<Map>,ValueState<List>,ValueState<Set>ValueState<String>(no warning expected)🤖 Generated with Claude Code