-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] All test failures are stored even when a limit config is set #373
Comments
❤️ Thanks for the kind words @hvassard. I see what you are saying. It looks to me like the solution would be to move this further up in the logic. Side note: check out More detailThe logic that is used to store the failures is located in a file like with meet_condition as(
select *
from "db"."feature_456"."customers"
),
validation_errors as (
select *
from meet_condition
where
-- never true, defaults to an empty result set. Exists to ensure any combo of the `or` clauses below succeeds
1 = 2
-- records with a value <= max_value are permitted. The `not` flips this to find records that don't meet the rule.
or not ID <= 5
)
select *
from validation_errors In my case, it does a "create table as" into this table:
And then the actual test logic is in select
count(*) as failures,
count(*) != 0 as should_warn,
count(*) != 0 as should_error
from (
select *
from "db"."feature_456_dbt_test__audit"."my_test_with_limit_and_store_failures"
limit 2
) dbt_internal_test So you can see the first one does not have the limit clause applied, whereas the second one does. Potential solutionSo the solution might be to move this to here and here instead. |
Transferred from dbt-core #9463 to #373 |
ReprexCreate these files:
seeds:
- name: customers
columns:
- name: id
tests:
- dbt_utils.accepted_range:
name: my_test_with_limit_and_store_failures
max_value: 1
inclusive: true
config:
store_failures_as: table
limit: 2 Run this command: dbt build -s customers --full-refresh Inspect the table and see that it has 5 results when according to the docs, it should only have 2:
|
Is this a new bug in dbt-core?
Current Behavior
Hi there, firstly thanks for the amazing job you're doing, I am huge fan of dbt !
I use dbt core with dbt-redshift.
I wrote a test on a simple seed to check the behavior of the store_failures test config when used in addition to the limit config.
The seed I test (
seeds/customers.csv
) looks like this and has 100 rows (from ID 1 to 100):Download file here : customers.csv
The test definition (
seeds/_seeds.yml
) looks like this:TLDR : The "ID" column must be strictly lower than 50. Store the failures. But stop if more than 20 failures.
What I experience when running
dbt test -s customers
:The test log seems OK
But my test audit table generated in my warehouse contains all the failed row (50) and not 20 (the limit specified).
Expected Behavior
I guess only the 20 first row must be stored in the audit table (based on the store_failure config documentation pictured here)
Steps To Reproduce
Where requirements.txt is
Relevant log output
No response
Environment
Which database adapter are you using with dbt?
redshift
Additional Context
I noticed this SQL file generated in the target folder if it can help
The text was updated successfully, but these errors were encountered: