Skip to content

Conversation

@piotrszul
Copy link
Collaborator

Resolves #2398.

piotrszul and others added 7 commits December 10, 2025 14:13
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>
@github-project-automation github-project-automation bot moved this to Backlog in Pathling Dec 17, 2025
@piotrszul piotrszul moved this from Backlog to In progress in Pathling Dec 17, 2025
@sonarqubecloud
Copy link

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

Labels

None yet

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

Support union operator

2 participants