Stream: fhirpath
Topic: union
Paul Lynch (Sep 06 2018 at 16:46):
The spec for union (5.4.1) says, "Merge the two collections into a single collection, eliminating any duplicate values...." Does that mean that the resulting collection has no duplicates, or only that no duplicates were introduced by the union? For, instance if collection "a" contains duplicates already, say [1, 1, 2], and collection b is [2, 3] , and I do "a | b", will the result be [1, 1, 2, 3] or [1, 2, 3]?
Josh Mandel (Sep 06 2018 at 16:47):
[1, 2, 3] is the only way I can read it.
Josh Mandel (Sep 06 2018 at 16:47):
Is there a test case that covers this situation?
Paul Lynch (Sep 06 2018 at 19:20):
My code agrees with [1, 2, 3], but it would not be difficult to implement the other way, and it is not clear to me which interpretation is best. I added GF#17812.
Grahame Grieve (Sep 06 2018 at 22:01):
there should be a test case - have you looked at the test cases?
Paul Lynch (Sep 06 2018 at 22:11):
In the "testUnion" group in https://github.com/hl7-fhir/fhir-svn/blob/master/tests/resources/tests-fhir-r4.xml, I do not see a test case that covers this situation.
Grahame Grieve (Sep 06 2018 at 22:17):
1.combine(1).union(2).count() = 2
Paul Lynch (Sep 06 2018 at 22:19):
Yes, good. I was ignoring the tests with "combine" for some reason. That covers it. So, then union removes all duplicates.
Grahame Grieve (Sep 06 2018 at 22:41):
yes
Last updated: Apr 12 2022 at 19:14 UTC