Customizing dbt Test Output Name

Is there a way to customize the auto-generated dbt test name? By default I see it’s test_name, model name, properties… Can I customize the name myself?

Curious… customize how given those examples ?

Let’s say for the first one, I just wanted to call it “is_unique” (for example, if I knew it would be the absolutely ONLY place I was calling this test)

(This is for a case where the generated name is extremely long since there are a lot of properties past in. I’d like to truncate the name to make the output easier to parse)

1 Like

You can do this by using the name property on the test:

Does that imply that I can use the list_unexpected_properties test, renaming it to contract_unexpected_properties in this particular test? That doesn’t seem to work here. Am I misunderstanding something?


I get a compilation error that the ‘test_contract_unexpected_properties’ is undefined

This is the example code from the docs:

version: 2

  - name: orders
      - name: status
          - accepted_values:
              name: unexpected_order_status_today
              values: ['placed', 'shipped', 'completed', 'returned']
                where: "order_date = current_date"

In your case, you would do something like:

  - name: contract_schema
      - name: key
          - list_unexpected_properties:
              name: contract_unexpected_properties
              value_set: [caseId, billingMethod, ...]

In the code you provided, you’re trying to attach two tests to the key column, a contract_unexpected_properties test with no arguments (like the built-in unique or not_null tests) and a list_unexpected_properties test which has a value_set argument.

That is beautiful and exactly what I’m looking for. Thank you!

For my own understanding, I don’t see the exact sample code you pasted in the docs you linked. Can you help me find that? It would have made things much clearer for me initially.

1 Like

It’s towards the bottom of the page (screenshot below); if you can’t see it, check which version of the docs you’re using (in my screenshot I have v1.3 selected). If you are looking at an old version then it might not show up; I don’t remember when this functionality was added!

Changing the version did it for me. Good to know that it was on v1.0 by default and I didn’t easily see how to change it. Hopefully, this makes things much clearer going forward.

Thanks again for your help!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.