-
Notifications
You must be signed in to change notification settings - Fork 102
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
Update the derivation of the test view name #576
base: master
Are you sure you want to change the base?
Update the derivation of the test view name #576
Conversation
Use the local MD5 macro to create a more unique hash based on the SQL of the test itself
Add in a random element because sometimes two tests can be completely identical as the unique work of the test is done in the jinja template itself before compilation. See https://github.com/calogica/dbt-expectations/blob/main/macros/schema_tests/table_shape/expect_table_column_count_to_equal_other_table.sql
Thanks @Benjamin-Knight. Will set some time aside this week to review. |
Hi, Edit: I'm really fine with the solution, just leaving the rest of my world salad here for people with spare time. {{ local_md5(main_sql) }}_{{ range(1300, 19000) | random }} should do the trick and you've got all the variables at hand anyways Isn't the more common approach to hash the "dbt name" of the test (which should be unique as well)? Or hash plus a random seed in case someone somehow manages to be really crazy with column and table names. So one would hash relationships_table1_conflict_column1__column2__ref_table2 instead of the underlying SQL. Cheers |
@johannes-becker-bt The pull currently uses a hash and a random seed as you mention for the exact reason you noted. Using the name of the test does sound like a better hash target, I'll have to test if DBT allows the setting of test names to be the same value, I often override the name of tests to a more user friendly version and DBT would need to ensure this is unique as well for this to work. |
Only if you feel like it. |
Merry Christmas! |
^ Yes please! Would love to hit 2 birds with one stone on this |
…e altering the same code. Update unit tests to also use a hash of the SQL to generate their view names as we are altering this code for dbt-msft#585.
Added an update to resolve #586 as well, I added the update to view name derivation to the unit test materialisations as well. |
Resolves #575 Use the local MD5 macro to create a more unique hash based on the SQL of the test itself