From 82acfd21e19a09322aa899b3dd7c0ec4479d5d0d Mon Sep 17 00:00:00 2001 From: John Grimes Date: Wed, 19 Jun 2024 16:36:37 +1000 Subject: [PATCH] Fix problem with conversion of timestamp to milliseconds --- .../test/java/au/csiro/pathling/views/FhirViewTest.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fhirpath/src/test/java/au/csiro/pathling/views/FhirViewTest.java b/fhirpath/src/test/java/au/csiro/pathling/views/FhirViewTest.java index b4612e10e8..f6fd9bc8a5 100644 --- a/fhirpath/src/test/java/au/csiro/pathling/views/FhirViewTest.java +++ b/fhirpath/src/test/java/au/csiro/pathling/views/FhirViewTest.java @@ -7,6 +7,7 @@ import static java.util.Objects.nonNull; import static org.apache.spark.sql.functions.callUDF; import static org.apache.spark.sql.functions.col; +import static org.apache.spark.sql.functions.unix_timestamp; import static org.apache.spark.sql.functions.when; import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -168,7 +169,11 @@ public void expectResult(@Nonnull final Dataset rowDataset) { // Normalize anything that looks like a date time, otherwise pass it through unaltered. return when( col(field.name()).rlike(FHIR_DATE_TIME_PATTERN), - callUDF(NormalizeDateTimeFunction.FUNCTION_NAME, col(field.name())) + // Convert the timestamp to milliseconds, so that it is the same type as a + // normalized time. + unix_timestamp( + callUDF(NormalizeDateTimeFunction.FUNCTION_NAME, col(field.name()))) + .multiply(1000) ).when( col(field.name()).rlike(FHIR_TIME_PATTERN), callUDF(NormalizeTimeFunction.FUNCTION_NAME, col(field.name()))