Skip to content
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] Test alias not working with dbt_utils.accepted_range #4549

Closed
1 task done
crystalro0 opened this issue Jan 4, 2022 · 1 comment
Closed
1 task done

[Bug] Test alias not working with dbt_utils.accepted_range #4549

crystalro0 opened this issue Jan 4, 2022 · 1 comment
Labels
bug Something isn't working dbt tests Issues related to built-in dbt testing functionality

Comments

@crystalro0
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Customer uses --store-failures on some columns in the same model, multiple instances of a test with a where clause. For example: two different dbt_util.accepted_range tests on different subsets of the same column.

      - name: status
        tests:
          - dbt_utils.accepted_range:
              alias: sale_placed_accepted_range
              where: "status = 'Placed'"
          - dbt_utils.accepted_range:
              alias: sale_shipped_accepted_range
              where: "status = 'Shipped'"

They experienced errors in v0.21 with --store-failures due to duplicate test names. Aliasing the tests resolved the dupe issue, but since they upgraded to 1.0, this doesn't seem to be working anymore.

Expected Behavior

Both tests run with the two aliases from the test config in the yml to differentiate between the two.

Steps To Reproduce

  1. Use environment on v1.0.0 or v1.0.1
  2. Add 2 tests to the same column with different where clauses.
  3. Run dbt test --store-failures
  4. Error:
Compilation Error
  dbt found two resources with the name "dbt_utils_accepted_range_test__0"
Since these resources have the same name,
  dbt will be unable to find the correct resource when "dbt_utils_accepted_range_test__0" is used.

Relevant log output

No response

Environment

- dbt: 1.0.1

What database are you using dbt with?

snowflake

Additional Context

No response

@crystalro0 crystalro0 added bug Something isn't working triage labels Jan 4, 2022
@jtcohen6 jtcohen6 added Team:Language dbt tests Issues related to built-in dbt testing functionality labels Jan 5, 2022
@jtcohen6
Copy link
Contributor

jtcohen6 commented Jan 6, 2022

@crystalro0 Thanks for opening! This is a duplicate of #4102.

It's a pretty thorny intricate thing that's happening:

  • Test configs (including where) aren't factored into a test's unique name construction. Test arguments are. This gets to a philosophical question of: When is a test the same? When is it different?
  • In previous versions of dbt, this didn't work either! The second test would silently overwrite the first test; as a result, dbt test would only run one of them. In v1.0, dbt now raises an explicit error, saying it's found the same test defined twice.

I'm going to close this issue, to keep the conversation centralized over in #4102

@jtcohen6 jtcohen6 closed this as completed Jan 6, 2022
@jtcohen6 jtcohen6 removed the triage label Jan 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dbt tests Issues related to built-in dbt testing functionality
Projects
None yet
Development

No branches or pull requests

2 participants