Skip to content

Commit

Permalink
Update data-tests.md (#6961)
Browse files Browse the repository at this point in the history
  • Loading branch information
mirnawong1 authored Mar 3, 2025
2 parents cbca2eb + 4825c20 commit 56794f7
Showing 1 changed file with 24 additions and 19 deletions.
43 changes: 24 additions & 19 deletions website/docs/reference/resource-properties/data-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ version: 2
models:
- name: <model_name>
tests:
- [<test_name>](#test_name):
- [<test_name>](#custom-data-test-name):
<argument_name>: <argument_value>
[config](/reference/resource-properties/config):
[<test_config>](/reference/data-test-configs): <config-value>

[columns](/reference/resource-properties/columns):
- name: <column_name>
tests:
- [<test_name>](#test_name)
- [<test_name>](#test_name):
- [<test_name>](#custom-data-test-name)
- [<test_name>](#custom-data-test-name):
<argument_name>: <argument_value>
[config](/reference/resource-properties/config):
[<test_config>](/reference/data-test-configs): <config-value>
Expand All @@ -59,17 +59,17 @@ sources:
tables:
- name: <table_name>
tests:
- [<test_name>](#test_name)
- [<test_name>](#test_name):
- [<test_name>](#custom-data-test-name)
- [<test_name>](#custom-data-test-name):
<argument_name>: <argument_value>
[config](/reference/resource-properties/config):
[<test_config>](/reference/data-test-configs): <config-value>

columns:
- name: <column_name>
tests:
- [<test_name>](#test_name)
- [<test_name>](#test_name):
- [<test_name>](#custom-data-test-name)
- [<test_name>](#custom-data-test-name):
<argument_name>: <argument_value>
[config](/reference/resource-properties/config):
[<test_config>](/reference/data-test-configs): <config-value>
Expand All @@ -90,17 +90,17 @@ version: 2
seeds:
- name: <seed_name>
tests:
- [<test_name>](#test_name)
- [<test_name>](#test_name):
- [<test_name>](#custom-data-test-name)
- [<test_name>](#custom-data-test-name):
<argument_name>: <argument_value>
[config](/reference/resource-properties/config):
[<test_config>](/reference/data-test-configs): <config-value>

columns:
- name: <column_name>
tests:
- [<test_name>](#test_name)
- [<test_name>](#test_name):
- [<test_name>](#custom-data-test-name)
- [<test_name>](#custom-data-test-name):
<argument_name>: <argument_value>
[config](/reference/resource-properties/config):
[<test_config>](/reference/data-test-configs): <config-value>
Expand All @@ -121,17 +121,17 @@ version: 2
snapshots:
- name: <snapshot_name>
tests:
- [<test_name>](#test_name)
- [<test_name>](#test_name):
- [<test_name>](#custom-data-test-name)
- [<test_name>](#custom-data-test-name):
<argument_name>: <argument_value>
[config](/reference/resource-properties/config):
[<test_config>](/reference/data-test-configs): <config-value>

columns:
- name: <column_name>
tests:
- [<test_name>](#test_name)
- [<test_name>](#test_name):
- [<test_name>](#custom-data-test-name)
- [<test_name>](#custom-data-test-name):
<argument_name>: <argument_value>
[config](/reference/resource-properties/config):
[<test_config>](/reference/data-test-configs): <config-value>
Expand Down Expand Up @@ -267,18 +267,23 @@ Some data tests require multiple columns, so it doesn't make sense to nest them

<File name='models/orders.yml'>

```yml
```yaml
version: 2
models:
- name: orders
description:
Order overview data mart, offering key details for each order including if it's a customer's first order and a food vs. drink item breakdown. One row per order.
tests:
- unique:
column_name: "country_code || '-' || order_id"
- dbt_utils.expression_is_true:
expression: "order_items_subtotal = subtotal"
- dbt_utils.expression_is_true:
expression: "order_total = subtotal + tax_paid"
```

</File>

This example focuses on testing expressions to ensure that `order_items_subtotal` equals `subtotal` and `order_total` correctly sums `subtotal` and `tax_paid`.

### Use custom generic test

If you've defined your own custom generic test, you can use that as the `test_name`:
Expand Down

0 comments on commit 56794f7

Please sign in to comment.