Skip to content

Commit

Permalink
Add failing test for #1770
Browse files Browse the repository at this point in the history
  • Loading branch information
johngrimes committed Oct 24, 2023
1 parent 6d28d10 commit 2de6eae
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Row> result = executor.buildQuery(request);
assertThat(result)
.debugAllRows();
result.printSchema();
}

@Test
void emptyColumn() {
subjectResource = ResourceType.PATIENT;
Expand Down
28 changes: 28 additions & 0 deletions lib/python/tests/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 2de6eae

Please sign in to comment.