Merged PR 3491: Allows possibility to retrieve claim as date or timestamp

# Description

Allows code to retrieve NewDashMoveDate in the case of being a date or a timestamp.

# Checklist

- [X] The edited models and dependants run properly with production data.
- [X] The edited models are sufficiently documented.
- [X] The edited models contain PK tests, and I've ran and passed them.
- [NA] I have checked for DRY opportunities with other models and docs.
- [NA] I've picked the right materialization for the affected models.

# Other

- [ ] Check if a full-refresh is required after this PR is merged.

Allows possibility to retrieve claim as date or timestamp

Related work items: #23980
This commit is contained in:
Oriol Roqué Paniagua 2024-11-13 11:42:04 +00:00
parent cce5d2b9d6
commit 3b822a2ea5

View file

@ -16,10 +16,18 @@ with
ndu.new_dash_version,
min(
case
-- If the claim_value contains a date, cast the date as timestamp
-- at 00:00:00
when
claim_value
~ '^(20\d{2})-(0[1-9]|1[0-2])-(0[1-9]|1\d|2\d|3[01])$'
then cast(date(claim_value) as timestamp)
-- If the claim_value contains a timestamp, retrieve the timestamp
when
claim_value
~ '^(20\d{2})-(0[1-9]|1[0-2])-(0[1-9]|1\d|2\d|3[01])\s([01]\d|2[0-3]):([0-5]\d):([0-5]\d)$'
then cast(claim_value as timestamp)
-- Return null otherwise
else null
end
) as new_dash_move_at_utc