Skip to content

Commit

Permalink
Fixing link for data tests (#6295)
Browse files Browse the repository at this point in the history
  • Loading branch information
mirnawong1 authored Oct 16, 2024
2 parents d3d379f + 951e4a3 commit 9322ef9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
20 changes: 18 additions & 2 deletions website/docs/docs/build/data-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,25 @@ having total_amount < 0

</File>

The name of this test is the name of the file: `assert_total_payment_amount_is_positive`. Simple enough.
The name of this test is the name of the file: `assert_total_payment_amount_is_positive`.

Singular data tests are easy to write—so easy that you may find yourself writing the same basic structure over and over, only changing the name of a column or model. By that point, the test isn't so singular! In that case, we recommend...
To add a data test to your project, add a `.yml` file to your `tests` directory, for example, `tests/schema.yml` with the following content:

<File name='tests/schema.yml'>

```yaml
version: 2
data_tests:
- name: assert_total_payment_amount_is_positive
description: >
Refunds have a negative amount, so the total amount should always be >= 0.
Therefore return records where total amount < 0 to make the test fail.
```
</File>
Singular data tests are so easy that you may find yourself writing the same basic structure repeatedly, only changing the name of a column or model. By that point, the test isn't so singular! In that case, we recommend generic data tests.
## Generic data tests
Certain data tests are generic: they can be reused over and over again. A generic data test is defined in a `test` block, which contains a parametrized query and accepts arguments. It might look like:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,6 @@ You can read more about each of these behavior changes in the following links:
We also made some quality-of-life improvements in Core 1.9, enabling you to:

- Maintain data quality now that dbt returns an an error (versioned models) or warning (unversioned models) when someone [removes a contracted model by deleting, renaming, or disabling](/docs/collaborate/govern/model-contracts#how-are-breaking-changes-handled) it.
- Document [singular data tests](/docs/build/data-tests#document-singular-tests).
- Document [singular data tests](/docs/build/data-tests#singular-data-tests).
- Use `ref` and `source` in [foreign key constraints](/reference/resource-properties/constraints).
- Use `dbt test` with the `--resource-type` / `--exclude-resource-type` flag, making it possible to include or exclude data tests (`test`) or unit tests (`unit_test`).

0 comments on commit 9322ef9

Please sign in to comment.