Skip to content

Commit 3e814b2

Browse files
epapineauElize Papineau
and
Elize Papineau
authored
Add _is_ephemeral test to get_column_values (#518)
* Add _is_ephemeral test Co-authored-by: Elize Papineau <elize.papineau@dbtlabs.com>
1 parent 15627b9 commit 3e814b2

File tree

2 files changed

+55
-47
lines changed

2 files changed

+55
-47
lines changed

README.md

+53-47
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ For compatibility details between versions of dbt-core and dbt-utils, [see this
6767
[Materializations](#materializations):
6868
- [insert_by_period](#insert_by_period-source)
6969

70-
---
70+
----
7171
### Schema Tests
7272
#### equal_rowcount ([source](macros/schema_tests/equal_rowcount.sql))
7373
This schema test asserts the that two relations have the same number of rows.
@@ -310,6 +310,7 @@ models:
310310
to: ref('other_model_name')
311311
field: client_id
312312
from_condition: id <> '4ca448b8-24bf-4b88-96c6-b1609499c38b'
313+
to_condition: created_date >= '2020-01-01'
313314
```
314315

315316
#### mutually_exclusive_ranges ([source](macros/schema_tests/mutually_exclusive_ranges.sql))
@@ -377,53 +378,58 @@ models:
377378
partition_by: customer_id
378379
gaps: allowed
379380
```
381+
<details>
382+
<summary>Additional `gaps` and `zero_length_range_allowed` examples</summary>
383+
384+
**Understanding the `gaps` argument:**
385+
386+
Here are a number of examples for each allowed `gaps` argument.
387+
* `gaps: not_allowed`: The upper bound of one record must be the lower bound of
388+
the next record.
389+
390+
| lower_bound | upper_bound |
391+
|-------------|-------------|
392+
| 0 | 1 |
393+
| 1 | 2 |
394+
| 2 | 3 |
395+
396+
* `gaps: allowed` (default): There may be a gap between the upper bound of one
397+
record and the lower bound of the next record.
398+
399+
| lower_bound | upper_bound |
400+
|-------------|-------------|
401+
| 0 | 1 |
402+
| 2 | 3 |
403+
| 3 | 4 |
404+
405+
* `gaps: required`: There must be a gap between the upper bound of one record and
406+
the lower bound of the next record (common for date ranges).
407+
408+
| lower_bound | upper_bound |
409+
|-------------|-------------|
410+
| 0 | 1 |
411+
| 2 | 3 |
412+
| 4 | 5 |
413+
414+
**Understanding the `zero_length_range_allowed` argument:**
415+
Here are a number of examples for each allowed `zero_length_range_allowed` argument.
416+
* `zero_length_range_allowed: false`: (default) The upper bound of each record must be greater than its lower bound.
417+
418+
| lower_bound | upper_bound |
419+
|-------------|-------------|
420+
| 0 | 1 |
421+
| 1 | 2 |
422+
| 2 | 3 |
423+
424+
* `zero_length_range_allowed: true`: The upper bound of each record can be greater than or equal to its lower bound.
425+
426+
| lower_bound | upper_bound |
427+
|-------------|-------------|
428+
| 0 | 1 |
429+
| 2 | 2 |
430+
| 3 | 4 |
380431

381-
**Understanding the `gaps` argument:**
382-
Here are a number of examples for each allowed `gaps` argument.
383-
* `gaps: not_allowed`: The upper bound of one record must be the lower bound of
384-
the next record.
385-
386-
| lower_bound | upper_bound |
387-
|-------------|-------------|
388-
| 0 | 1 |
389-
| 1 | 2 |
390-
| 2 | 3 |
391-
392-
* `gaps: allowed` (default): There may be a gap between the upper bound of one
393-
record and the lower bound of the next record.
394-
395-
| lower_bound | upper_bound |
396-
|-------------|-------------|
397-
| 0 | 1 |
398-
| 2 | 3 |
399-
| 3 | 4 |
400-
401-
* `gaps: required`: There must be a gap between the upper bound of one record and
402-
the lower bound of the next record (common for date ranges).
403-
404-
| lower_bound | upper_bound |
405-
|-------------|-------------|
406-
| 0 | 1 |
407-
| 2 | 3 |
408-
| 4 | 5 |
409-
410-
**Understanding the `zero_length_range_allowed` argument:**
411-
Here are a number of examples for each allowed `zero_length_range_allowed` argument.
412-
* `zero_length_range_allowed: false`: (default) The upper bound of each record must be greater than its lower bound.
413-
414-
| lower_bound | upper_bound |
415-
|-------------|-------------|
416-
| 0 | 1 |
417-
| 1 | 2 |
418-
| 2 | 3 |
419-
420-
* `zero_length_range_allowed: true`: The upper bound of each record can be greater than or equal to its lower bound.
421-
422-
| lower_bound | upper_bound |
423-
|-------------|-------------|
424-
| 0 | 1 |
425-
| 2 | 2 |
426-
| 3 | 4 |
432+
</details>
427433

428434
#### sequential_values ([source](macros/schema_tests/sequential_values.sql))
429435
This test confirms that a column contains sequential values. It can be used

macros/sql/get_column_values.sql

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
{{ return(default) }}
1212
{% endif %}
1313

14+
{%- do dbt_utils._is_ephemeral(table, 'get_column_values') -%}
15+
1416
{# Not all relations are tables. Renaming for internal clarity without breaking functionality for anyone using named arguments #}
1517
{# TODO: Change the method signature in a future 0.x.0 release #}
1618
{%- set target_relation = table -%}

0 commit comments

Comments
 (0)