-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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] unit tests' comparisons are sometimes sensitive to the order of records returned #10167
Comments
Not sure if it is related or not, but in dbt-labs/dbt-redshift#821, the rows with non-null values also needed to come prior to the rows with nulls. |
@joellabes Which database are you seeing this error in? |
Here's some minimal reproducible examples using dbt-postgres:
|
Amusingly, I also believe that each adapter has different order needs! This test fails on Redshift but passes locally on Snowflake: https://app.circleci.com/pipelines/github/dbt-labs/dbt-audit-helper/416/workflows/64b0d0f6-8cd8-48cf-bac2-e462987d69fa/jobs/409 (and presumably vice versa, but I haven't 100% tested that) |
Notes from estimation:
|
Is this a new bug in dbt-core?
Current Behavior
Normally, dbt's unit tests don't care whether rows are ordered the same as the expect block or not.
is just as good as
as far as
is concerned.
I have a use case which is order dependent, but I don't know why.
Expected Behavior
Order to not matter
Steps To Reproduce
Unit test yaml:
The tested model (which is just a call to a macro)
(Yes, unit_test_model_a and unit_test_model_b are identical! They're not used in production contexts, just to define the columns so they can be overridden by the actual test)
Log output when I run `dbt test -s :
But if I reorder the expect block so that the identical row is on top:
The test passes.
Compiled code:
reworked_compare_identical_tables_multiple_null_pk_with_duplicate_rows.txt
Relevant log output
No response
Environment
Which database adapter are you using with dbt?
Snowflake
Additional Context
We believe this is happening when there are multiple explicit null values in the expected output.
Even though the tested columns are all identical, the extra columns that the results return do vary. I made a Loom of a different unit test which is easier to demonstrate with: https://www.loom.com/share/23b636f08019437eb2b09c912e9723fb
You can see all of my assorted tests here.
Blocking
audit_helper
PR dbt-labs/dbt-audit-helper#99The text was updated successfully, but these errors were encountered: