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

Updated singular tests section to show they can now be documented #6147

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6157c7f
Updated singular tests section to show they can now be documented
nataliefiann Sep 25, 2024
370363f
Update website/docs/docs/build/data-tests.md
nataliefiann Sep 25, 2024
7a9dc71
Remove description of previous behavior
dbeatty10 Sep 30, 2024
d90dc18
Merge branch 'current' into nfiann-singulartests
dbeatty10 Sep 30, 2024
3b02592
Use a subdirectory in the example for documenting singular data tests
dbeatty10 Sep 30, 2024
2d0ad4d
Simplify YAML example for descriptions for singular data tests
dbeatty10 Sep 30, 2024
dadc07b
The `description` property is available for singular data tests begin…
dbeatty10 Sep 30, 2024
30ddc39
`test-paths` has been added to the default `docs-paths` starting v1.9
dbeatty10 Sep 30, 2024
92f9d48
`test-paths` has been added to the default `docs-paths` starting v1.9
dbeatty10 Sep 30, 2024
cf0863b
Add version tags for listing of default `docs-paths`
dbeatty10 Sep 30, 2024
1cf3325
Add version tags for listing of default `docs-paths`
dbeatty10 Sep 30, 2024
da74ea3
For v1.8 and earlier, call out that this is available in v1.9
dbeatty10 Sep 30, 2024
c1af500
Merge branch 'current' into nfiann-singulartests
dbeatty10 Oct 1, 2024
920bc68
Merge branch 'current' into nfiann-singulartests
mirnawong1 Oct 1, 2024
8c5ed44
Update website/docs/docs/build/documentation.md
mirnawong1 Oct 1, 2024
75d7a81
Update website/docs/docs/build/documentation.md
mirnawong1 Oct 1, 2024
e613ffc
Update website/docs/docs/build/documentation.md
mirnawong1 Oct 1, 2024
fe65d38
Update website/docs/docs/build/documentation.md
mirnawong1 Oct 1, 2024
65e9cf8
Update docs-paths.md
mirnawong1 Oct 1, 2024
7912247
Update website/docs/reference/resource-properties/description.md
mirnawong1 Oct 1, 2024
1a39a15
Update website/docs/docs/build/data-tests.md
mirnawong1 Oct 1, 2024
06dddbf
Merge branch 'current' into nfiann-singulartests
mirnawong1 Oct 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion website/docs/docs/build/data-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,33 @@ having total_amount < 0

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

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...
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 [generic data tests](#generic-data-tests).

### Document singular data tests

<VersionBlock firstVersion="1.9">

The top-level `data_tests:` key in YAML files allows for adding a [`description`](/reference/resource-properties/description) for singular data tests. Descriptions can include Markdown, as well as the [`doc` jinja function](/reference/dbt-jinja-functions/doc).

<File name='tests/singular/data_tests.yml'>

```yml

# top-level
data_tests:
- name: my_super_cool_singular_test
description: The `order_id` is unique for every row in the orders model
```

</File>

</VersionBlock>

<VersionBlock lastVersion="1.8">

The `description` property is available for [singular data tests](/build/data-tests#document-singular-data-tests) beginning in dbt v1.9.

</VersionBlock>


## Generic data tests
Expand Down
13 changes: 12 additions & 1 deletion website/docs/docs/build/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,18 @@ The events in this table are recorded by [Snowplow](http://github.com/snowplow/s
In the above example, a docs block named `table_events` is defined with some descriptive markdown contents. There is nothing significant about the name `table_events` — docs blocks can be named however you like, as long as the name only contains alphanumeric and underscore characters and does not start with a numeric character.

### Placement
Docs blocks should be placed in files with a `.md` file extension. By default, dbt will search in all resource paths for docs blocks (i.e. the combined list of [model-paths](/reference/project-configs/model-paths), [seed-paths](/reference/project-configs/seed-paths), [analysis-paths](/reference/project-configs/analysis-paths), [macro-paths](/reference/project-configs/macro-paths) and [snapshot-paths](/reference/project-configs/snapshot-paths)) — you can adjust this behavior using the [docs-paths](/reference/project-configs/docs-paths) config.

<VersionBlock firstVersion="1.9">

Docs blocks should be placed in files with a `.md` file extension. By default, dbt will search in all resource paths for docs blocks (for example, the combined list of [model-paths](/reference/project-configs/model-paths), [seed-paths](/reference/project-configs/seed-paths), [analysis-paths](/reference/project-configs/analysis-paths), [test-paths](/reference/project-configs/test-paths), [macro-paths](/reference/project-configs/macro-paths), and [snapshot-paths](/reference/project-configs/snapshot-paths)) &mdash; you can adjust this behavior using the [docs-paths](/reference/project-configs/docs-paths) config.

</VersionBlock>

<VersionBlock lastVersion="1.8">

Docs blocks should be placed in files with a `.md` file extension. By default, dbt will search in all resource paths for docs blocks (for example, the combined list of [model-paths](/reference/project-configs/model-paths), [seed-paths](/reference/project-configs/seed-paths), [analysis-paths](/reference/project-configs/analysis-paths), [macro-paths](/reference/project-configs/macro-paths), and [snapshot-paths](/reference/project-configs/snapshot-paths)) &mdash; you can adjust this behavior using the [docs-paths](/reference/project-configs/docs-paths) config.

</VersionBlock>


### Usage
Expand Down
12 changes: 11 additions & 1 deletion website/docs/reference/project-configs/docs-paths.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,18 @@ Optionally specify a custom list of directories where [docs blocks](/docs/build/


## Default
By default, dbt will search in all resource paths for docs blocks (i.e. the combined list of [model-paths](/reference/project-configs/model-paths), [seed-paths](/reference/project-configs/seed-paths), [analysis-paths](/reference/project-configs/analysis-paths), [macro-paths](/reference/project-configs/macro-paths) and [snapshot-paths](/reference/project-configs/snapshot-paths)). If this option is configured, dbt will _only_ look in the specified directory for docs blocks.

<VersionBlock firstVersion="1.9">

By default, dbt will search in all resource paths for docs blocks (for example, the combined list of [model-paths](/reference/project-configs/model-paths), [seed-paths](/reference/project-configs/seed-paths), [analysis-paths](/reference/project-configs/analysis-paths), [test-paths](/reference/project-configs/test-paths), [macro-paths](/reference/project-configs/macro-paths), and [snapshot-paths](/reference/project-configs/snapshot-paths)). If this option is configured, dbt will _only_ look in the specified directory for docs blocks.

</VersionBlock>

<VersionBlock lastVersion="1.8">

By default, dbt will search in all resource paths for docs blocks (i.e. the combined list of [model-paths](/reference/project-configs/model-paths), [seed-paths](/reference/project-configs/seed-paths), [analysis-paths](/reference/project-configs/analysis-paths), [macro-paths](/reference/project-configs/macro-paths), and [snapshot-paths](/reference/project-configs/snapshot-paths)). If this option is configured, dbt will _only_ look in the specified directory for docs blocks.

</VersionBlock>

## Example

Expand Down
28 changes: 28 additions & 0 deletions website/docs/reference/resource-properties/description.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ description: "This guide explains how to use the description key to add YAML des
{ label: 'Snapshots', value: 'snapshots', },
{ label: 'Analyses', value: 'analyses', },
{ label: 'Macros', value: 'macros', },
{ label: 'Singular data tests', value: 'singular_data_tests', },
]
}>
<TabItem value="models">
Expand Down Expand Up @@ -145,6 +146,33 @@ macros:

</TabItem>

<TabItem value="singular_data_tests">

<VersionBlock firstVersion="1.9">

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

```yml
version: 2

data_tests:
- name: singular_data_test_name
description: markdown_string

```

</File>

</VersionBlock>

<VersionBlock lastVersion="1.8">

The `description` property is available for [singular data tests](/build/data-tests#document-singular-data-tests) beginning in dbt v1.9.

</VersionBlock>

</TabItem>


</Tabs>

Expand Down
Loading