I’d like to extend the current ‘unique’ test to be able to take a variable list of parameters so it can test if the concatenation of the list of columns is unique i.e. col1 || col2 || col3
The context of why I’m trying to do this
I have tables that need to have this assertion tested.
What I’ve already tried
looking through the docs, it seems custom tests must take named arguements atm.
oh nice! I didn’t realise that!! below is what I tried but am now getting a compilation error complaining about the macro takes no keyword argument ‘column_name’ which I can’t control… ideas?
Compilation Error in test dbt_utils_unique_combination_of_columns_SEED_METRIC_LIST_CNMS_METRIC_NAME__GROUP_NAME__METRIC_NAME__False (seeds/Metadata/metadata.yml)
macro ‘dbt_macro__test_unique_combination_of_columns’ takes no keyword argument ‘column_name’
When you put the test below the model/seed name, dbt assumes you are passing to the test an arg called “model” with the name of your model/seed.
When you put the test below the column name, dbt assumes you are passing to the test two args, model like before, and column_name, which is the name of your column.
This specific test does not accept a column_name arg, because it is not designed for a specific column, but a group of them. This group of columns is passed by a custom arg called “combination_of_columns” that is why you have to specify it in the .yml.