dbtdbtype

How to use dbt_utils.unique_combination_of_columns on DBT


How could anyone help me how to use this DBT command "dbt_utils.unique_combination_of_columns" I plan to test 2 different column on my DBT unfortunately (user_id & ticker_symbol) I'm encountering an error upon running dbt test. Your response is highly appreciated. Thank you so much.

Screen of my yaml file

enter image description here

Screenshot of my .sql

enter image description here

Error encountered upon running DBT test:

enter image description here


Solution

  • This dbt_utils generic test is thought to be ran on top of a model, not on a particular column, so you'd need to place it under the model name and not to a certain column.

    So, instead of what you did in the screenshot, you could do the following:

    # this is your schema.yml
    
    version: 2
    
    models:
      
      - name: mrt_test
        description: ""
        tests:
          - dbt_utils.unique_combination_of_columns:
              combination_of_columns:
                - user_id
                - ticker_symbol
        columns:
          - name: (...)