Skip to content

Commit

Permalink
testing datetime interval
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaszanotelli committed Dec 11, 2023
1 parent f49cc18 commit f9de057
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions models/marts/enriched_history_operations.sql
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ with
, batch_insert_ts
from {{ ref('stg_history_ledgers') }}
where
cast(batch_run_date as date) < date_add(date('{{ dbt_airflow_macros.ds() }}'), interval 2 day)
and date(closed_at) < date_add(date('{{ dbt_airflow_macros.ds() }}'), interval 1 day)
batch_run_date < date_add(TIMESTAMP '{{ dbt_airflow_macros.ts() }}', interval 60 minute)
and closed_at < date_add(TIMESTAMP '{{ dbt_airflow_macros.ts() }}', interval 30 minute)
{% if is_incremental() %}
and cast(batch_run_date as date) >= date('{{ dbt_airflow_macros.ds() }}') -- batch run is the min bound of a batch
and date(closed_at) >= date_sub(date('{{ dbt_airflow_macros.ds() }}'), interval 1 day)
and batch_run_date >= TIMESTAMP '{{ dbt_airflow_macros.ts() }}' -- batch run is the min bound of a batch
and closed_at >= date_sub(TIMESTAMP '{{ dbt_airflow_macros.ts() }}', interval 30 minute)
{% endif %}
)

Expand Down Expand Up @@ -70,11 +70,11 @@ with
, batch_insert_ts
from {{ ref('stg_history_transactions') }}
where
cast(batch_run_date as date) < date_add(date('{{ dbt_airflow_macros.ds() }}'), interval 2 day)
and date(closed_at) < date_add(date('{{ dbt_airflow_macros.ds() }}'), interval 1 day)
batch_run_date < date_add(TIMESTAMP '{{ dbt_airflow_macros.ts() }}', interval 60 minute)
and closed_at < date_add(TIMESTAMP '{{ dbt_airflow_macros.ts() }}', interval 30 minute)
{% if is_incremental() %}
and cast(batch_run_date as date) >= date('{{ dbt_airflow_macros.ds() }}') -- batch run is the min bound of a batch
and date(closed_at) >= date_sub(date('{{ dbt_airflow_macros.ds() }}'), interval 1 day)
and batch_run_date >= TIMESTAMP '{{ dbt_airflow_macros.ts() }}' -- batch run is the min bound of a batch
and closed_at >= date_sub(TIMESTAMP '{{ dbt_airflow_macros.ts() }}', interval 30 minute)
{% endif %}
)

Expand Down Expand Up @@ -190,11 +190,11 @@ with
, batch_insert_ts
from {{ ref('stg_history_operations') }}
where
cast(batch_run_date as date) < date_add(date('{{ dbt_airflow_macros.ds() }}'), interval 2 day)
and date(closed_at) < date_add(date('{{ dbt_airflow_macros.ds() }}'), interval 1 day)
batch_run_date < date_add(TIMESTAMP '{{ dbt_airflow_macros.ts() }}', interval 60 minute)
and closed_at < date_add(TIMESTAMP '{{ dbt_airflow_macros.ts() }}', interval 30 minute)
{% if is_incremental() %}
and cast(batch_run_date as date) >= date('{{ dbt_airflow_macros.ds() }}') -- batch run is the min bound of a batch
and date(closed_at) >= date_sub(date('{{ dbt_airflow_macros.ds() }}'), interval 1 day)
and batch_run_date >= TIMESTAMP '{{ dbt_airflow_macros.ts() }}' -- batch run is the min bound of a batch
and closed_at >= date_sub(TIMESTAMP '{{ dbt_airflow_macros.ts() }}', interval 30 minute)
{% endif %}

)
Expand Down

0 comments on commit f9de057

Please sign in to comment.