Skip to content

Commit 81671df

Browse files
committed
fix links
1 parent 78e453d commit 81671df

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{% macro no_nulls_in_columns(model) %}
2+
SELECT * FROM {{ model }} WHERE
3+
{% for col in adapter.get_columns_in_relation(model) -%}
4+
{{ col.column }} IS NULL OR
5+
{% endfor %}
6+
FALSE
7+
{% endmacro %}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{ no_nulls_in_columns(ref('dim_listings_cleansed')) }}

dbt/dbt-udemy-course/models.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ FROM
9595
In seeds folder we can create static data by dropping csv files there. Goog for lookups data entered manually.
9696
#### Sources
9797
Add 1 more semantic layer in DBT, good for lineage.
98-
Intead of reading from raw tables, can read from sources created in [sources.yml](./dbt_project/target/compiled/dbt_project/models/sources.yml) using the jinja macro for sources:
98+
Intead of reading from raw tables, can read from sources created in [sources.yml](./dbt_project/models/sources.yml) using the jinja macro for sources:
9999
```sql
100100
SELECT * FROM
101101
--AIRBNB.RAW.RAW_REVIEWS
@@ -107,7 +107,7 @@ dbt compile
107107
```
108108

109109
### Source Freshness
110-
Can set for each source the freshness to check last time the column was updated based on date column. Check [sources.yml](./dbt_project/target/compiled/dbt_project/models/sources.yml) to see how to implement, and then run the command:
110+
Can set for each source the freshness to check last time the column was updated based on date column. Check [sources.yml](./dbt_project/models/sources.yml) to see how to implement, and then run the command:
111111
```bash
112112
dbt source freshness
113113
```
@@ -119,7 +119,7 @@ Used to handle type 2 SCD.
119119
* check: Any change in a set of columns (or all columns) will be picked up as an update.
120120

121121
#### Implementing
122-
Snapshots live in their folder, like [scd_raw_listings.sql](./dbt_project/target/compiled/dbt_project/snapshots/scd_raw_listings.sql), and they ran over a different command:
122+
Snapshots live in their folder, like [scd_raw_listings.sql](./dbt_project/snapshots/scd_raw_listings.sql), and they ran over a different command:
123123
```bash
124124
dbt snapshot
125125
```
@@ -140,16 +140,26 @@ SELECT * FROM AIRBNB.DEV.SCD_RAW_LISTINGS WHERE ID=3176;
140140
* unique, not_null, accepted_values, relationships
141141

142142
#### Generic Test
143-
Create a file called [schema.yml](./dbt_project/target/compiled/dbt_project/models/schema.yml) in models. This is not mandatory, you can create sepatare files inside each model folder, as you wish to organize it. Test it with:
143+
Create a file called [schema.yml](./dbt_project/models/schema.yml) in models. This is not mandatory, you can create sepatare files inside each model folder, as you wish to organize it. Test it with:
144144
```bash
145145
dbt test
146146
```
147147
Can also check the compiled queries in target folder to see the query created.
148148
To check a failure, change one of the accepted values to a fake value and run the tests, it should break.
149149

150150
### Single Test
151-
Live in the test folder and are queries, like [dim_listings_minimum_nights.sql](./dbt_project/target/compiled/dbt_project/tests/dim_listings_minimum_nights.sql).
151+
Live in the test folder and are queries, like [dim_listings_minimum_nights.sql](./dbt_project/tests/dim_listings_minimum_nights.sql).
152152
You can run as dbt test to execute all tests, or can execute just this test (same approach works to dbt run and other dbt commands).
153153
```bash
154154
dbt test --select dim_listings_cleansed
155-
```
155+
```
156+
157+
### Macros, Custom Tests and Packages
158+
* Macros are jinja templates created in macro folder
159+
* There are many built in macros
160+
* Can be used in model definitions and tests
161+
* A special macro called test can be used to create own generic tests
162+
* Packages can be downloaded with more macros and tests
163+
* in jinja there are control loops and so on, must the study jinja to do more advanced stuff
164+
165+
Create a new macro on macro folders as [no_nulls_in_columns.sql](./dbt_project/macros/no_nulls_in_columns.sql) and then call the macro in tests, creating a specific test like [no_nulls_in_dim_listings.sql](./dbt_project/tests/no_nulls_in_dim_listings.sql).

0 commit comments

Comments
 (0)