From fb0fa0f85e5f26dcc53ee1863a9a97ee00c606d0 Mon Sep 17 00:00:00 2001 From: Benjamin Ryon Date: Wed, 23 Dec 2020 13:28:55 -0800 Subject: [PATCH] Use boolean for zero range arg. --- README.md | 8 ++++---- integration_tests/models/schema_tests/schema.yml | 2 +- macros/schema_tests/mutually_exclusive_ranges.sql | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 4ea96df9..d841b616 100644 --- a/README.md +++ b/README.md @@ -394,9 +394,9 @@ 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 | |-------------|-------------| @@ -404,7 +404,7 @@ Here are a number of examples for each allowed `zero_length` parameter. | 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 | |-------------|-------------| diff --git a/integration_tests/models/schema_tests/schema.yml b/integration_tests/models/schema_tests/schema.yml index e9015a14..deae3f13 100644 --- a/integration_tests/models/schema_tests/schema.yml +++ b/integration_tests/models/schema_tests/schema.yml @@ -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: diff --git a/macros/schema_tests/mutually_exclusive_ranges.sql b/macros/schema_tests/mutually_exclusive_ranges.sql index 9e0de820..65007aad 100644 --- a/macros/schema_tests/mutually_exclusive_ranges.sql +++ b/macros/schema_tests/mutually_exclusive_ranges.sql @@ -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='=' %} @@ -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 %}