Recency test to fail when no recent records are found#1051
Closed
marzaccaro wants to merge 1 commit intodbt-labs:mainfrom
Closed
Recency test to fail when no recent records are found#1051marzaccaro wants to merge 1 commit intodbt-labs:mainfrom
marzaccaro wants to merge 1 commit intodbt-labs:mainfrom
Conversation
13e913a to
8eabbe5
Compare
8eabbe5 to
3d865af
Compare
Author
|
closing as this is resolved by #1065 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
resolves #1041
Problem
The
dbt_utils.recencytest incorrectly passes when awhereclause filtersout all records.
Current behavior: When a
whereclause results in no matching records,most_recentbecomesNULL. The test only checkswhere most_recent < {{ threshold }}, but sinceNULL < thresholdevaluates toNULL(not true), norows are returned and the test incorrectly passes.
Expected behavior: The test should fail when no recent data exists (even
when filtered by a where clause), indicating missing recent data.
Solution
Modified the
recencymacro inmacros/generic_tests/recency.sqlto includeor most_recent is nullin the WHERE clause. This ensures that when a whereclause filters out all records (causing
most_recentto be null), the testcorrectly fails by returning the null row.
Changes made:
where most_recent < {{ threshold }}towhere most_recent < {{ threshold }} or most_recent is nullrecency_with_where_filterthat reproduces theoriginal bug and verifies the fix
filters to non-existent records
Testing approach:
most_recent)Checklist
issue which has been
triaged and [accepted for development](https://docs.getdbt.com/docs/contributin
g/oss-expectations#pull-requests).
guide and
understand what's expected of me
issue