From a7e8cbfcfd0abedfded8d32d4cbe7056b67b29d4 Mon Sep 17 00:00:00 2001 From: sarbmeetka Date: Sun, 8 Oct 2023 19:53:15 -0600 Subject: [PATCH] Handle dry run and approx percentile for Trino along with more explicit castings --- .../dbt_connectors/adapter_backed_client.py | 13 +++++++++- metricflow/sql/render/trino.py | 6 ++--- metricflow/test/generate_snapshots.py | 10 +++++++ .../test_cases/itest_granularity.yaml | 26 +++++++++---------- .../test_cases/itest_order_limit.yaml | 2 +- .../integration/test_cases/itest_scd.yaml | 22 ++++++++-------- .../itest_semi_additive_measure.yaml | 12 ++++----- .../test/integration/test_configured_cases.py | 6 ++--- .../test_constrain_time_range_node__plan0.sql | 2 +- ...train_time_range_node__plan0_optimized.sql | 2 +- ..._no_window_with_time_constraint__plan0.sql | 2 +- ..._with_time_constraint__plan0_optimized.sql | 2 +- ...ive_metric_with_time_constraint__plan0.sql | 2 +- ..._with_time_constraint__plan0_optimized.sql | 2 +- ...rived_metric_with_offset_window__plan0.sql | 2 +- ...ic_with_offset_window__plan0_optimized.sql | 2 +- ...h_offset_window_and_granularity__plan0.sql | 2 +- ...indow_and_granularity__plan0_optimized.sql | 2 +- ...fset_window_and_offset_to_grain__plan0.sql | 2 +- ...w_and_offset_to_grain__plan0_optimized.sql | 2 +- ...offset_to_grain_and_granularity__plan0.sql | 2 +- ...grain_and_granularity__plan0_optimized.sql | 2 +- ...erived_offset_cumulative_metric__plan0.sql | 4 +-- ...set_cumulative_metric__plan0_optimized.sql | 4 +-- ...et_metric_with_one_input_metric__plan0.sql | 2 +- ...with_one_input_metric__plan0_optimized.sql | 2 +- ...spine_node_with_offset_to_grain__plan0.sql | 2 +- ..._with_offset_to_grain__plan0_optimized.sql | 2 +- ...e_spine_node_with_offset_window__plan0.sql | 4 +-- ...de_with_offset_window__plan0_optimized.sql | 4 +-- ..._time_spine_node_without_offset__plan0.sql | 2 +- ...e_node_without_offset__plan0_optimized.sql | 2 +- ..._multiple_metrics_no_dimensions__plan0.sql | 4 +-- ...metrics_no_dimensions__plan0_optimized.sql | 4 +-- ...st_offset_window_with_date_part__plan0.sql | 2 +- ...window_with_date_part__plan0_optimized.sql | 2 +- ...mate_continuous_percentile_expr__plan0.sql | 2 +- 37 files changed, 94 insertions(+), 73 deletions(-) diff --git a/metricflow/cli/dbt_connectors/adapter_backed_client.py b/metricflow/cli/dbt_connectors/adapter_backed_client.py index c9c6fe7b05..cc15d521a9 100644 --- a/metricflow/cli/dbt_connectors/adapter_backed_client.py +++ b/metricflow/cli/dbt_connectors/adapter_backed_client.py @@ -219,7 +219,18 @@ def dry_run( request_id = SqlRequestId(f"mf_rid__{random_id()}") connection_name = f"MetricFlow_dry_run_request_{request_id}" # TODO - consolidate to self._adapter.validate_sql() when all implementations will work from within MetricFlow - if self.sql_engine_type is SqlEngine.BIGQUERY: + + # Trino has a bug where explain command actually creates table. Wrapping with validate to avoid this. + # See https://github.com/trinodb/trino/issues/130 + if self.sql_engine_type is SqlEngine.TRINO: + with self._adapter.connection_named(connection_name): + # Either the response will be bool value or a string with error message from Trino. + result = self._adapter.execute(f"EXPLAIN (type validate) {stmt}", auto_begin=True, fetch=True) + has_error = False if str(result[0]) == "SUCCESS" else True + if has_error: + raise DbtDatabaseError("Encountered error in Trino dry run.") + + elif self.sql_engine_type is SqlEngine.BIGQUERY: with self._adapter.connection_named(connection_name): self._adapter.validate_sql(stmt) else: diff --git a/metricflow/sql/render/trino.py b/metricflow/sql/render/trino.py index 00163828f6..c24ff8c3df 100644 --- a/metricflow/sql/render/trino.py +++ b/metricflow/sql/render/trino.py @@ -2,10 +2,10 @@ from typing import Collection +from dateutil.parser import parse from dbt_semantic_interfaces.enum_extension import assert_values_exhausted from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity from typing_extensions import override -from dateutil.parser import parse from metricflow.sql.render.expr_renderer import ( DefaultSqlExpressionRenderer, @@ -15,11 +15,11 @@ from metricflow.sql.render.sql_plan_renderer import DefaultSqlQueryPlanRenderer from metricflow.sql.sql_bind_parameters import SqlBindParameters from metricflow.sql.sql_exprs import ( + SqlBetweenExpression, SqlGenerateUuidExpression, SqlPercentileExpression, SqlPercentileFunctionType, SqlTimeDeltaExpression, - SqlBetweenExpression ) @@ -75,7 +75,7 @@ def visit_percentile_expr(self, node: SqlPercentileExpression) -> SqlExpressionR function_str = "PERCENTILE_DISC" elif node.percentile_args.function_type is SqlPercentileFunctionType.APPROXIMATE_CONTINUOUS: return SqlExpressionRenderResult( - sql=f"approx_quantile({arg_rendered.sql}, {percentile})", + sql=f"approx_percentile({arg_rendered.sql}, {percentile})", bind_parameters=params, ) elif node.percentile_args.function_type is SqlPercentileFunctionType.APPROXIMATE_DISCRETE: diff --git a/metricflow/test/generate_snapshots.py b/metricflow/test/generate_snapshots.py index 64b87d91b5..857fa1a026 100644 --- a/metricflow/test/generate_snapshots.py +++ b/metricflow/test/generate_snapshots.py @@ -28,6 +28,10 @@ "engine_url": postgres://...", "engine_password": "..." }, + "trino": { + "engine_url": trino://...", + "engine_password": "..." + }, } EOF ) @@ -66,6 +70,7 @@ class MetricFlowTestCredentialSetForAllEngines(FrozenBaseModel): # noqa: D big_query: MetricFlowTestCredentialSet databricks: MetricFlowTestCredentialSet postgres: MetricFlowTestCredentialSet + trino: MetricFlowTestCredentialSet @property def as_configurations(self) -> Sequence[MetricFlowTestConfiguration]: # noqa: D @@ -94,6 +99,10 @@ def as_configurations(self) -> Sequence[MetricFlowTestConfiguration]: # noqa: D engine=SqlEngine.POSTGRES, credential_set=self.postgres, ), + MetricFlowTestConfiguration( + engine=SqlEngine.TRINO, + credential_set=self.trino, + ), ) @@ -149,6 +158,7 @@ def run_tests(test_configuration: MetricFlowTestConfiguration, test_file_paths: or test_configuration.engine is SqlEngine.BIGQUERY or test_configuration.engine is SqlEngine.DATABRICKS or test_configuration.engine is SqlEngine.POSTGRES + or test_configuration.engine is SqlEngine.TRINO ): engine_name = test_configuration.engine.value.lower() os.environ["MF_TEST_ADAPTER_TYPE"] = engine_name diff --git a/metricflow/test/integration/test_cases/itest_granularity.yaml b/metricflow/test/integration/test_cases/itest_granularity.yaml index 7aee578af1..ea3f974516 100644 --- a/metricflow/test/integration/test_cases/itest_granularity.yaml +++ b/metricflow/test/integration/test_cases/itest_granularity.yaml @@ -25,7 +25,7 @@ integration_test: , {{ render_date_trunc("ds", TimeGranularity.WEEK) }} AS metric_time__week FROM {{ source_schema }}.fct_bookings_extended GROUP BY - metric_time__week + {{ render_date_trunc("ds", TimeGranularity.WEEK) }} --- integration_test: name: query_granularity_for_sum_month @@ -39,7 +39,7 @@ integration_test: , {{ render_date_trunc("ds", TimeGranularity.MONTH) }} AS metric_time__month FROM {{ source_schema }}.fct_bookings_extended GROUP BY - metric_time__month + {{ render_date_trunc("ds", TimeGranularity.MONTH) }} --- integration_test: name: query_granularity_for_sum_quarter @@ -53,7 +53,7 @@ integration_test: , {{ render_date_trunc("ds", TimeGranularity.QUARTER) }} AS metric_time__quarter FROM {{ source_schema }}.fct_bookings_extended GROUP BY - metric_time__quarter + {{ render_date_trunc("ds", TimeGranularity.QUARTER) }} --- integration_test: name: query_granularity_for_sum_year @@ -67,7 +67,7 @@ integration_test: , {{ render_date_trunc("ds", TimeGranularity.YEAR) }} AS metric_time__year FROM {{ source_schema }}.fct_bookings_extended GROUP BY - metric_time__year + {{ render_date_trunc("ds", TimeGranularity.YEAR) }} --- integration_test: name: query_granularity_for_count_distinct_day @@ -95,7 +95,7 @@ integration_test: , {{ render_date_trunc("ds", TimeGranularity.WEEK) }} AS metric_time__week FROM {{ source_schema }}.fct_bookings_extended GROUP BY - metric_time__week + {{ render_date_trunc("ds", TimeGranularity.WEEK) }} --- integration_test: name: query_granularity_for_count_distinct_month @@ -109,7 +109,7 @@ integration_test: , {{ render_date_trunc("ds", TimeGranularity.MONTH) }} AS metric_time__month FROM {{ source_schema }}.fct_bookings_extended GROUP BY - metric_time__month + {{ render_date_trunc("ds", TimeGranularity.MONTH) }} --- integration_test: name: query_granularity_for_count_distinct_quarter @@ -123,7 +123,7 @@ integration_test: , {{ render_date_trunc("ds", TimeGranularity.QUARTER) }} AS metric_time__quarter FROM {{ source_schema }}.fct_bookings_extended GROUP BY - metric_time__quarter + {{ render_date_trunc("ds", TimeGranularity.QUARTER) }} --- integration_test: name: query_granularity_for_count_distinct_year @@ -137,7 +137,7 @@ integration_test: , {{ render_date_trunc("ds", TimeGranularity.YEAR) }} AS metric_time__year FROM {{ source_schema }}.fct_bookings_extended GROUP BY - metric_time__year + {{ render_date_trunc("ds", TimeGranularity.YEAR) }} --- integration_test: name: query_granularity_for_joined_dundered_dimension_day @@ -185,7 +185,7 @@ integration_test: FROM {{ source_schema }}.fct_bookings_extended_monthly WHERE {{ render_time_constraint("ds", "2020-01-01", "2020-02-29") }} GROUP BY - metric_time__month + ds --- integration_test: name: metric_with_non_day_granularity_on_non_boundaries @@ -201,7 +201,7 @@ integration_test: FROM {{ source_schema }}.fct_bookings_extended_monthly WHERE {{ render_time_constraint("ds", "2020-01-01", "2020-02-29") }} GROUP BY - metric_time__month + ds --- integration_test: name: weekly_metric_on_non_boundaries @@ -217,7 +217,7 @@ integration_test: FROM {{ source_schema }}.fct_bookings_extended WHERE {{ render_time_constraint("ds", "2020-01-13", "2020-01-26") }} GROUP BY - metric_time__week + {{ render_date_trunc("ds", TimeGranularity.WEEK) }} --- integration_test: name: daily_metric_with_monthly_time_dimension @@ -233,7 +233,7 @@ integration_test: FROM {{ source_schema }}.fct_bookings_extended WHERE {{ render_time_constraint("ds", "2020-01-01", "2020-01-31") }} GROUP BY - metric_time__month + {{ render_date_trunc("ds", TimeGranularity.MONTH) }} --- integration_test: name: metrics_with_different_time_granularities @@ -273,7 +273,7 @@ integration_test: ON a.ds = b.ds ) c GROUP BY - metric_time__month + ds --- integration_test: name: metrics_with_different_time_granularities_and_no_metric_time diff --git a/metricflow/test/integration/test_cases/itest_order_limit.yaml b/metricflow/test/integration/test_cases/itest_order_limit.yaml index b8a1f6b44d..7e5af9779c 100644 --- a/metricflow/test/integration/test_cases/itest_order_limit.yaml +++ b/metricflow/test/integration/test_cases/itest_order_limit.yaml @@ -69,6 +69,6 @@ integration_test: , SUM(booking_value) AS booking_value FROM {{ source_schema }}.fct_bookings GROUP BY - metric_time__month + {{ render_date_trunc("ds", TimeGranularity.MONTH) }} ORDER BY metric_time__month DESC, booking_value diff --git a/metricflow/test/integration/test_cases/itest_scd.yaml b/metricflow/test/integration/test_cases/itest_scd.yaml index 42e3d5a980..b44b444060 100644 --- a/metricflow/test/integration/test_cases/itest_scd.yaml +++ b/metricflow/test/integration/test_cases/itest_scd.yaml @@ -15,7 +15,7 @@ integration_test: ON a.listing_id = b.listing_id AND a.ds >= b.active_from AND (a.ds < b.active_to OR b.active_to is NULL) GROUP BY - listing__capacity, metric_time__day + capacity, ds --- integration_test: name: basic_scd_constrained_metric @@ -35,7 +35,7 @@ integration_test: WHERE b.capacity >= 3 GROUP BY is_instant - , metric_time__day + , ds --- integration_test: name: scd_constrained_metric_with_nulls @@ -61,8 +61,8 @@ integration_test: WHERE b.is_lux OR b.is_lux IS NULL GROUP BY is_instant - , metric_time__day - , listing__is_lux + , ds + , is_lux --- integration_test: name: scd_grouped_metric_with_second_dim @@ -87,9 +87,9 @@ integration_test: LEFT OUTER JOIN {{ source_schema }}.dim_users_latest c ON b.user_id = c.user_id GROUP BY - metric_time__day - , listing__is_lux - , listing__user__home_state_latest + a.ds + , b.is_lux + , c.home_state_latest --- integration_test: name: scd_multi_hop_groupby_through_scd @@ -112,8 +112,8 @@ integration_test: LEFT OUTER JOIN {{ source_schema }}.dim_users_latest c ON b.user_id = c.user_id GROUP BY - metric_time__day - , listing__user__home_state_latest + a.ds + , c.home_state_latest --- integration_test: name: scd_multi_hop_groupby_to_scd @@ -136,5 +136,5 @@ integration_test: ON b.lux_listing_id = c.lux_listing_id AND a.ds >= c.valid_from AND (a.ds < c.valid_to OR c.valid_to is NULL) GROUP BY - metric_time__day - , listing__lux_listing__is_confirmed_lux + a.ds + , c.is_confirmed_lux diff --git a/metricflow/test/integration/test_cases/itest_semi_additive_measure.yaml b/metricflow/test/integration/test_cases/itest_semi_additive_measure.yaml index 9043723f43..59cb7429f3 100644 --- a/metricflow/test/integration/test_cases/itest_semi_additive_measure.yaml +++ b/metricflow/test/integration/test_cases/itest_semi_additive_measure.yaml @@ -55,7 +55,7 @@ integration_test: , MAX(ds) AS ds FROM {{ source_schema }}.fct_accounts GROUP BY - metric_time__week + {{ render_date_trunc("ds", TimeGranularity.WEEK) }} , user_id ) b ON @@ -85,7 +85,7 @@ integration_test: , {{ render_date_trunc("ds", TimeGranularity.DAY) }} AS metric_time__day FROM {{ source_schema }}.fct_accounts GROUP BY - metric_time__day + {{ render_date_trunc("ds", TimeGranularity.DAY) }} ) b ON a.ds = b.ds @@ -167,7 +167,7 @@ integration_test: , {{ render_date_trunc("ds", TimeGranularity.WEEK) }} AS metric_time__week FROM {{ source_schema }}.fct_accounts GROUP BY - metric_time__week + {{ render_date_trunc("ds", TimeGranularity.WEEK) }} ) b ON a.ds = b.ds @@ -226,7 +226,7 @@ integration_test: model: SIMPLE_MODEL metrics: ["total_account_balance_first_day"] group_bys: ["account__account_type"] - where_filter: "{{ render_time_dimension_template('account__ds', 'day') }} >= '2020-01-03'" + where_filter: "{{ render_time_dimension_template('account__ds', 'day') }} >= {{ cast_to_ts('2020-01-03') }}" check_query: | SELECT b.account_type AS account__account_type @@ -243,7 +243,7 @@ integration_test: , account_balance AS total_account_balance_first_day FROM {{ source_schema }}.fct_accounts ) a - WHERE ds >= '2020-01-03' + WHERE ds >= {{ cast_to_ts('2020-01-03') }} ) b INNER JOIN ( SELECT @@ -253,7 +253,7 @@ integration_test: ds FROM {{ source_schema }}.fct_accounts ) c - WHERE ds >= '2020-01-03' + WHERE ds >= {{ cast_to_ts('2020-01-03') }} ) d ON b.ds = d.ds__complete diff --git a/metricflow/test/integration/test_configured_cases.py b/metricflow/test/integration/test_configured_cases.py index 2e6f0756c2..d9f69f9e67 100644 --- a/metricflow/test/integration/test_configured_cases.py +++ b/metricflow/test/integration/test_configured_cases.py @@ -76,9 +76,7 @@ def render_between_time_constraint( start_time: str, stop_time: str, ) -> str: - """ Render an expression like "ds between timestamp '2020-01-01' AND timestamp '2020-01-02'" - since Trino require timestamp literals to be wrapped in a timestamp() function. - """ + """Render an expression like "ds between timestamp '2020-01-01' AND timestamp '2020-01-02'" since Trino require timestamp literals to be wrapped in a timestamp() function.""" start_expr = self.cast_to_ts(f"{start_time}") stop_expr = self.cast_to_ts(f"{stop_time}") return f"{expr} BETWEEN {start_expr} AND {stop_expr}" @@ -309,6 +307,7 @@ def test_case( render_dimension_template=check_query_helpers.render_dimension_template, render_entity_template=check_query_helpers.render_entity_template, render_time_dimension_template=check_query_helpers.render_time_dimension_template, + cast_to_ts=check_query_helpers.cast_to_ts, ) if case.where_filter else None, @@ -334,6 +333,7 @@ def test_case( render_percentile_expr=check_query_helpers.render_percentile_expr, mf_time_spine_source=semantic_manifest_lookup.time_spine_source.spine_table.sql, double_data_type_name=check_query_helpers.double_data_type_name, + cast_to_ts=check_query_helpers.cast_to_ts, ) ) # If we sort, it's effectively not checking the order whatever order that the output was would be overwritten. diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_constrain_time_range_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_constrain_time_range_node__plan0.sql index 5b6dd99cc4..4278be9e4c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_constrain_time_range_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_constrain_time_range_node__plan0.sql @@ -116,4 +116,4 @@ FROM ( ) subq_0 ) subq_1 ) subq_2 -WHERE subq_2.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' +WHERE subq_2.metric_time__day BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-02' diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_constrain_time_range_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_constrain_time_range_node__plan0_optimized.sql index bfc4959615..0c8b28937a 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_constrain_time_range_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_constrain_time_range_node__plan0_optimized.sql @@ -8,4 +8,4 @@ SELECT , ds AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 -WHERE ds BETWEEN '2020-01-01' AND '2020-01-02' +WHERE ds BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-02' diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index 5cba3a3202..308cae149d 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -130,7 +130,7 @@ FROM ( FROM ***************************.fct_revenue revenue_src_10006 ) subq_0 ) subq_1 - WHERE subq_1.metric_time__day BETWEEN '2000-01-01' AND '2020-01-01' + WHERE subq_1.metric_time__day BETWEEN timestamp '2000-01-01' AND timestamp '2020-01-01' ) subq_2 ) subq_3 GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index c420ef636f..697ab2fb18 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -9,6 +9,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS revenue_all_time FROM ***************************.fct_revenue revenue_src_10006 -WHERE created_at BETWEEN '2000-01-01' AND '2020-01-01' +WHERE created_at BETWEEN timestamp '2000-01-01' AND timestamp '2020-01-01' GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0.sql index 414159089b..bf6c16fbc2 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0.sql @@ -130,7 +130,7 @@ FROM ( FROM ***************************.fct_revenue revenue_src_10006 ) subq_0 ) subq_1 - WHERE subq_1.metric_time__day BETWEEN '2019-12-01' AND '2020-01-01' + WHERE subq_1.metric_time__day BETWEEN timestamp '2019-12-01' AND timestamp '2020-01-01' ) subq_2 ) subq_3 GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index e3387b51e4..84588c24f3 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -9,6 +9,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS trailing_2_months_revenue FROM ***************************.fct_revenue revenue_src_10006 -WHERE created_at BETWEEN '2019-12-01' AND '2020-01-01' +WHERE created_at BETWEEN timestamp '2019-12-01' AND timestamp '2020-01-01' GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window__plan0.sql index 38aeec72e9..453ed49bde 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window__plan0.sql @@ -565,7 +565,7 @@ FROM ( ) subq_5 ) subq_6 ON - subq_7.metric_time__day - INTERVAL 14 day = subq_6.metric_time__day + CAST(subq_7.metric_time__day AS TIMESTAMP) - INTERVAL '14' day = subq_6.metric_time__day ) subq_9 ) subq_10 GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window__plan0_optimized.sql index 28b07ca0e2..b7ccecc378 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window__plan0_optimized.sql @@ -46,7 +46,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_20 ON - subq_22.ds - INTERVAL 14 day = subq_20.metric_time__day + CAST(subq_22.ds AS TIMESTAMP) - INTERVAL '14' day = subq_20.metric_time__day GROUP BY subq_22.ds ) subq_26 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_granularity__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_granularity__plan0.sql index 0ad6211336..ad51fb152c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_granularity__plan0.sql @@ -565,7 +565,7 @@ FROM ( ) subq_5 ) subq_6 ON - subq_7.metric_time__day - INTERVAL 14 day = subq_6.metric_time__day + CAST(subq_7.metric_time__day AS TIMESTAMP) - INTERVAL '14' day = subq_6.metric_time__day ) subq_9 ) subq_10 GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql index db9eaf374e..2341c656f8 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql @@ -46,7 +46,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_20 ON - subq_22.ds - INTERVAL 14 day = subq_20.metric_time__day + CAST(subq_22.ds AS TIMESTAMP) - INTERVAL '14' day = subq_20.metric_time__day GROUP BY DATE_TRUNC('quarter', subq_22.ds) ) subq_26 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql index c987150223..57de20f8c8 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql @@ -671,7 +671,7 @@ FROM ( ) subq_8 ) subq_9 ON - subq_10.metric_time__day - INTERVAL 1 month = subq_9.metric_time__day + CAST(subq_10.metric_time__day AS TIMESTAMP) - INTERVAL '1' month = subq_9.metric_time__day ) subq_12 ) subq_13 GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql index e239a53fef..bce093c2bf 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql @@ -50,7 +50,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_26 ON - subq_28.ds - INTERVAL 1 month = subq_26.metric_time__day + CAST(subq_28.ds AS TIMESTAMP) - INTERVAL '1' month = subq_26.metric_time__day GROUP BY subq_28.ds ) subq_32 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql index cddee48ddb..4b9645ffb7 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql @@ -672,7 +672,7 @@ FROM ( ) subq_8 ) subq_9 ON - subq_10.metric_time__day - INTERVAL 1 month = subq_9.metric_time__day + CAST(subq_10.metric_time__day AS TIMESTAMP) - INTERVAL '1' month = subq_9.metric_time__day ) subq_12 ) subq_13 GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql index f4b9c2a35c..dfa4bb2e86 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql @@ -51,7 +51,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_26 ON - subq_28.ds - INTERVAL 1 month = subq_26.metric_time__day + CAST(subq_28.ds AS TIMESTAMP) - INTERVAL '1' month = subq_26.metric_time__day GROUP BY DATE_TRUNC('year', subq_28.ds) ) subq_32 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_offset_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_offset_cumulative_metric__plan0.sql index 94cf44278b..24d934dad9 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_offset_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_offset_cumulative_metric__plan0.sql @@ -447,11 +447,11 @@ FROM ( ( subq_1.metric_time__day <= subq_2.metric_time__day ) AND ( - subq_1.metric_time__day > subq_2.metric_time__day - INTERVAL 2 day + subq_1.metric_time__day > CAST(subq_2.metric_time__day AS TIMESTAMP) - INTERVAL '2' day ) ) subq_4 ON - subq_5.metric_time__day - INTERVAL 2 day = subq_4.metric_time__day + CAST(subq_5.metric_time__day AS TIMESTAMP) - INTERVAL '2' day = subq_4.metric_time__day ) subq_7 ) subq_8 GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_offset_cumulative_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_offset_cumulative_metric__plan0_optimized.sql index 1b96977064..2655024e11 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_offset_cumulative_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_offset_cumulative_metric__plan0_optimized.sql @@ -24,11 +24,11 @@ FROM ( ( bookings_source_src_10001.ds <= subq_14.ds ) AND ( - bookings_source_src_10001.ds > subq_14.ds - INTERVAL 2 day + bookings_source_src_10001.ds > CAST(subq_14.ds AS TIMESTAMP) - INTERVAL '2' day ) ) subq_15 ON - subq_17.ds - INTERVAL 2 day = subq_15.metric_time__day + CAST(subq_17.ds AS TIMESTAMP) - INTERVAL '2' day = subq_15.metric_time__day GROUP BY subq_17.ds ) subq_21 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_one_input_metric__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_one_input_metric__plan0.sql index 6b4f9e31f9..609ed03345 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_one_input_metric__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_one_input_metric__plan0.sql @@ -330,7 +330,7 @@ FROM ( ) subq_0 ) subq_1 ON - subq_2.metric_time__day - INTERVAL 5 day = subq_1.metric_time__day + CAST(subq_2.metric_time__day AS TIMESTAMP) - INTERVAL '5' day = subq_1.metric_time__day ) subq_4 ) subq_5 GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql index b5a8855b9c..6d4efccd71 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql @@ -21,7 +21,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_9 ON - subq_11.ds - INTERVAL 5 day = subq_9.metric_time__day + CAST(subq_11.ds AS TIMESTAMP) - INTERVAL '5' day = subq_9.metric_time__day GROUP BY subq_11.ds ) subq_15 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql index 9f23719b49..38492f6341 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql @@ -8,7 +8,7 @@ FROM ( SELECT subq_6.ds AS metric_time__day FROM ***************************.mf_time_spine subq_6 - WHERE subq_6.ds BETWEEN '2020-01-01' AND '2021-01-01' + WHERE subq_6.ds BETWEEN timestamp '2020-01-01' AND timestamp '2021-01-01' ) subq_5 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql index 6a4ced8cd8..4fddfa6c2c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql @@ -8,7 +8,7 @@ FROM ( SELECT ds AS metric_time__day FROM ***************************.mf_time_spine subq_13 - WHERE ds BETWEEN '2020-01-01' AND '2021-01-01' + WHERE ds BETWEEN timestamp '2020-01-01' AND timestamp '2021-01-01' ) subq_12 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_window__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_window__plan0.sql index 406b83cae3..811955977e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_window__plan0.sql @@ -8,7 +8,7 @@ FROM ( SELECT subq_6.ds AS metric_time__day FROM ***************************.mf_time_spine subq_6 - WHERE subq_6.ds BETWEEN '2020-01-01' AND '2021-01-01' + WHERE subq_6.ds BETWEEN timestamp '2020-01-01' AND timestamp '2021-01-01' ) subq_5 INNER JOIN ( -- Compute Metrics via Expressions @@ -244,4 +244,4 @@ INNER JOIN ( ) subq_3 ) subq_4 ON - subq_5.metric_time__day - INTERVAL 10 day = subq_4.metric_time__day + CAST(subq_5.metric_time__day AS TIMESTAMP) - INTERVAL '10' day = subq_4.metric_time__day diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql index 4a9399b1f2..98efd224f9 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql @@ -8,7 +8,7 @@ FROM ( SELECT ds AS metric_time__day FROM ***************************.mf_time_spine subq_13 - WHERE ds BETWEEN '2020-01-01' AND '2021-01-01' + WHERE ds BETWEEN timestamp '2020-01-01' AND timestamp '2021-01-01' ) subq_12 INNER JOIN ( -- Compute Metrics via Expressions @@ -33,4 +33,4 @@ INNER JOIN ( ) subq_10 ) subq_11 ON - subq_12.metric_time__day - INTERVAL 10 day = subq_11.metric_time__day + CAST(subq_12.metric_time__day AS TIMESTAMP) - INTERVAL '10' day = subq_11.metric_time__day diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_without_offset__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_without_offset__plan0.sql index 2093e49b0b..642ca46e74 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_without_offset__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_without_offset__plan0.sql @@ -8,7 +8,7 @@ FROM ( SELECT subq_6.ds AS metric_time__day FROM ***************************.mf_time_spine subq_6 - WHERE subq_6.ds BETWEEN '2020-01-01' AND '2021-01-01' + WHERE subq_6.ds BETWEEN timestamp '2020-01-01' AND timestamp '2021-01-01' ) subq_5 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_without_offset__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_without_offset__plan0_optimized.sql index 4afadfc929..1b4288571b 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_without_offset__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_without_offset__plan0_optimized.sql @@ -8,7 +8,7 @@ FROM ( SELECT ds AS metric_time__day FROM ***************************.mf_time_spine subq_13 - WHERE ds BETWEEN '2020-01-01' AND '2021-01-01' + WHERE ds BETWEEN timestamp '2020-01-01' AND timestamp '2021-01-01' ) subq_12 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_multiple_metrics_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_multiple_metrics_no_dimensions__plan0.sql index 54b108dd33..275fe93c4e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_multiple_metrics_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_multiple_metrics_no_dimensions__plan0.sql @@ -331,7 +331,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_0 ) subq_1 - WHERE subq_1.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' + WHERE subq_1.metric_time__day BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' ) subq_2 ) subq_3 ) subq_4 @@ -565,7 +565,7 @@ CROSS JOIN ( FROM ***************************.dim_listings_latest listings_latest_src_10004 ) subq_6 ) subq_7 - WHERE subq_7.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' + WHERE subq_7.metric_time__day BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' ) subq_8 ) subq_9 ) subq_10 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_multiple_metrics_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_multiple_metrics_no_dimensions__plan0_optimized.sql index 74dcbb71f8..58bfd2747e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_multiple_metrics_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_multiple_metrics_no_dimensions__plan0_optimized.sql @@ -13,7 +13,7 @@ FROM ( SELECT SUM(1) AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 - WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' + WHERE ds BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' ) subq_17 CROSS JOIN ( -- Read Elements From Semantic Model 'listings_latest' @@ -26,5 +26,5 @@ CROSS JOIN ( SELECT SUM(1) AS listings FROM ***************************.dim_listings_latest listings_latest_src_10004 - WHERE created_at BETWEEN '2020-01-01' AND '2020-01-01' + WHERE created_at BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' ) subq_23 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_offset_window_with_date_part__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_offset_window_with_date_part__plan0.sql index a65895e8b1..243fd36ac8 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_offset_window_with_date_part__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_offset_window_with_date_part__plan0.sql @@ -565,7 +565,7 @@ FROM ( ) subq_5 ) subq_6 ON - subq_7.metric_time__day - INTERVAL 14 day = subq_6.metric_time__day + CAST(subq_7.metric_time__day AS TIMESTAMP) - INTERVAL '14' day = subq_6.metric_time__day ) subq_9 ) subq_10 GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_offset_window_with_date_part__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_offset_window_with_date_part__plan0_optimized.sql index 5f6ec1ee79..6deb5f4a9e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_offset_window_with_date_part__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_offset_window_with_date_part__plan0_optimized.sql @@ -46,7 +46,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_20 ON - subq_22.ds - INTERVAL 14 day = subq_20.metric_time__day + CAST(subq_22.ds AS TIMESTAMP) - INTERVAL '14' day = subq_20.metric_time__day GROUP BY EXTRACT(dow FROM subq_22.ds) ) subq_26 diff --git a/metricflow/test/snapshots/test_engine_specific_rendering.py/SqlQueryPlan/Trino/test_approximate_continuous_percentile_expr__plan0.sql b/metricflow/test/snapshots/test_engine_specific_rendering.py/SqlQueryPlan/Trino/test_approximate_continuous_percentile_expr__plan0.sql index ca1e6ab7a9..5ad435c9e1 100644 --- a/metricflow/test/snapshots/test_engine_specific_rendering.py/SqlQueryPlan/Trino/test_approximate_continuous_percentile_expr__plan0.sql +++ b/metricflow/test/snapshots/test_engine_specific_rendering.py/SqlQueryPlan/Trino/test_approximate_continuous_percentile_expr__plan0.sql @@ -1,4 +1,4 @@ -- Test Approximate Continuous Percentile Expression SELECT - approx_quantile(a.col0, 0.5) AS col0_percentile + approx_percentile(a.col0, 0.5) AS col0_percentile FROM foo.bar a