Skip to content
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

#1441: Fixes for Union #1480

Merged
merged 3 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public Object visitUnion(Union elm, State state) {
(org.opencds.cqf.cql.engine.runtime.Interval) rightResult,
state);
} else {
return UnionEvaluator.union(left, right, state);
return UnionEvaluator.union(leftResult, rightResult, state);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.List;
Expand All @@ -12,10 +13,17 @@ class TestUnion extends CqlTestBase {
@Test
void union() {
var results = engine.evaluate(toElmIdentifier("TestUnion"));
var value = results.forExpression("NullAndNull").value();

var value = results.forExpression("NullAndNullList").value();
assertNotNull(value);
assertTrue(((List<?>) value).isEmpty());

value = results.forExpression("NullAndNullInterval").value();
assertNull(value);

value = results.forExpression("NullAndNullUntyped").value();
assertNull(value);

value = results.forExpression("NullAndEmpty").value();
assertNotNull(value);
assertTrue(((List<?>) value).isEmpty());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
library TestUnion

// expect {}
define "NullAndNull":
define "NullAndNullList":
null as List<Integer> union null as List<Integer>

// expect null
define "NullAndNullInterval":
null as Interval<Integer> union null as Interval<Integer>

// expect null
// Based on the CQL conversion precedence rules,
// the compiler _should have_ inferred this as Intervals
// and not Lists.
define "NullAndNullUntyped":
null union null

// expect {}
define "NullAndEmpty":
null union {}
Expand Down
Loading