-
Notifications
You must be signed in to change notification settings - Fork 17
Implement support for union operator #2526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
piotrszul
wants to merge
7
commits into
main
Choose a base branch
from
issue/2398
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Implements the FHIRPath union operator (|) for Boolean, Integer, and String types using Spark's array_union() function for deduplication. Key changes: - Add UnionOperator class extending SameTypeBinaryOperator - Enhance SameTypeBinaryOperator with handleOneEmpty() hook for custom empty collection semantics - Register union operator in BinaryOperatorType enum - Enable union expression parsing in Visitor - Add comprehensive DSL test suite with 61 test cases covering empty collections, single values, arrays, and grouped expressions - Add test exclusion for cross-type unions not yet supported Per FHIRPath spec, union eliminates duplicates using equality semantics, and unioning with an empty collection returns the non-empty collection with duplicates eliminated. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
feat: Add DecimalCollection support to union operator Implements union operator (|) for decimal values by normalizing decimal precision to DECIMAL(32,6) before merging. This enables union operations on decimals with different precisions and mixing of integer and decimal values. Changes: - Add normalizeDecimalType() method to DecimalCollection for type compatibility - Add getArrayForUnion() helper in UnionOperator using Java 21 pattern matching - Refactor union operations to use new helper method - Add comprehensive test coverage for decimal unions including precision variations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Implements the FHIRPath union operator (|) for Boolean, Integer, and String types using Spark's array_union() function for deduplication. Key changes: - Add UnionOperator class extending SameTypeBinaryOperator - Enhance SameTypeBinaryOperator with handleOneEmpty() hook for custom empty collection semantics - Register union operator in BinaryOperatorType enum - Enable union expression parsing in Visitor - Add comprehensive DSL test suite with 61 test cases covering empty collections, single values, arrays, and grouped expressions - Add test exclusion for cross-type unions not yet supported Per FHIRPath spec, union eliminates duplicates using equality semantics, and unioning with an empty collection returns the non-empty collection with duplicates eliminated. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Extends the union operator (|) to support QuantityCollection using custom equality semantics. The implementation uses aggregate-based deduplication with ifnull() to properly handle non-comparable quantities (e.g., different dimensions like 'cm' vs 'cm2', or indefinite calendar durations like '1 year' vs '12 months'). Key changes: - Add deduplicateWithEquality() helper using Spark aggregate() function - Handle QuantityCollection in both handleOneEmpty() and handleEquivalentTypes() - Add asStringCollection() to QuantityCollection for test framework - Add comprehensive test suite with 13 Quantity union test cases - Add exclusion for indefinite calendar duration union deduplication - Update all union tests to follow singular/plural pattern The first element is retained when quantities are equal (same dimension and normalized value), and both values are kept when they are non-comparable (equality returns NULL). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Extends union operator (|) to support Coding type with custom equality semantics based on system, code, version, display, and userSelected fields. Follows the same pattern as QuantityCollection using aggregate- based deduplication. Changes: - UnionOperator: Added CodingCollection type checks and custom equality - CodingCollection: Added asStringCollection() for test formatting - DefaultYamlTestExecutor: Extended result formatting for Coding types - CombiningOperatorsDslTest: Added 17 comprehensive test cases All tests pass: 112/112 CombiningOperatorsDslTest, 1821/1821 YamlReferenceImplTest 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Extends union operator (|) to support Time type with precision-aware equality semantics via TemporalComparator. Times with different precisions are treated as incomparable and both are retained in the union. Changes: - UnionOperator: Added TimeCollection type checks and custom equality - TimeCollection: Added asStringCollection() for test formatting - DefaultYamlTestExecutor: Extended result formatting for Time types - CombiningOperatorsDslTest: Added 23 comprehensive test cases covering same precision, different precision, and mixed precision scenarios All tests pass: 135/135 CombiningOperatorsDslTest, 1821/1821 YamlReferenceImplTest 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Implements union operator (|) for Date and DateTime types with precision-aware equality for deduplication. Date and DateTime types can be unioned together with implicit type promotion, but values remain incomparable due to precision differences. Key changes: - Added DateCollection and DateTimeCollection support to UnionOperator - Both types use custom equality via deduplicateWithEquality() for precision-aware comparison - Added castAs() method to DateCollection for Date to DateTime type promotion - Migrated test expectations to FhirTypedLiteral pattern using toDate(), toDateTime(), toTime(), and toCoding() helpers - Added comprehensive Date, DateTime, and Date/DateTime union tests covering precision handling, empty collections, arrays, and nested expressions - Restored QuantityCollection special handling in DefaultYamlTestExecutor Test coverage: - 175 tests passing in CombiningOperatorsDslTest - All YamlReferenceImplTest cases passing with expected exclusions Resolves #2398 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Refactors UnionOperator to eliminate explicit instanceof checks on collection types by using comparator detection instead. This makes the code more maintainable, extensible, and follows the open/closed principle. Key changes: - Add usesDefaultSqlEquality() marker method to ColumnEquality interface - Extract array operations to SqlFunctions utility methods: - arrayDistinctWithEquality() for custom equality deduplication - arrayUnionWithEquality() for custom equality merging - Refactor UnionOperator to use comparator detection via usesDefaultSqlEquality() instead of explicit collection type checks - Update class documentation to describe behavior in terms of type reconciliation and equality semantics Benefits: - Polymorphic: uses comparator type instead of collection type - Extensible: new collection types require no UnionOperator changes - Reusable: SqlFunctions methods available for other operators - Maintainable: clear separation of concerns All 175 tests in CombiningOperatorsDslTest pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.



Resolves #2398.