Skip to content
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

Defining column_name in YAML for generic data tests is only for advanced use cases #6436

Open
1 task done
dbeatty10 opened this issue Nov 7, 2024 · 1 comment
Open
1 task done
Labels
content Improvements or additions to content improvement Use this when an area of the docs needs improvement as it's currently unclear

Comments

@dbeatty10
Copy link
Contributor

Contributions

  • I have read the contribution docs, and understand what's expected of me.

Link to the page on docs.getdbt.com requiring updates

https://docs.getdbt.com/reference/resource-properties/data-tests#test-an-expression

What part(s) of the page would you like to see updated?

It looks to me like the code example here dbt-labs/dbt-core#10966 (comment) lead to some confusion.

I don't know off the top of my head how we could/should refactor it, but we should give it a look if we can.

Currently, this code example seems to be trying to cover two things at the same time:

  • Using a SQL expression within a data test
  • Apply the data test to a model instead of a column

So maybe things will be less confusing if those two things are split into their own separate code examples?

It might be helpful to use a different example for SQL expressions. One idea is expression_is_true from dbt-utils:

Test an expression

models:
  - name: model_name
    tests:
      - dbt_utils.expression_is_true:
          expression: "col_a + col_b = total"

Another example:

models:
  - name: model_name
    tests:
      - dbt_utils.expression_is_true:
          expression: "delivery_date >= order_date"

Something to keep in mind is that this looks like it originally pointed to this example:

models:
  - name: orders
    tests:
      - unique:
          column_name: "country_code || '-' || order_id"

Additional information

No response

@dbeatty10 dbeatty10 added content Improvements or additions to content improvement Use this when an area of the docs needs improvement as it's currently unclear labels Nov 7, 2024
@rudo-ro
Copy link

rudo-ro commented Nov 10, 2024

+1 for the improvement here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content Improvements or additions to content improvement Use this when an area of the docs needs improvement as it's currently unclear
Projects
None yet
Development

No branches or pull requests

2 participants