From a10bc6806c856022a60c0c373d8c329a26ebd501 Mon Sep 17 00:00:00 2001 From: breken-ai <312387581+breken-ai@users.noreply.github.com> Date: Fri, 25 Sep 2026 21:53:03 -0700 Subject: [PATCH 1/2] fix: apply seasonality case-insensitively like its validation validate_seasonality lowercases the value before checking it, so 'Day_Of_Week' is accepted, but get_seasonality returned it unchanged and get_anomaly_scores_query / get_days_back compare against lowercase names. The test then ran with no seasonality at all. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../tests/test_volume_anomalies.py | 21 +++++++++++++++++++ .../test_configuration/get_seasonality.sql | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/integration_tests/tests/test_volume_anomalies.py b/integration_tests/tests/test_volume_anomalies.py index 3ce4a865e..95e416bb4 100644 --- a/integration_tests/tests/test_volume_anomalies.py +++ b/integration_tests/tests/test_volume_anomalies.py @@ -200,6 +200,27 @@ def test_volume_anomalies_with_seasonality(test_id: str, dbt_project: DbtProject assert test_result["status"] == "fail" +def test_volume_anomalies_with_seasonality_is_case_insensitive( + test_id: str, dbt_project: DbtProject +): + # Seasonality values are validated case-insensitively, so they must also be + # applied case-insensitively instead of being silently ignored. + utc_today = datetime.utcnow().date() + dates = generate_dates( + base_date=utc_today - timedelta(days=1), + step=timedelta(weeks=1), + days_back=7 * 14, + ) + data = [ + {TIMESTAMP_COLUMN: cur_date.strftime(DATE_FORMAT)} + for cur_date in dates + if cur_date < utc_today - timedelta(weeks=1) + ] + test_args = {**DBT_TEST_ARGS, "seasonality": "Day_Of_Week"} + test_result = dbt_project.test(test_id, DBT_TEST_NAME, test_args, data=data) + assert test_result["status"] == "fail" + + def test_volume_anomalies_with_sensitivity(test_id: str, dbt_project: DbtProject): utc_today = datetime.utcnow().date() data = [ diff --git a/macros/edr/tests/test_configuration/get_seasonality.sql b/macros/edr/tests/test_configuration/get_seasonality.sql index b16161ab5..ac24dccc4 100644 --- a/macros/edr/tests/test_configuration/get_seasonality.sql +++ b/macros/edr/tests/test_configuration/get_seasonality.sql @@ -7,7 +7,7 @@ {%- do elementary.validate_seasonality( seasonality, time_bucket, timestamp_column ) -%} - {%- if seasonality %} {{ return(seasonality) }} {%- endif %} + {%- if seasonality %} {{ return(seasonality | lower) }} {%- endif %} {{ return(none) }} {% endmacro %} From d09833bebbc673d292cb79e08e0325752897ac71 Mon Sep 17 00:00:00 2001 From: breken-ai <312387581+breken-ai@users.noreply.github.com> Date: Sun, 27 Sep 2026 12:57:23 -0700 Subject: [PATCH 2/2] test: make seasonality case test adapter portable Signed-off-by: breken-ai <312387581+breken-ai@users.noreply.github.com> --- .../tests/test_anomaly_test_configuration.py | 5 +++-- .../tests/test_volume_anomalies.py | 21 ------------------- 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/integration_tests/tests/test_anomaly_test_configuration.py b/integration_tests/tests/test_anomaly_test_configuration.py index 89fcd3291..38d5b25ab 100644 --- a/integration_tests/tests/test_anomaly_test_configuration.py +++ b/integration_tests/tests/test_anomaly_test_configuration.py @@ -32,7 +32,7 @@ class ParamValues(Generic[T]): {"count": 1, "period": "day"}, ), "backfill_days": ParamValues(30, 60, 90), - "seasonality": ParamValues("day_of_week", "hour_of_day", "day_of_week"), + "seasonality": ParamValues("day_of_week", "hour_of_day", "Day_Of_Week"), "event_timestamp_column": ParamValues( "vars.updated_at", "model.updated_at", "test.updated_at" ), @@ -67,7 +67,8 @@ class ParamValues(Generic[T]): def _get_expected_adapted_config(values_type: Literal["vars", "model", "test"]): def get_value(key: str): - return PARAM_VALUES[key].__dict__[values_type] + value = PARAM_VALUES[key].__dict__[values_type] + return value.lower() if key == "seasonality" and value else value days_back_multiplier = ( 7 if get_value("seasonality") in ["day_of_week", "hour_of_week"] else 1 diff --git a/integration_tests/tests/test_volume_anomalies.py b/integration_tests/tests/test_volume_anomalies.py index 95e416bb4..3ce4a865e 100644 --- a/integration_tests/tests/test_volume_anomalies.py +++ b/integration_tests/tests/test_volume_anomalies.py @@ -200,27 +200,6 @@ def test_volume_anomalies_with_seasonality(test_id: str, dbt_project: DbtProject assert test_result["status"] == "fail" -def test_volume_anomalies_with_seasonality_is_case_insensitive( - test_id: str, dbt_project: DbtProject -): - # Seasonality values are validated case-insensitively, so they must also be - # applied case-insensitively instead of being silently ignored. - utc_today = datetime.utcnow().date() - dates = generate_dates( - base_date=utc_today - timedelta(days=1), - step=timedelta(weeks=1), - days_back=7 * 14, - ) - data = [ - {TIMESTAMP_COLUMN: cur_date.strftime(DATE_FORMAT)} - for cur_date in dates - if cur_date < utc_today - timedelta(weeks=1) - ] - test_args = {**DBT_TEST_ARGS, "seasonality": "Day_Of_Week"} - test_result = dbt_project.test(test_id, DBT_TEST_NAME, test_args, data=data) - assert test_result["status"] == "fail" - - def test_volume_anomalies_with_sensitivity(test_id: str, dbt_project: DbtProject): utc_today = datetime.utcnow().date() data = [