File tree Expand file tree Collapse file tree 3 files changed +29
-0
lines changed
integration_tests/models/generic_tests Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Original file line number Diff line number Diff line change 1+ -- Test model with data that's intentionally old
2+ -- This simulates a scenario where we have data but it's all outside the recency window
3+ -- this should fail with a where clause but currently it would pass
4+ select
5+ 1 as id,
6+ {{ dbt .dateadd (' day' , - 10 , dbt .current_timestamp ()) }} as created_at
7+
8+ union all
9+
10+ select
11+ 2 as id,
12+ {{ dbt .dateadd (' day' , - 15 , dbt .current_timestamp ()) }} as created_at
Original file line number Diff line number Diff line change @@ -261,3 +261,19 @@ models:
261261 compare_model : ref('data_test_equality_a')
262262 exclude_columns :
263263 - col_c
264+
265+ - name : recency_with_where_filter
266+ data_tests :
267+ # This test should FAIL and return 0 rows (test failure) because when we filter to id = 3,
268+ # no records match the where condition, so most_recent will be null.
269+ # Before the fix: test would incorrectly PASS (no rows returned)
270+ # After the fix: test should correctly FAIL (returns the null row)
271+ - dbt_utils.recency :
272+ datepart : day
273+ field : created_at
274+ ignore_time_component : true
275+ interval : 5
276+ config :
277+ where : " id = 3" # This filters to no records since only id 1,2 exist
278+ error_if : " <1"
279+ warn_if : " <0"
Original file line number Diff line number Diff line change 3737
3838from recency
3939where most_recent < {{ threshold }}
40+ or most_recent is null
4041
4142{% endmacro %}
You can’t perform that action at this time.
0 commit comments