Skip to content

Commit e2add69

Browse files
authored
fix(recency): handle empty tables returning NULL (dbt-labs#1065)
When a table is empty, MAX(field) returns NULL. The comparison NULL < threshold evaluates to NULL (not TRUE), causing the WHERE clause to filter out the row and incorrectly pass the test. This fix adds 'OR most_recent IS NULL' to properly fail the test when a table has no data within the recency window, including when the table is completely empty.
1 parent ef562ba commit e2add69

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

macros/generic_tests/recency.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@ select
3737

3838
from recency
3939
where most_recent < {{ threshold }}
40+
or most_recent is null
4041

4142
{% endmacro %}

0 commit comments

Comments
 (0)