You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the event_time column is NULL or the table is truncated, the following situation occurs:
• When event_time is NULL, the query select * from stg_source_table where event_time > NULL returns no results because the condition evaluates to NULL.
• This results in no data being loaded, and dbt considers it an incremental load, which can lead to model failure.
Currently, dbt does not handle this edge case, which can cause issues during incremental loads.
Thanks, @mirnawong1 for the advice to open an issue in dbt core as suggested in PR
Expected Behavior
dbt should handle this edge case by ensuring that if event_time is NULL or the table is truncated, the incremental load does not fail. Suggested improvements include adding logic to handle NULL values in the event_time column. As suggested by @mirnawong1 in the PR
Steps To Reproduce
{{
config(
materialized='incremental',
unique_key='date_day'
)
}}
select
date_trunc('day', event_at) as date_day,
count(distinct user_id) as daily_active_users
from {{ ref('app_data_events') }}
{% if is_incremental() %}
-- this filter will only be applied on an incremental run-- (uses >= to include records arriving later on the same day as the last run of this model)where date_day >= (select event_time from {{ this }})
{% endif %}
group by1
Truncate the destination table.
As the table already exists in the database schema. dbt considers it as the incremental load.
Where condition date_day >= NULL it is always True and returns No result. It will leads to No data load
It's edge case that has to handled in the dbt.
To handle this case I have added the sample code in the dbt documentation Doc Link
Relevant log output
No response
Environment
- OS:
- Python:
- dbt:
Which database adapter are you using with dbt?
snowflake
Additional Context
No response
The text was updated successfully, but these errors were encountered:
dbeatty10
changed the title
Incremental Strategy - Edge Case Safeguarding on Merge Incremental Model
[Feature] Incremental Strategy - Edge Case Safeguarding on Merge Incremental Model
Jul 15, 2024
Is this a new bug in dbt-core?
Current Behavior
Edge Case Safeguarding in dbt Core Incremental Merge Stragerty
Refer this Documentation
If the event_time column is NULL or the table is truncated, the following situation occurs:
• When event_time is NULL, the query select * from stg_source_table where event_time > NULL returns no results because the condition evaluates to NULL.
• This results in no data being loaded, and dbt considers it an incremental load, which can lead to model failure.
Currently, dbt does not handle this edge case, which can cause issues during incremental loads.
Thanks, @mirnawong1 for the advice to open an issue in dbt core as suggested in PR
Expected Behavior
dbt should handle this edge case by ensuring that if event_time is NULL or the table is truncated, the incremental load does not fail. Suggested improvements include adding logic to handle NULL values in the event_time column. As suggested by @mirnawong1 in the PR
Steps To Reproduce
Relevant log output
No response
Environment
Which database adapter are you using with dbt?
snowflake
Additional Context
No response
The text was updated successfully, but these errors were encountered: