Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move date typecasts into stg models #40

Closed
katy-sadowski opened this issue Jun 19, 2024 · 2 comments
Closed

Move date typecasts into stg models #40

katy-sadowski opened this issue Jun 19, 2024 · 2 comments
Assignees

Comments

@katy-sadowski
Copy link
Collaborator

There are repeated typecasts of timestamp-->date in the OMOP models. To DRY up the code we can move these into the original stg models by creating a _date column in those models and carrying it through to the final models.

For example:

, {{ dbt.safe_cast("drug_exposure_start_date", api.Column.translate_type("date")) }} AS drug_exposure_start_date

@katy-sadowski
Copy link
Collaborator Author

@lawrenceadams , I have addressed this Issue in commit ae79114

I accidentally pushed to main 🙈 I had branch protections relaxed for myself in the early days and forgot I was working on main. I have added these back now so I won't be able to do that in the future...oopsie! It runs and passes all tests on duckdb and Postgres. If you'd like to take a look / test the changes please do! What I did:

  • Moved casts upstream where applicable to reduce repetition
  • Changed all casts to use dbt.cast
  • Spotted a couple other opportunities to use dbt macros (datediff, dateadd)
  • Renamed some columns to indicate that they're datetimes, not dates (holdover from ETL-Synthea)

@lawrenceadams
Copy link
Collaborator

Oops! easily done (have done it myself before)!!

Excellent commit! 💪

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants