Skip to content

Commit

Permalink
Use boolean for zero range arg.
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Ryon committed Dec 23, 2020
1 parent 949d40d commit fb0fa0f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -394,17 +394,17 @@ the lower bound of the next record (common for date ranges).
| 2 | 3 |
| 4 | 5 |

**Understanding the `zero_length` parameter:**
Here are a number of examples for each allowed `zero_length` parameter.
* `zero_length:not_allowed`: The upper bound of each record must be greater than its lower bound.
**Understanding the `zero_length_range_allowed` parameter:**
Here are a number of examples for each allowed `zero_length_range_allowed` parameter.
* `zero_length_range_allowed:false`: (default) The upper bound of each record must be greater than its lower bound.

| lower_bound | upper_bound |
|-------------|-------------|
| 0 | 1 |
| 1 | 2 |
| 2 | 3 |

* `zero_length:allowed`: The upper bound of each record can be greater than or equal to its lower bound.
* `zero_length_range_allowed:true`: The upper bound of each record can be greater than or equal to its lower bound.

| lower_bound | upper_bound |
|-------------|-------------|
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/models/schema_tests/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ models:
lower_bound_column: valid_from
upper_bound_column: valid_to
partition_by: subscription_id
zero_length: allowed
zero_length_range_allowed: true

- name: data_unique_combination_of_columns
tests:
Expand Down
8 changes: 4 additions & 4 deletions macros/schema_tests/mutually_exclusive_ranges.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% macro test_mutually_exclusive_ranges(model, lower_bound_column, upper_bound_column, partition_by=None, gaps='allowed', zero_length='not_allowed') %}
{% macro test_mutually_exclusive_ranges(model, lower_bound_column, upper_bound_column, partition_by=None, gaps='allowed', zero_length_range_allowed=False) %}

{% if gaps == 'not_allowed' %}
{% set allow_gaps_operator='=' %}
Expand All @@ -14,15 +14,15 @@
"`gaps` argument for mutually_exclusive_ranges test must be one of ['not_allowed', 'allowed', 'required'] Got: '" ~ gaps ~"'.'"
) }}
{% endif %}
{% if zero_length == 'not_allowed' %}
{% if not zero_length_range_allowed %}
{% set allow_zero_length_operator='<' %}
{% set allow_zero_length_operator_in_words='less_than' %}
{% elif zero_length == 'allowed' %}
{% elif zero_length_range_allowed %}
{% set allow_zero_length_operator='<=' %}
{% set allow_zero_length_operator_in_words='less_than_or_equal_to' %}
{% else %}
{{ exceptions.raise_compiler_error(
"`zero_length` argument for mutually_exclusive_ranges test must be one of ['not_allowed', 'allowed'] Got: '" ~ zero_length ~"'.'"
"`zero_length_range_allowed` argument for mutually_exclusive_ranges test must be one of [true, false] Got: '" ~ zero_length ~"'.'"
) }}
{% endif %}

Expand Down

0 comments on commit fb0fa0f

Please sign in to comment.