Skip to content

Commit

Permalink
Fix problem with conversion of timestamp to milliseconds
Browse files Browse the repository at this point in the history
  • Loading branch information
johngrimes committed Jun 19, 2024
1 parent 6359423 commit 82acfd2
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -168,7 +169,11 @@ public void expectResult(@Nonnull final Dataset<Row> 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()))
Expand Down

0 comments on commit 82acfd2

Please sign in to comment.