Skip to content

Commit

Permalink
refactor: use datediff macro over extracting day from timedelta
Browse files Browse the repository at this point in the history
 - various sql engines do not allow interval extraction from delta (as deltas are passed as numeric types); concretely: snowflake, likely others
 - use the dbt standard datediff macro to open up possibility to other sql engines
 - arguably more idiomatic
 - bring in line with other recent changes by @katy-sadowski
  • Loading branch information
lawrenceadams committed Oct 6, 2024
1 parent ae79114 commit 5c2cf10
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions models/omop/drug_era.sql
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,7 @@ WITH ctePreDrugTarget AS (
, drug_sub_exposure_start_date
, drug_sub_exposure_end_date
, drug_exposure_count
, EXTRACT(
DAY FROM drug_sub_exposure_end_date - drug_sub_exposure_start_date
) AS days_exposed
, {{ dbt.datediff("drug_sub_exposure_start_date", "drug_sub_exposure_end_date", "day") }} AS days_exposed
FROM cteSubExposures
)

Expand Down

0 comments on commit 5c2cf10

Please sign in to comment.