Skip to content

Commit 38143cd

Browse files
author
Elize Papineau
authored
Merge pull request #377 from dbt-labs/epapineau/undocumented-sources
Epapineau/undocumented sources
2 parents 1fbc682 + 7ecc826 commit 38143cd

9 files changed

Lines changed: 122 additions & 1 deletion

File tree

docs/rules.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ hide:
2323
|Testing |[Test Coverage](../rules/testing/#test-coverage) |`fct_test_coverage`|
2424
|Documentation |[Undocumented Models](../rules/documentation/#undocumented-models) |`fct_undocumented_models`|
2525
|Documentation |[Documentation Coverage](../rules/documentation/#documentation-coverage) |`fct_documentation_coverage`|
26+
|Documentation |[Undocumented Source Tables](../rules/documentation/#undocumented-source-tables) |`fct_undocumented_source_tables`|
27+
|Documentation |[Undocumented Sources](../rules/documentation/#undocumented-sources) |`fct_documentation_sources`|
2628
|Structure |[Test Directories](../rules/structure/#test-directories) |`fct_test_directories`|
2729
|Structure |[Model Naming Conventions](../rules/structure/#model-naming-conventions) |`fct_model_naming_conventions`|
2830
|Structure |[Source Directories](../rules/structure/#source-directories) |`fct_source_directories`|

docs/rules/documentation.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,43 @@ function in the model's `.yml` entry.
4646
!!! note "Tip"
4747

4848
We recommend that every model in your dbt project has at minimum a model-level description. This ensures that each model's purpose is clear to other developers and stakeholders when viewing the dbt docs site. Missing documentation should be addressed first for marts models, then for the rest of your project, to ensure that stakeholders in the organization can understand the data which is surfaced to them.
49+
50+
## Undocumented Source Tables
51+
52+
`fct_undocumented_source_tables` ([source](https://github.com/dbt-labs/dbt-project-evaluator/tree/main/models/marts/documentation/fct_undocumented_source_tables.sql)) lists every source table with no description configured.
53+
54+
**Reason to Flag**
55+
56+
Good documentation for your dbt sources will help contributors to your project understand how and when data is loaded into your warehouse.
57+
58+
**How to Remediate**
59+
60+
Apply a text [description](https://docs.getdbt.com/docs/building-a-dbt-project/documentation) in the table's `.yml` entry, or create a [docs block](https://docs.getdbt.com/docs/building-a-dbt-project/documentation#using-docs-blocks) in a markdown file, and use the `{{ doc() }}`
61+
function in the table's `.yml` entry.
62+
```
63+
sources:
64+
- name: my_source
65+
tables:
66+
- name: my_table
67+
description: This is the source table description
68+
```
69+
70+
## Undocumented Sources
71+
72+
`fct_undocumented_sources` ([source](https://github.com/dbt-labs/dbt-project-evaluator/tree/main/models/marts/documentation/fct_undocumented_sources.sql)) lists every source with no description configured.
73+
74+
**Reason to Flag**
75+
76+
Good documentation for your dbt sources will help contributors to your project understand how and when data is loaded into your warehouse.
77+
78+
**How to Remediate**
79+
80+
Apply a text [description](https://docs.getdbt.com/docs/building-a-dbt-project/documentation) in the source's `.yml` entry, or create a [docs block](https://docs.getdbt.com/docs/building-a-dbt-project/documentation#using-docs-blocks) in a markdown file, and use the `{{ doc() }}`
81+
function in the source's `.yml` entry.
82+
```
83+
sources:
84+
- name: my_source
85+
description: This is the source description
86+
tables:
87+
- name: my_table
88+
```

integration_tests/models/staging/source_1/source.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ version: 2
22

33
sources:
44
- name: source_1
5+
description: this is source 1.
56
schema: real_schema
67
# database: real_database
78
tables:

integration_tests/seeds/docs/docs_seeds.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,22 @@ seeds:
3030
- staging_documentation_coverage_pct
3131
- intermediate_documentation_coverage_pct
3232
- marts_documentation_coverage_pct
33-
- other_documentation_coverage_pct
33+
- other_documentation_coverage_pct
34+
35+
- name: test_fct_undocumented_source_tables
36+
config:
37+
tags:
38+
- docs
39+
tests:
40+
- dbt_utils.equality:
41+
name: equality_fct_undocumented_source_tables
42+
compare_model: ref('fct_undocumented_source_tables')
43+
44+
- name: test_fct_undocumented_sources
45+
config:
46+
tags:
47+
- docs
48+
tests:
49+
- dbt_utils.equality:
50+
name: equality_fct_undocumented_sources
51+
compare_model: ref('fct_undocumented_sources')
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
resource_name
2+
source_1.table_4
3+
source_1.table_5
4+
source_2.table_3
5+
source_1.raw_table_5
6+
source_1.table_2
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
source_name
2+
source_2

models/marts/documentation/documentation.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,15 @@ models:
1616
- name: fct_undocumented_models
1717
description: >
1818
This model contains all models that do not have a description configured in a YML file.
19+
tests:
20+
- is_empty
21+
- name: fct_undocumented_source_tables
22+
description: >
23+
This model contains all source tables that do not have a description configured in a YML file.
24+
tests:
25+
- is_empty
26+
- name: fct_undocumented_sources
27+
description: >
28+
This model contains all sources that do not have a description configured in a YML file.
1929
tests:
2030
- is_empty
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
with
2+
3+
all_resources as (
4+
select * from {{ ref('int_all_graph_resources') }}
5+
where not is_excluded
6+
7+
),
8+
9+
final as (
10+
11+
select
12+
resource_name
13+
14+
from all_resources
15+
where not is_described and resource_type = 'source'
16+
17+
)
18+
19+
select * from final
20+
21+
{{ filter_exceptions(model.name) }}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
with
2+
3+
all_resources as (
4+
select * from {{ ref('int_all_graph_resources') }}
5+
where not is_excluded
6+
7+
),
8+
9+
final as (
10+
11+
select distinct
12+
source_name
13+
14+
from all_resources
15+
where not is_source_described and resource_type = 'source'
16+
17+
)
18+
19+
select * from final
20+
21+
{{ filter_exceptions(model.name) }}

0 commit comments

Comments
 (0)