Skip to content

Commit

Permalink
anomalies_exclude_dates: don't allow ranges without "before"
Browse files Browse the repository at this point in the history
  • Loading branch information
haritamar committed Oct 7, 2023
1 parent e83bbea commit d61ac57
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
6 changes: 6 additions & 0 deletions integration_tests/tests/test_anomalies_exclude_dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,9 @@ def test_invalid_configurations(test_id: str, dbt_project: DbtProject):
test_id, DBT_TEST_NAME, test_args, test_column="metric"
)
assert test_result["status"] == "error"

test_args = {**DBT_TEST_ARGS, "anomalies_exclude_dates": {"after": "2023-10-01"}}
test_result = dbt_project.test(
test_id, DBT_TEST_NAME, test_args, test_column="metric"
)
assert test_result["status"] == "error"
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@
{% if value is string %}
{% do dates_in_config.append(value) %}
{% elif value is mapping %}
{# Don't allow ranges without "before" #}
{% if "before" not in value %}
{% do elementary.raise_anomalies_exclusion_dates_invalid_format_error() %}
{% endif %}

{# Make sure "after" and "before" are the only allowed keys #}
{% for key, val in value.items() %}
{% if key not in ["before", "after"] %}
{% if key not in ["after", "before"] %}
{% do elementary.raise_anomalies_exclusion_dates_invalid_format_error() %}
{% endif %}
{% do dates_in_config.append(val) %}
Expand All @@ -35,7 +41,8 @@
{% macro raise_anomalies_exclusion_dates_invalid_format_error() %}
{% do exceptions.raise_compiler_error(
"
Invalid detection_delay format. Expected format is a list of either dates or date ranges, for example:
Invalid detection_delay format. Expected format is a list of either dates or date ranges. Below are
examples of the supported options:
anomalies_exclude_dates:
- 2023-10-01 # Specific date
Expand Down

0 comments on commit d61ac57

Please sign in to comment.