From e63dfcaab657852c41d09d98ac871e9826cbd583 Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Mon, 29 Jul 2024 15:26:04 -0700 Subject: [PATCH] Fix Trino issue with previous check query test Unrelated to this PR, but this is causing SQL engine test failures. I assume this was not caught previously because the SQL engine tests were not run for this change. --- .../integration/test_cases/itest_metrics.yaml | 4 ++-- tests_metricflow/integration/test_configured_cases.py | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tests_metricflow/integration/test_cases/itest_metrics.yaml b/tests_metricflow/integration/test_cases/itest_metrics.yaml index 7c6e96f8f6..1b3be4ab49 100644 --- a/tests_metricflow/integration/test_cases/itest_metrics.yaml +++ b/tests_metricflow/integration/test_cases/itest_metrics.yaml @@ -2225,5 +2225,5 @@ integration_test: SELECT SUM(1) AS bookings_between_dec_18_2019_and_dec_20_2019 FROM {{ source_schema }}.fct_bookings - WHERE ({{ render_date_trunc("ds", TimeGranularity.DAY) }} < '2012-12-20') - AND ({{ render_date_trunc("ds", TimeGranularity.WEEK) }} > '2019-12-18') + WHERE ({{ render_less_than_time_constraint(render_date_trunc("ds", TimeGranularity.DAY), '2012-12-20') }}) + AND ({{ render_greater_than_time_constraint(render_date_trunc("ds", TimeGranularity.WEEK), '2019-12-18') }}) diff --git a/tests_metricflow/integration/test_configured_cases.py b/tests_metricflow/integration/test_configured_cases.py index 1a781ebdf9..6db027a7da 100644 --- a/tests_metricflow/integration/test_configured_cases.py +++ b/tests_metricflow/integration/test_configured_cases.py @@ -65,6 +65,12 @@ def render_time_constraint( stop_expr = self.cast_to_ts(f"{stop_time_plus_one_day}") return f"{self.cast_expr_to_ts(expr)} >= {start_expr} AND {self.cast_expr_to_ts(expr)} < {stop_expr}" + def render_greater_than_time_constraint(self, expr: str, date_str: str) -> str: + return f"{expr} > {self.cast_to_ts(date_str)}" + + def render_less_than_time_constraint(self, expr: str, date_str: str) -> str: + return f"{expr} < {self.cast_to_ts(date_str)}" + def render_between_time_constraint( self, expr: str, @@ -296,6 +302,8 @@ def test_case( source_schema=mf_test_configuration.mf_source_schema, render_time_constraint=check_query_helpers.render_time_constraint, render_between_time_constraint=check_query_helpers.render_between_time_constraint, + render_greater_than_time_constraint=check_query_helpers.render_greater_than_time_constraint, + render_less_than_time_constraint=check_query_helpers.render_less_than_time_constraint, TimeGranularity=TimeGranularity, DatePart=DatePart, render_date_sub=check_query_helpers.render_date_sub, @@ -329,6 +337,8 @@ def test_case( source_schema=mf_test_configuration.mf_source_schema, render_time_constraint=check_query_helpers.render_time_constraint, render_between_time_constraint=check_query_helpers.render_between_time_constraint, + render_greater_than_time_constraint=check_query_helpers.render_greater_than_time_constraint, + render_less_than_time_constraint=check_query_helpers.render_less_than_time_constraint, TimeGranularity=TimeGranularity, DatePart=DatePart, render_date_sub=check_query_helpers.render_date_sub,