Skip to content

Issue #1041

@marzaccaro

Description

@marzaccaro

Describe the bug

When using dbt_utils.recency test in combination with the config: where parameter to limit the scanned data the test will pass if no record is found to be less than the threshold - so the test is passing if no recent data are found!

Steps to reproduce

example seed (example.csv)

ingestion_date
2024-10-01
2025-01-01

test configuration on the seed (ie _seeds.yml)

seeds:
  - name: example
     tests:
       - dbt_utils.recency:
            arguments:
              datepart: day
              field: ingestion_date
              interval: 1
              config: 
                where: "ingestion_date > current_date - 2"

Expected results

I would expect this to fail the tests (as it happens when there is no filters)

Actual results

The test is actually passing!

Screenshots and log output

System information

The contents of your packages.yml file:

packages:
  - package: dbt-labs/dbt_utils
    version: 1.3.0

Which database are you using dbt with?

  • postgres
  • redshift
  • bigquery
  • snowflake
  • other (specify: ____________)

The output of dbt --version:

Latest of dbt 

Additional context

The reason for the issue is we have this where clause here

where most_recent < {{ threshold }}

we should have something like this:

where most_recent < {{ threshold }} or most_recent is null

Are you interested in contributing the fix?

Yes happy to contribute to the fix, will try to open a PR for this :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions