-
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
dbt 0.20.0 tries to create two tables with the same name when --store-failures is used with similar-looking expression_is_true tests #3626
Comments
@joellabes Thanks for the report! dbt does try to create a unique hashed alias of <64 characters for tests with too-long names. The issue is that we're first substituting all special characters for underscores, then hashing the flattened arguments into a unique identifier: Since the two tests only differ by a special character, both get stringified to fixThe most obvious fix here is to hash There's one issue I can foresee: If a test name (including all arguments and underscores) is <64 characters, we aren't including a hashed suffix at all. Special characters would still be substituted out for underscores, causing a collision. Should we start adding hash suffixes for all tests with arguments, regardless of length? Frankly, I don't know how common it is for two tests to both have very few/concise arguments and differ by only special characters between them. We will have at least narrowed this edge case into an even rarer occasion. workaroundIn the meantime, you could certainly work around this by adding an extra condition to one of the tests, and "salting" the hash: tests:
- dbt_utils.expression_is_true:
expression: "not (len(memovalue) > 0 and len(value) > 0)" #only one of memovalue and value can be populated
- dbt_utils.expression_is_true:
expression: "not (len(memovalue) = 0 and len(value) = 0) and true" #... but, one of them does have to be longer-term optionsTests already support an tests:
- dbt_utils.expression_is_true:
expression: "not (len(memovalue) > 0 and len(value) > 0)" #only one of memovalue and value can be populated
alias: test_only_one_of_memovalue_and_value
- dbt_utils.expression_is_true:
expression: "not (len(memovalue) = 0 and len(value) = 0)" #... but, one of them does have to be
alias: test_at_least_one_of_memovalue_and_value We've also got some broader thinking in the works about node naming + identification: #3348, #3548 |
@jtcohen6 I've just spent some time looking into this, and have found another wrinkle:
The args dict for the latter is
and the Should I be passing |
@joellabes Ah, that's a really good point. We've made it so that The thing that feels weirder to me here is that both As it happens, thanks to the work in #3616, v0.21 will actually include support for the "long-term option" I described above: defining a custom |
I had the same thought, but decided that it was still papering around the edges of the problem instead of fixing it forever so it didn't really move things forward.
I strongly prefer this 😍 our use case here is to use a combo of get_relations_by_pattern and union_relations to build a dashboard of failing tests over time. It'll be much easier to get the specific relations by pattern if there's.. a pattern, especially one that we can control. Let's close this issue and I'll jump on the .21 beta quicksharp! |
Describe the bug
This schema.yml file:
gives an error when running
dbt test --store-failures
:I guess the problem comes from the only difference between the expressions being the
>
vs=
, which both get turned into_
s. However, the.77167f5215
and.c19220b2a8
suffixes provide deduplication for the tests' FQNs (I think those are the FQNs?)Expected behavior
Both tests to be given different DB representations.
Screenshots and log output
See above
System information
Which database are you using dbt with?
postgres
redshift
other (specify: ____________)
bigquery
snowflake
The output of
dbt --version
:The operating system you're using:
Win10
The output of
python --version
:Python 3.8.0
The text was updated successfully, but these errors were encountered: