From 2de6eae98ae2b41dca9af564beccb9ed5c250eeb Mon Sep 17 00:00:00 2001 From: John Grimes Date: Tue, 24 Oct 2023 16:25:34 +1000 Subject: [PATCH] Add failing test for #1770 --- .../pathling/extract/ExtractQueryTest.java | 16 +++++++++++ lib/python/tests/test_query.py | 28 +++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/fhir-server/src/test/java/au/csiro/pathling/extract/ExtractQueryTest.java b/fhir-server/src/test/java/au/csiro/pathling/extract/ExtractQueryTest.java index e654d1def5..22f1e1f81b 100644 --- a/fhir-server/src/test/java/au/csiro/pathling/extract/ExtractQueryTest.java +++ b/fhir-server/src/test/java/au/csiro/pathling/extract/ExtractQueryTest.java @@ -332,6 +332,22 @@ void multipleNonSingularColumnsWithDifferentTypes() { "responses/ExtractQueryTest/multipleNonSingularColumnsWithDifferentTypes.csv"); } + @Test + void issue1770() { + subjectResource = ResourceType.OBSERVATION; + mockResource(subjectResource); + + final ExtractRequest request = new ExtractRequestBuilder(subjectResource) + .withColumn("id") + .withColumn("valueQuantity.value") + .build(); + + final Dataset result = executor.buildQuery(request); + assertThat(result) + .debugAllRows(); + result.printSchema(); + } + @Test void emptyColumn() { subjectResource = ResourceType.PATIENT; diff --git a/lib/python/tests/test_query.py b/lib/python/tests/test_query.py index 6a1f5440de..e03f1bd4c6 100644 --- a/lib/python/tests/test_query.py +++ b/lib/python/tests/test_query.py @@ -28,6 +28,13 @@ def test_data_source(pathling_ctx, test_data_dir): return pathling_ctx.read.ndjson(os.path.join(test_data_dir, "ndjson")) +@fixture(scope="module") +def test_bundles_data_source(pathling_ctx, test_data_dir): + return pathling_ctx.read.bundles( + os.path.join(test_data_dir, "bundles"), resource_types=["Observation"] + ) + + def test_extract(test_data_source): result = test_data_source.extract( "Patient", @@ -85,6 +92,27 @@ def test_extract_no_filters(test_data_source): ) +def test_extract_issue_1770(test_bundles_data_source): + result = test_bundles_data_source.extract( + "Observation", + columns=[ + Expression("id", "Identifier"), + Expression("valueQuantity.value", "Value_Quantity"), + ], + ) + + # noinspection PyPep8Naming + ExtractRow = Row("Identifier", "Value_Quantity") + + assert_result( + [ + ExtractRow("e1f0e0c0-0f2e-4e1f-8e1a-0e1f0e0c0f2e", 0.0), + ExtractRow("e1f0e0c0-0f2e-4e1f-8e1a-0e1f0e0c0f2e", 0.0), + ], + result.orderBy("Identifier", "Value_Quantity").limit(2).collect(), + ) + + def test_aggregate(test_data_source): agg_result = test_data_source.aggregate( "Patient",