From 2e1cabbdc073ca2546b985af0c3d50d1b80c840d Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Wed, 11 Dec 2024 15:28:35 -0800 Subject: [PATCH 01/13] Move sql_exprs file into metricflow-semantics --- .../metricflow_semantics}/sql/sql_exprs.py | 0 metricflow/dataset/convert_semantic_model.py | 14 ++-- metricflow/plan_conversion/dataflow_to_sql.py | 44 ++++++------- .../plan_conversion/instance_converters.py | 10 +-- .../sql_expression_builders.py | 3 +- .../plan_conversion/sql_join_builder.py | 18 ++--- .../sql/optimizer/required_column_aliases.py | 2 +- .../optimizer/rewriting_sub_query_reducer.py | 8 +-- metricflow/sql/optimizer/sub_query_reducer.py | 2 +- metricflow/sql/render/big_query.py | 20 +++--- metricflow/sql/render/databricks.py | 2 +- metricflow/sql/render/duckdb_renderer.py | 14 ++-- metricflow/sql/render/expr_renderer.py | 8 +-- metricflow/sql/render/postgres.py | 14 ++-- metricflow/sql/render/redshift.py | 12 ++-- metricflow/sql/render/snowflake.py | 10 +-- metricflow/sql/render/sql_plan_renderer.py | 2 +- metricflow/sql/render/trino.py | 16 ++--- metricflow/sql/sql_plan.py | 3 +- .../dataflow/builder/test_node_data_set.py | 2 +- .../integration/test_configured_cases.py | 66 ++++++++++--------- .../mf_logging/test_dag_to_text.py | 6 +- ...select_columns_with_measures_aggregated.py | 10 +-- .../sql/optimizer/test_column_pruner.py | 14 ++-- .../sql/optimizer/test_cte_column_pruner.py | 12 ++-- .../test_cte_rewriting_sub_query_reducer.py | 12 ++-- .../test_cte_table_alias_simplifier.py | 12 ++-- .../test_rewriting_sub_query_reducer.py | 12 ++-- .../sql/optimizer/test_sub_query_reducer.py | 12 ++-- .../optimizer/test_table_alias_simplifier.py | 12 ++-- .../sql/test_engine_specific_rendering.py | 10 +-- tests_metricflow/sql/test_render_cte.py | 10 +-- tests_metricflow/sql/test_sql_expr_render.py | 8 +-- tests_metricflow/sql/test_sql_plan_render.py | 12 ++-- .../sql_clients/test_date_time_operations.py | 8 +-- 35 files changed, 211 insertions(+), 209 deletions(-) rename {metricflow => metricflow-semantics/metricflow_semantics}/sql/sql_exprs.py (100%) diff --git a/metricflow/sql/sql_exprs.py b/metricflow-semantics/metricflow_semantics/sql/sql_exprs.py similarity index 100% rename from metricflow/sql/sql_exprs.py rename to metricflow-semantics/metricflow_semantics/sql/sql_exprs.py diff --git a/metricflow/dataset/convert_semantic_model.py b/metricflow/dataset/convert_semantic_model.py index 56ee4279e6..050b13edb6 100644 --- a/metricflow/dataset/convert_semantic_model.py +++ b/metricflow/dataset/convert_semantic_model.py @@ -32,13 +32,7 @@ from metricflow_semantics.specs.dimension_spec import DimensionSpec from metricflow_semantics.specs.entity_spec import EntitySpec from metricflow_semantics.specs.time_dimension_spec import DEFAULT_TIME_GRANULARITY, TimeDimensionSpec -from metricflow_semantics.sql.sql_table import SqlTable -from metricflow_semantics.time.granularity import ExpandedTimeGranularity -from metricflow_semantics.time.time_spine_source import TimeSpineSource - -from metricflow.dataset.semantic_model_adapter import SemanticModelDataSet -from metricflow.dataset.sql_dataset import SqlDataSet -from metricflow.sql.sql_exprs import ( +from metricflow_semantics.sql.sql_exprs import ( SqlColumnReference, SqlColumnReferenceExpression, SqlDateTruncExpression, @@ -46,6 +40,12 @@ SqlExtractExpression, SqlStringExpression, ) +from metricflow_semantics.sql.sql_table import SqlTable +from metricflow_semantics.time.granularity import ExpandedTimeGranularity +from metricflow_semantics.time.time_spine_source import TimeSpineSource + +from metricflow.dataset.semantic_model_adapter import SemanticModelDataSet +from metricflow.dataset.sql_dataset import SqlDataSet from metricflow.sql.sql_plan import ( SqlSelectColumn, SqlSelectStatementNode, diff --git a/metricflow/plan_conversion/dataflow_to_sql.py b/metricflow/plan_conversion/dataflow_to_sql.py index 90918cb8f4..d6c52dfbb0 100644 --- a/metricflow/plan_conversion/dataflow_to_sql.py +++ b/metricflow/plan_conversion/dataflow_to_sql.py @@ -37,6 +37,28 @@ from metricflow_semantics.specs.metric_spec import MetricSpec from metricflow_semantics.specs.spec_set import InstanceSpecSet from metricflow_semantics.specs.where_filter.where_filter_spec import WhereFilterSpec +from metricflow_semantics.sql.sql_exprs import ( + SqlAggregateFunctionExpression, + SqlBetweenExpression, + SqlColumnReference, + SqlColumnReferenceExpression, + SqlComparison, + SqlComparisonExpression, + SqlDateTruncExpression, + SqlExpressionNode, + SqlExtractExpression, + SqlFunction, + SqlFunctionExpression, + SqlGenerateUuidExpression, + SqlLogicalExpression, + SqlLogicalOperator, + SqlRatioComputationExpression, + SqlStringExpression, + SqlStringLiteralExpression, + SqlWindowFunction, + SqlWindowFunctionExpression, + SqlWindowOrderByArgument, +) from metricflow_semantics.sql.sql_join_type import SqlJoinType from metricflow_semantics.sql.sql_table import SqlTable from metricflow_semantics.time.granularity import ExpandedTimeGranularity @@ -112,28 +134,6 @@ SqlQueryOptimizationLevel, ) from metricflow.sql.optimizer.sql_query_plan_optimizer import SqlQueryPlanOptimizer -from metricflow.sql.sql_exprs import ( - SqlAggregateFunctionExpression, - SqlBetweenExpression, - SqlColumnReference, - SqlColumnReferenceExpression, - SqlComparison, - SqlComparisonExpression, - SqlDateTruncExpression, - SqlExpressionNode, - SqlExtractExpression, - SqlFunction, - SqlFunctionExpression, - SqlGenerateUuidExpression, - SqlLogicalExpression, - SqlLogicalOperator, - SqlRatioComputationExpression, - SqlStringExpression, - SqlStringLiteralExpression, - SqlWindowFunction, - SqlWindowFunctionExpression, - SqlWindowOrderByArgument, -) from metricflow.sql.sql_plan import ( SqlCreateTableAsNode, SqlCteNode, diff --git a/metricflow/plan_conversion/instance_converters.py b/metricflow/plan_conversion/instance_converters.py index b801d958d3..cb292a48eb 100644 --- a/metricflow/plan_conversion/instance_converters.py +++ b/metricflow/plan_conversion/instance_converters.py @@ -32,11 +32,7 @@ from metricflow_semantics.specs.instance_spec import InstanceSpec, LinkableInstanceSpec from metricflow_semantics.specs.measure_spec import MeasureSpec, MetricInputMeasureSpec from metricflow_semantics.specs.spec_set import InstanceSpecSet -from more_itertools import bucket - -from metricflow.dataflow.nodes.join_to_base import ValidityWindowJoinDescription -from metricflow.plan_conversion.select_column_gen import SelectColumnSet -from metricflow.sql.sql_exprs import ( +from metricflow_semantics.sql.sql_exprs import ( SqlAggregateFunctionExpression, SqlColumnReference, SqlColumnReferenceExpression, @@ -45,6 +41,10 @@ SqlFunctionExpression, SqlStringExpression, ) +from more_itertools import bucket + +from metricflow.dataflow.nodes.join_to_base import ValidityWindowJoinDescription +from metricflow.plan_conversion.select_column_gen import SelectColumnSet from metricflow.sql.sql_plan import ( SqlSelectColumn, ) diff --git a/metricflow/plan_conversion/sql_expression_builders.py b/metricflow/plan_conversion/sql_expression_builders.py index e5ed18d463..26029788c0 100644 --- a/metricflow/plan_conversion/sql_expression_builders.py +++ b/metricflow/plan_conversion/sql_expression_builders.py @@ -1,9 +1,10 @@ """Utility module for building sql expressions from inputs derived from dataflow plan or other nodes.""" + from __future__ import annotations from typing import List, Sequence -from metricflow.sql.sql_exprs import ( +from metricflow_semantics.sql.sql_exprs import ( SqlAggregateFunctionExpression, SqlColumnReference, SqlColumnReferenceExpression, diff --git a/metricflow/plan_conversion/sql_join_builder.py b/metricflow/plan_conversion/sql_join_builder.py index 284e203609..f80cdf2287 100644 --- a/metricflow/plan_conversion/sql_join_builder.py +++ b/metricflow/plan_conversion/sql_join_builder.py @@ -7,15 +7,7 @@ from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity from metricflow_semantics.assert_one_arg import assert_exactly_one_arg_set from metricflow_semantics.errors.custom_grain_not_supported import error_if_not_standard_grain -from metricflow_semantics.sql.sql_join_type import SqlJoinType - -from metricflow.dataflow.nodes.join_conversion_events import JoinConversionEventsNode -from metricflow.dataflow.nodes.join_over_time import JoinOverTimeRangeNode -from metricflow.dataflow.nodes.join_to_base import JoinDescription -from metricflow.dataflow.nodes.join_to_time_spine import JoinToTimeSpineNode -from metricflow.dataset.sql_dataset import AnnotatedSqlDataSet -from metricflow.plan_conversion.sql_expression_builders import make_coalesced_expr -from metricflow.sql.sql_exprs import ( +from metricflow_semantics.sql.sql_exprs import ( SqlColumnReference, SqlColumnReferenceExpression, SqlComparison, @@ -26,6 +18,14 @@ SqlLogicalOperator, SqlSubtractTimeIntervalExpression, ) +from metricflow_semantics.sql.sql_join_type import SqlJoinType + +from metricflow.dataflow.nodes.join_conversion_events import JoinConversionEventsNode +from metricflow.dataflow.nodes.join_over_time import JoinOverTimeRangeNode +from metricflow.dataflow.nodes.join_to_base import JoinDescription +from metricflow.dataflow.nodes.join_to_time_spine import JoinToTimeSpineNode +from metricflow.dataset.sql_dataset import AnnotatedSqlDataSet +from metricflow.plan_conversion.sql_expression_builders import make_coalesced_expr from metricflow.sql.sql_plan import SqlExpressionNode, SqlJoinDescription, SqlSelectStatementNode diff --git a/metricflow/sql/optimizer/required_column_aliases.py b/metricflow/sql/optimizer/required_column_aliases.py index 32dfacd32d..08022a6faa 100644 --- a/metricflow/sql/optimizer/required_column_aliases.py +++ b/metricflow/sql/optimizer/required_column_aliases.py @@ -5,10 +5,10 @@ from typing import Dict, FrozenSet, List, Set, Tuple from metricflow_semantics.mf_logging.lazy_formattable import LazyFormat +from metricflow_semantics.sql.sql_exprs import SqlExpressionTreeLineage from typing_extensions import override from metricflow.sql.optimizer.tag_column_aliases import NodeToColumnAliasMapping -from metricflow.sql.sql_exprs import SqlExpressionTreeLineage from metricflow.sql.sql_plan import ( SqlCreateTableAsNode, SqlCteNode, diff --git a/metricflow/sql/optimizer/rewriting_sub_query_reducer.py b/metricflow/sql/optimizer/rewriting_sub_query_reducer.py index bd4fbb87fb..82efa5dcd6 100644 --- a/metricflow/sql/optimizer/rewriting_sub_query_reducer.py +++ b/metricflow/sql/optimizer/rewriting_sub_query_reducer.py @@ -6,10 +6,7 @@ from metricflow_semantics.mf_logging.formatting import indent from metricflow_semantics.mf_logging.lazy_formattable import LazyFormat -from typing_extensions import override - -from metricflow.sql.optimizer.sql_query_plan_optimizer import SqlQueryPlanOptimizer -from metricflow.sql.sql_exprs import ( +from metricflow_semantics.sql.sql_exprs import ( SqlColumnAliasReferenceExpression, SqlColumnReference, SqlColumnReplacements, @@ -18,6 +15,9 @@ SqlLogicalExpression, SqlLogicalOperator, ) +from typing_extensions import override + +from metricflow.sql.optimizer.sql_query_plan_optimizer import SqlQueryPlanOptimizer from metricflow.sql.sql_plan import ( SqlCreateTableAsNode, SqlCteNode, diff --git a/metricflow/sql/optimizer/sub_query_reducer.py b/metricflow/sql/optimizer/sub_query_reducer.py index c223d5d3f7..9a930b99b2 100644 --- a/metricflow/sql/optimizer/sub_query_reducer.py +++ b/metricflow/sql/optimizer/sub_query_reducer.py @@ -3,10 +3,10 @@ import logging from typing import List, Optional +from metricflow_semantics.sql.sql_exprs import SqlColumnReference, SqlColumnReferenceExpression from typing_extensions import override from metricflow.sql.optimizer.sql_query_plan_optimizer import SqlQueryPlanOptimizer -from metricflow.sql.sql_exprs import SqlColumnReference, SqlColumnReferenceExpression from metricflow.sql.sql_plan import ( SqlCreateTableAsNode, SqlCteNode, diff --git a/metricflow/sql/render/big_query.py b/metricflow/sql/render/big_query.py index a63b2d06c6..5745ab2f8e 100644 --- a/metricflow/sql/render/big_query.py +++ b/metricflow/sql/render/big_query.py @@ -8,16 +8,7 @@ from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity from metricflow_semantics.errors.error_classes import UnsupportedEngineFeatureError from metricflow_semantics.sql.sql_bind_parameters import SqlBindParameterSet -from typing_extensions import override - -from metricflow.protocols.sql_client import SqlEngine -from metricflow.sql.render.expr_renderer import ( - DefaultSqlExpressionRenderer, - SqlExpressionRenderer, - SqlExpressionRenderResult, -) -from metricflow.sql.render.sql_plan_renderer import DefaultSqlQueryPlanRenderer -from metricflow.sql.sql_exprs import ( +from metricflow_semantics.sql.sql_exprs import ( SqlAddTimeExpression, SqlCastToTimestampExpression, SqlDateTruncExpression, @@ -27,6 +18,15 @@ SqlPercentileFunctionType, SqlSubtractTimeIntervalExpression, ) +from typing_extensions import override + +from metricflow.protocols.sql_client import SqlEngine +from metricflow.sql.render.expr_renderer import ( + DefaultSqlExpressionRenderer, + SqlExpressionRenderer, + SqlExpressionRenderResult, +) +from metricflow.sql.render.sql_plan_renderer import DefaultSqlQueryPlanRenderer from metricflow.sql.sql_plan import SqlSelectColumn diff --git a/metricflow/sql/render/databricks.py b/metricflow/sql/render/databricks.py index 5aa98000a7..2b7dbe6366 100644 --- a/metricflow/sql/render/databricks.py +++ b/metricflow/sql/render/databricks.py @@ -5,6 +5,7 @@ from dbt_semantic_interfaces.enum_extension import assert_values_exhausted from dbt_semantic_interfaces.type_enums.date_part import DatePart from metricflow_semantics.errors.error_classes import UnsupportedEngineFeatureError +from metricflow_semantics.sql.sql_exprs import SqlPercentileExpression, SqlPercentileFunctionType from typing_extensions import override from metricflow.protocols.sql_client import SqlEngine @@ -14,7 +15,6 @@ SqlExpressionRenderResult, ) from metricflow.sql.render.sql_plan_renderer import DefaultSqlQueryPlanRenderer -from metricflow.sql.sql_exprs import SqlPercentileExpression, SqlPercentileFunctionType class DatabricksSqlExpressionRenderer(DefaultSqlExpressionRenderer): diff --git a/metricflow/sql/render/duckdb_renderer.py b/metricflow/sql/render/duckdb_renderer.py index 3e03b7eca5..ecfca54f52 100644 --- a/metricflow/sql/render/duckdb_renderer.py +++ b/metricflow/sql/render/duckdb_renderer.py @@ -5,6 +5,13 @@ from dbt_semantic_interfaces.enum_extension import assert_values_exhausted from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity from metricflow_semantics.sql.sql_bind_parameters import SqlBindParameterSet +from metricflow_semantics.sql.sql_exprs import ( + SqlAddTimeExpression, + SqlGenerateUuidExpression, + SqlPercentileExpression, + SqlPercentileFunctionType, + SqlSubtractTimeIntervalExpression, +) from typing_extensions import override from metricflow.protocols.sql_client import SqlEngine @@ -14,13 +21,6 @@ SqlExpressionRenderResult, ) from metricflow.sql.render.sql_plan_renderer import DefaultSqlQueryPlanRenderer -from metricflow.sql.sql_exprs import ( - SqlAddTimeExpression, - SqlGenerateUuidExpression, - SqlPercentileExpression, - SqlPercentileFunctionType, - SqlSubtractTimeIntervalExpression, -) class DuckDbSqlExpressionRenderer(DefaultSqlExpressionRenderer): diff --git a/metricflow/sql/render/expr_renderer.py b/metricflow/sql/render/expr_renderer.py index a387a2da0d..10e3d748b9 100644 --- a/metricflow/sql/render/expr_renderer.py +++ b/metricflow/sql/render/expr_renderer.py @@ -12,10 +12,7 @@ from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity from metricflow_semantics.mf_logging.formatting import indent from metricflow_semantics.sql.sql_bind_parameters import SqlBindParameterSet -from typing_extensions import override - -from metricflow.sql.render.rendering_constants import SqlRenderingConstants -from metricflow.sql.sql_exprs import ( +from metricflow_semantics.sql.sql_exprs import ( SqlAddTimeExpression, SqlAggregateFunctionExpression, SqlBetweenExpression, @@ -40,6 +37,9 @@ SqlSubtractTimeIntervalExpression, SqlWindowFunctionExpression, ) +from typing_extensions import override + +from metricflow.sql.render.rendering_constants import SqlRenderingConstants from metricflow.sql.sql_plan import SqlSelectColumn if TYPE_CHECKING: diff --git a/metricflow/sql/render/postgres.py b/metricflow/sql/render/postgres.py index 8ced430207..2509dfc243 100644 --- a/metricflow/sql/render/postgres.py +++ b/metricflow/sql/render/postgres.py @@ -6,6 +6,13 @@ from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity from metricflow_semantics.errors.error_classes import UnsupportedEngineFeatureError from metricflow_semantics.sql.sql_bind_parameters import SqlBindParameterSet +from metricflow_semantics.sql.sql_exprs import ( + SqlAddTimeExpression, + SqlGenerateUuidExpression, + SqlPercentileExpression, + SqlPercentileFunctionType, + SqlSubtractTimeIntervalExpression, +) from typing_extensions import override from metricflow.protocols.sql_client import SqlEngine @@ -15,13 +22,6 @@ SqlExpressionRenderResult, ) from metricflow.sql.render.sql_plan_renderer import DefaultSqlQueryPlanRenderer -from metricflow.sql.sql_exprs import ( - SqlAddTimeExpression, - SqlGenerateUuidExpression, - SqlPercentileExpression, - SqlPercentileFunctionType, - SqlSubtractTimeIntervalExpression, -) class PostgresSqlExpressionRenderer(DefaultSqlExpressionRenderer): diff --git a/metricflow/sql/render/redshift.py b/metricflow/sql/render/redshift.py index c916cd3a1c..46c3385984 100644 --- a/metricflow/sql/render/redshift.py +++ b/metricflow/sql/render/redshift.py @@ -6,6 +6,12 @@ from dbt_semantic_interfaces.type_enums.date_part import DatePart from metricflow_semantics.errors.error_classes import UnsupportedEngineFeatureError from metricflow_semantics.sql.sql_bind_parameters import SqlBindParameterSet +from metricflow_semantics.sql.sql_exprs import ( + SqlExtractExpression, + SqlGenerateUuidExpression, + SqlPercentileExpression, + SqlPercentileFunctionType, +) from typing_extensions import override from metricflow.protocols.sql_client import SqlEngine @@ -15,12 +21,6 @@ SqlExpressionRenderResult, ) from metricflow.sql.render.sql_plan_renderer import DefaultSqlQueryPlanRenderer -from metricflow.sql.sql_exprs import ( - SqlExtractExpression, - SqlGenerateUuidExpression, - SqlPercentileExpression, - SqlPercentileFunctionType, -) class RedshiftSqlExpressionRenderer(DefaultSqlExpressionRenderer): diff --git a/metricflow/sql/render/snowflake.py b/metricflow/sql/render/snowflake.py index bc125087e8..04aabeee48 100644 --- a/metricflow/sql/render/snowflake.py +++ b/metricflow/sql/render/snowflake.py @@ -6,6 +6,11 @@ from dbt_semantic_interfaces.type_enums.date_part import DatePart from metricflow_semantics.errors.error_classes import UnsupportedEngineFeatureError from metricflow_semantics.sql.sql_bind_parameters import SqlBindParameterSet +from metricflow_semantics.sql.sql_exprs import ( + SqlGenerateUuidExpression, + SqlPercentileExpression, + SqlPercentileFunctionType, +) from typing_extensions import override from metricflow.protocols.sql_client import SqlEngine @@ -15,11 +20,6 @@ SqlExpressionRenderResult, ) from metricflow.sql.render.sql_plan_renderer import DefaultSqlQueryPlanRenderer -from metricflow.sql.sql_exprs import ( - SqlGenerateUuidExpression, - SqlPercentileExpression, - SqlPercentileFunctionType, -) class SnowflakeSqlExpressionRenderer(DefaultSqlExpressionRenderer): diff --git a/metricflow/sql/render/sql_plan_renderer.py b/metricflow/sql/render/sql_plan_renderer.py index 9e0fb11f6e..59e51cca82 100644 --- a/metricflow/sql/render/sql_plan_renderer.py +++ b/metricflow/sql/render/sql_plan_renderer.py @@ -9,6 +9,7 @@ from metricflow_semantics.mf_logging.formatting import indent from metricflow_semantics.sql.sql_bind_parameters import SqlBindParameterSet +from metricflow_semantics.sql.sql_exprs import SqlExpressionNode from typing_extensions import override from metricflow.sql.render.expr_renderer import ( @@ -17,7 +18,6 @@ SqlExpressionRenderResult, ) from metricflow.sql.render.rendering_constants import SqlRenderingConstants -from metricflow.sql.sql_exprs import SqlExpressionNode from metricflow.sql.sql_plan import ( SqlCreateTableAsNode, SqlCteNode, diff --git a/metricflow/sql/render/trino.py b/metricflow/sql/render/trino.py index e6aff3150a..bd3a581597 100644 --- a/metricflow/sql/render/trino.py +++ b/metricflow/sql/render/trino.py @@ -7,6 +7,14 @@ from dbt_semantic_interfaces.type_enums.date_part import DatePart from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity from metricflow_semantics.sql.sql_bind_parameters import SqlBindParameterSet +from metricflow_semantics.sql.sql_exprs import ( + SqlAddTimeExpression, + SqlBetweenExpression, + SqlGenerateUuidExpression, + SqlPercentileExpression, + SqlPercentileFunctionType, + SqlSubtractTimeIntervalExpression, +) from typing_extensions import override from metricflow.protocols.sql_client import SqlEngine @@ -16,14 +24,6 @@ SqlExpressionRenderResult, ) from metricflow.sql.render.sql_plan_renderer import DefaultSqlQueryPlanRenderer -from metricflow.sql.sql_exprs import ( - SqlAddTimeExpression, - SqlBetweenExpression, - SqlGenerateUuidExpression, - SqlPercentileExpression, - SqlPercentileFunctionType, - SqlSubtractTimeIntervalExpression, -) class TrinoSqlExpressionRenderer(DefaultSqlExpressionRenderer): diff --git a/metricflow/sql/sql_plan.py b/metricflow/sql/sql_plan.py index 792498cc2e..ff0b34c650 100644 --- a/metricflow/sql/sql_plan.py +++ b/metricflow/sql/sql_plan.py @@ -9,13 +9,12 @@ from metricflow_semantics.dag.id_prefix import IdPrefix, StaticIdPrefix from metricflow_semantics.dag.mf_dag import DagId, DagNode, DisplayedProperty, MetricFlowDag +from metricflow_semantics.sql.sql_exprs import SqlExpressionNode from metricflow_semantics.sql.sql_join_type import SqlJoinType from metricflow_semantics.sql.sql_table import SqlTable from metricflow_semantics.visitor import VisitorOutputT from typing_extensions import override -from metricflow.sql.sql_exprs import SqlExpressionNode - logger = logging.getLogger(__name__) diff --git a/tests_metricflow/dataflow/builder/test_node_data_set.py b/tests_metricflow/dataflow/builder/test_node_data_set.py index c62c255e55..5e369b3386 100644 --- a/tests_metricflow/dataflow/builder/test_node_data_set.py +++ b/tests_metricflow/dataflow/builder/test_node_data_set.py @@ -16,6 +16,7 @@ from metricflow_semantics.specs.dunder_column_association_resolver import DunderColumnAssociationResolver from metricflow_semantics.specs.entity_spec import LinklessEntitySpec from metricflow_semantics.specs.measure_spec import MeasureSpec +from metricflow_semantics.sql.sql_exprs import SqlColumnReference, SqlColumnReferenceExpression from metricflow_semantics.sql.sql_join_type import SqlJoinType from metricflow_semantics.sql.sql_table import SqlTable from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration @@ -26,7 +27,6 @@ from metricflow.dataflow.nodes.join_to_base import JoinDescription, JoinOnEntitiesNode from metricflow.dataflow.nodes.read_sql_source import ReadSqlSourceNode from metricflow.dataset.sql_dataset import SqlDataSet -from metricflow.sql.sql_exprs import SqlColumnReference, SqlColumnReferenceExpression from metricflow.sql.sql_plan import ( SqlSelectColumn, SqlSelectStatementNode, diff --git a/tests_metricflow/integration/test_configured_cases.py b/tests_metricflow/integration/test_configured_cases.py index c7763bbb43..027834d059 100644 --- a/tests_metricflow/integration/test_configured_cases.py +++ b/tests_metricflow/integration/test_configured_cases.py @@ -15,13 +15,7 @@ from metricflow_semantics.mf_logging.lazy_formattable import LazyFormat from metricflow_semantics.protocols.query_parameter import DimensionOrEntityQueryParameter from metricflow_semantics.specs.query_param_implementations import DimensionOrEntityParameter, TimeDimensionParameter -from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration -from metricflow_semantics.time.time_constants import ISO8601_PYTHON_FORMAT, ISO8601_PYTHON_TS_FORMAT -from metricflow_semantics.time.time_spine_source import TimeSpineSource - -from metricflow.engine.metricflow_engine import MetricFlowQueryRequest -from metricflow.protocols.sql_client import SqlClient -from metricflow.sql.sql_exprs import ( +from metricflow_semantics.sql.sql_exprs import ( SqlCastToTimestampExpression, SqlColumnReference, SqlColumnReferenceExpression, @@ -34,6 +28,12 @@ SqlStringExpression, SqlSubtractTimeIntervalExpression, ) +from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration +from metricflow_semantics.time.time_constants import ISO8601_PYTHON_FORMAT, ISO8601_PYTHON_TS_FORMAT +from metricflow_semantics.time.time_spine_source import TimeSpineSource + +from metricflow.engine.metricflow_engine import MetricFlowQueryRequest +from metricflow.protocols.sql_client import SqlClient from tests_metricflow.fixtures.manifest_fixtures import MetricFlowEngineTestFixture, SemanticManifestSetup from tests_metricflow.integration.configured_test_case import ( CONFIGURED_INTEGRATION_TESTS_REPOSITORY, @@ -280,31 +280,33 @@ def test_case( limit=case.limit, time_constraint_start=parser.parse(case.time_constraint[0]) if case.time_constraint else None, time_constraint_end=parser.parse(case.time_constraint[1]) if case.time_constraint else None, - where_constraints=[ - jinja2.Template( - case.where_filter, - undefined=jinja2.StrictUndefined, - ).render( - source_schema=mf_test_configuration.mf_source_schema, - render_time_constraint=check_query_helpers.render_time_constraint, - TimeGranularity=TimeGranularity, - DatePart=DatePart, - render_date_sub=check_query_helpers.render_date_sub, - render_date_trunc=check_query_helpers.render_date_trunc, - render_extract=check_query_helpers.render_extract, - render_percentile_expr=check_query_helpers.render_percentile_expr, - mf_time_spine_source=time_spine_source.spine_table.sql, - double_data_type_name=check_query_helpers.double_data_type_name, - render_dimension_template=check_query_helpers.render_dimension_template, - render_entity_template=check_query_helpers.render_entity_template, - render_metric_template=check_query_helpers.render_metric_template, - render_time_dimension_template=check_query_helpers.render_time_dimension_template, - generate_random_uuid=check_query_helpers.generate_random_uuid, - cast_to_ts=check_query_helpers.cast_to_ts, - ) - ] - if case.where_filter - else None, + where_constraints=( + [ + jinja2.Template( + case.where_filter, + undefined=jinja2.StrictUndefined, + ).render( + source_schema=mf_test_configuration.mf_source_schema, + render_time_constraint=check_query_helpers.render_time_constraint, + TimeGranularity=TimeGranularity, + DatePart=DatePart, + render_date_sub=check_query_helpers.render_date_sub, + render_date_trunc=check_query_helpers.render_date_trunc, + render_extract=check_query_helpers.render_extract, + render_percentile_expr=check_query_helpers.render_percentile_expr, + mf_time_spine_source=time_spine_source.spine_table.sql, + double_data_type_name=check_query_helpers.double_data_type_name, + render_dimension_template=check_query_helpers.render_dimension_template, + render_entity_template=check_query_helpers.render_entity_template, + render_metric_template=check_query_helpers.render_metric_template, + render_time_dimension_template=check_query_helpers.render_time_dimension_template, + generate_random_uuid=check_query_helpers.generate_random_uuid, + cast_to_ts=check_query_helpers.cast_to_ts, + ) + ] + if case.where_filter + else None + ), order_by_names=case.order_bys, min_max_only=case.min_max_only, ) diff --git a/tests_metricflow/mf_logging/test_dag_to_text.py b/tests_metricflow/mf_logging/test_dag_to_text.py index c7a8a3c88f..d69c2a12d4 100644 --- a/tests_metricflow/mf_logging/test_dag_to_text.py +++ b/tests_metricflow/mf_logging/test_dag_to_text.py @@ -10,11 +10,11 @@ from metricflow_semantics.dag.mf_dag import DagId from metricflow_semantics.mf_logging.formatting import indent from metricflow_semantics.mf_logging.lazy_formattable import LazyFormat -from metricflow_semantics.sql.sql_table import SqlTable - -from metricflow.sql.sql_exprs import ( +from metricflow_semantics.sql.sql_exprs import ( SqlStringExpression, ) +from metricflow_semantics.sql.sql_table import SqlTable + from metricflow.sql.sql_plan import ( SqlPlan, SqlSelectColumn, diff --git a/tests_metricflow/plan_conversion/instance_converters/test_create_select_columns_with_measures_aggregated.py b/tests_metricflow/plan_conversion/instance_converters/test_create_select_columns_with_measures_aggregated.py index 68ca855c4e..1c188dffe2 100644 --- a/tests_metricflow/plan_conversion/instance_converters/test_create_select_columns_with_measures_aggregated.py +++ b/tests_metricflow/plan_conversion/instance_converters/test_create_select_columns_with_measures_aggregated.py @@ -7,17 +7,17 @@ from metricflow_semantics.specs.dunder_column_association_resolver import DunderColumnAssociationResolver from metricflow_semantics.specs.measure_spec import MeasureSpec, MetricInputMeasureSpec from metricflow_semantics.specs.spec_set import InstanceSpecSet +from metricflow_semantics.sql.sql_exprs import ( + SqlAggregateFunctionExpression, + SqlFunction, + SqlPercentileExpression, +) from metricflow.plan_conversion.instance_converters import ( CreateSelectColumnsWithMeasuresAggregated, FilterElements, ) from metricflow.plan_conversion.select_column_gen import SelectColumnSet -from metricflow.sql.sql_exprs import ( - SqlAggregateFunctionExpression, - SqlFunction, - SqlPercentileExpression, -) from tests_metricflow.fixtures.manifest_fixtures import MetricFlowEngineTestFixture, SemanticManifestSetup __SOURCE_TABLE_ALIAS = "a" diff --git a/tests_metricflow/sql/optimizer/test_column_pruner.py b/tests_metricflow/sql/optimizer/test_column_pruner.py index 01760be80a..dc66a2c85f 100644 --- a/tests_metricflow/sql/optimizer/test_column_pruner.py +++ b/tests_metricflow/sql/optimizer/test_column_pruner.py @@ -5,13 +5,7 @@ import pytest from _pytest.fixtures import FixtureRequest from metricflow_semantics.mf_logging.lazy_formattable import LazyFormat -from metricflow_semantics.sql.sql_join_type import SqlJoinType -from metricflow_semantics.sql.sql_table import SqlTable -from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration - -from metricflow.sql.optimizer.column_pruner import SqlColumnPrunerOptimizer -from metricflow.sql.render.sql_plan_renderer import DefaultSqlQueryPlanRenderer, SqlQueryPlanRenderer -from metricflow.sql.sql_exprs import ( +from metricflow_semantics.sql.sql_exprs import ( SqlColumnReference, SqlColumnReferenceExpression, SqlComparison, @@ -19,6 +13,12 @@ SqlIsNullExpression, SqlStringExpression, ) +from metricflow_semantics.sql.sql_join_type import SqlJoinType +from metricflow_semantics.sql.sql_table import SqlTable +from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration + +from metricflow.sql.optimizer.column_pruner import SqlColumnPrunerOptimizer +from metricflow.sql.render.sql_plan_renderer import DefaultSqlQueryPlanRenderer, SqlQueryPlanRenderer from metricflow.sql.sql_plan import ( SqlJoinDescription, SqlQueryPlanNode, diff --git a/tests_metricflow/sql/optimizer/test_cte_column_pruner.py b/tests_metricflow/sql/optimizer/test_cte_column_pruner.py index 3300ef8216..e8af9117a0 100644 --- a/tests_metricflow/sql/optimizer/test_cte_column_pruner.py +++ b/tests_metricflow/sql/optimizer/test_cte_column_pruner.py @@ -4,18 +4,18 @@ import pytest from _pytest.fixtures import FixtureRequest +from metricflow_semantics.sql.sql_exprs import ( + SqlColumnReference, + SqlColumnReferenceExpression, + SqlComparison, + SqlComparisonExpression, +) from metricflow_semantics.sql.sql_join_type import SqlJoinType from metricflow_semantics.sql.sql_table import SqlTable from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration from metricflow.sql.optimizer.column_pruner import SqlColumnPrunerOptimizer from metricflow.sql.render.sql_plan_renderer import DefaultSqlQueryPlanRenderer, SqlQueryPlanRenderer -from metricflow.sql.sql_exprs import ( - SqlColumnReference, - SqlColumnReferenceExpression, - SqlComparison, - SqlComparisonExpression, -) from metricflow.sql.sql_plan import ( SqlCteNode, SqlJoinDescription, diff --git a/tests_metricflow/sql/optimizer/test_cte_rewriting_sub_query_reducer.py b/tests_metricflow/sql/optimizer/test_cte_rewriting_sub_query_reducer.py index dbdec0e4ff..33b04e7d9d 100644 --- a/tests_metricflow/sql/optimizer/test_cte_rewriting_sub_query_reducer.py +++ b/tests_metricflow/sql/optimizer/test_cte_rewriting_sub_query_reducer.py @@ -4,18 +4,18 @@ import pytest from _pytest.fixtures import FixtureRequest +from metricflow_semantics.sql.sql_exprs import ( + SqlColumnReference, + SqlColumnReferenceExpression, + SqlComparison, + SqlComparisonExpression, +) from metricflow_semantics.sql.sql_join_type import SqlJoinType from metricflow_semantics.sql.sql_table import SqlTable from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration from metricflow.sql.optimizer.rewriting_sub_query_reducer import SqlRewritingSubQueryReducer from metricflow.sql.render.sql_plan_renderer import DefaultSqlQueryPlanRenderer, SqlQueryPlanRenderer -from metricflow.sql.sql_exprs import ( - SqlColumnReference, - SqlColumnReferenceExpression, - SqlComparison, - SqlComparisonExpression, -) from metricflow.sql.sql_plan import ( SqlCteNode, SqlJoinDescription, diff --git a/tests_metricflow/sql/optimizer/test_cte_table_alias_simplifier.py b/tests_metricflow/sql/optimizer/test_cte_table_alias_simplifier.py index f2794f5ecd..aa631c27b9 100644 --- a/tests_metricflow/sql/optimizer/test_cte_table_alias_simplifier.py +++ b/tests_metricflow/sql/optimizer/test_cte_table_alias_simplifier.py @@ -2,18 +2,18 @@ import pytest from _pytest.fixtures import FixtureRequest +from metricflow_semantics.sql.sql_exprs import ( + SqlColumnReference, + SqlColumnReferenceExpression, + SqlComparison, + SqlComparisonExpression, +) from metricflow_semantics.sql.sql_join_type import SqlJoinType from metricflow_semantics.sql.sql_table import SqlTable from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration from metricflow.sql.optimizer.table_alias_simplifier import SqlTableAliasSimplifier from metricflow.sql.render.sql_plan_renderer import DefaultSqlQueryPlanRenderer -from metricflow.sql.sql_exprs import ( - SqlColumnReference, - SqlColumnReferenceExpression, - SqlComparison, - SqlComparisonExpression, -) from metricflow.sql.sql_plan import ( SqlCteNode, SqlJoinDescription, diff --git a/tests_metricflow/sql/optimizer/test_rewriting_sub_query_reducer.py b/tests_metricflow/sql/optimizer/test_rewriting_sub_query_reducer.py index 221594f367..5c40afb77a 100644 --- a/tests_metricflow/sql/optimizer/test_rewriting_sub_query_reducer.py +++ b/tests_metricflow/sql/optimizer/test_rewriting_sub_query_reducer.py @@ -2,12 +2,7 @@ import pytest from _pytest.fixtures import FixtureRequest -from metricflow_semantics.sql.sql_join_type import SqlJoinType -from metricflow_semantics.sql.sql_table import SqlTable -from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration - -from metricflow.sql.optimizer.rewriting_sub_query_reducer import SqlRewritingSubQueryReducer -from metricflow.sql.sql_exprs import ( +from metricflow_semantics.sql.sql_exprs import ( SqlAggregateFunctionExpression, SqlColumnReference, SqlColumnReferenceExpression, @@ -17,6 +12,11 @@ SqlStringExpression, SqlStringLiteralExpression, ) +from metricflow_semantics.sql.sql_join_type import SqlJoinType +from metricflow_semantics.sql.sql_table import SqlTable +from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration + +from metricflow.sql.optimizer.rewriting_sub_query_reducer import SqlRewritingSubQueryReducer from metricflow.sql.sql_plan import ( SqlJoinDescription, SqlOrderByDescription, diff --git a/tests_metricflow/sql/optimizer/test_sub_query_reducer.py b/tests_metricflow/sql/optimizer/test_sub_query_reducer.py index 30726e8ac4..991e7c86ff 100644 --- a/tests_metricflow/sql/optimizer/test_sub_query_reducer.py +++ b/tests_metricflow/sql/optimizer/test_sub_query_reducer.py @@ -2,17 +2,17 @@ import pytest from _pytest.fixtures import FixtureRequest -from metricflow_semantics.sql.sql_join_type import SqlJoinType -from metricflow_semantics.sql.sql_table import SqlTable -from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration - -from metricflow.sql.optimizer.sub_query_reducer import SqlSubQueryReducer -from metricflow.sql.sql_exprs import ( +from metricflow_semantics.sql.sql_exprs import ( SqlColumnReference, SqlColumnReferenceExpression, SqlComparison, SqlComparisonExpression, ) +from metricflow_semantics.sql.sql_join_type import SqlJoinType +from metricflow_semantics.sql.sql_table import SqlTable +from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration + +from metricflow.sql.optimizer.sub_query_reducer import SqlSubQueryReducer from metricflow.sql.sql_plan import ( SqlJoinDescription, SqlOrderByDescription, diff --git a/tests_metricflow/sql/optimizer/test_table_alias_simplifier.py b/tests_metricflow/sql/optimizer/test_table_alias_simplifier.py index 1615b3795b..7a1de37504 100644 --- a/tests_metricflow/sql/optimizer/test_table_alias_simplifier.py +++ b/tests_metricflow/sql/optimizer/test_table_alias_simplifier.py @@ -2,18 +2,18 @@ import pytest from _pytest.fixtures import FixtureRequest +from metricflow_semantics.sql.sql_exprs import ( + SqlColumnReference, + SqlColumnReferenceExpression, + SqlComparison, + SqlComparisonExpression, +) from metricflow_semantics.sql.sql_join_type import SqlJoinType from metricflow_semantics.sql.sql_table import SqlTable from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration from metricflow.sql.optimizer.table_alias_simplifier import SqlTableAliasSimplifier from metricflow.sql.render.sql_plan_renderer import DefaultSqlQueryPlanRenderer, SqlQueryPlanRenderer -from metricflow.sql.sql_exprs import ( - SqlColumnReference, - SqlColumnReferenceExpression, - SqlComparison, - SqlComparisonExpression, -) from metricflow.sql.sql_plan import ( SqlJoinDescription, SqlSelectColumn, diff --git a/tests_metricflow/sql/test_engine_specific_rendering.py b/tests_metricflow/sql/test_engine_specific_rendering.py index 987762006b..adc52cbcc4 100644 --- a/tests_metricflow/sql/test_engine_specific_rendering.py +++ b/tests_metricflow/sql/test_engine_specific_rendering.py @@ -5,11 +5,7 @@ import pytest from _pytest.fixtures import FixtureRequest from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity -from metricflow_semantics.sql.sql_table import SqlTable -from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration - -from metricflow.protocols.sql_client import SqlClient -from metricflow.sql.sql_exprs import ( +from metricflow_semantics.sql.sql_exprs import ( SqlAddTimeExpression, SqlCastToTimestampExpression, SqlColumnReference, @@ -21,6 +17,10 @@ SqlStringExpression, SqlStringLiteralExpression, ) +from metricflow_semantics.sql.sql_table import SqlTable +from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration + +from metricflow.protocols.sql_client import SqlClient from metricflow.sql.sql_plan import ( SqlJoinDescription, SqlOrderByDescription, diff --git a/tests_metricflow/sql/test_render_cte.py b/tests_metricflow/sql/test_render_cte.py index 326804327b..db32aa68de 100644 --- a/tests_metricflow/sql/test_render_cte.py +++ b/tests_metricflow/sql/test_render_cte.py @@ -3,16 +3,16 @@ import logging from _pytest.fixtures import FixtureRequest -from metricflow_semantics.sql.sql_join_type import SqlJoinType -from metricflow_semantics.sql.sql_table import SqlTable -from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration - -from metricflow.sql.sql_exprs import ( +from metricflow_semantics.sql.sql_exprs import ( SqlColumnReference, SqlColumnReferenceExpression, SqlComparison, SqlComparisonExpression, ) +from metricflow_semantics.sql.sql_join_type import SqlJoinType +from metricflow_semantics.sql.sql_table import SqlTable +from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration + from metricflow.sql.sql_plan import ( SqlCteNode, SqlJoinDescription, diff --git a/tests_metricflow/sql/test_sql_expr_render.py b/tests_metricflow/sql/test_sql_expr_render.py index 05b4103ea2..f2a578e8b2 100644 --- a/tests_metricflow/sql/test_sql_expr_render.py +++ b/tests_metricflow/sql/test_sql_expr_render.py @@ -8,10 +8,7 @@ from _pytest.fixtures import FixtureRequest from dbt_semantic_interfaces.type_enums.date_part import DatePart from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity -from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration - -from metricflow.sql.render.expr_renderer import DefaultSqlExpressionRenderer -from metricflow.sql.sql_exprs import ( +from metricflow_semantics.sql.sql_exprs import ( SqlAggregateFunctionExpression, SqlBetweenExpression, SqlCastToTimestampExpression, @@ -34,6 +31,9 @@ SqlWindowFunctionExpression, SqlWindowOrderByArgument, ) +from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration + +from metricflow.sql.render.expr_renderer import DefaultSqlExpressionRenderer from tests_metricflow.snapshot_utils import assert_str_snapshot_equal logger = logging.getLogger(__name__) diff --git a/tests_metricflow/sql/test_sql_plan_render.py b/tests_metricflow/sql/test_sql_plan_render.py index c14d67db50..7e09d83bb8 100644 --- a/tests_metricflow/sql/test_sql_plan_render.py +++ b/tests_metricflow/sql/test_sql_plan_render.py @@ -5,12 +5,7 @@ import pytest from _pytest.fixtures import FixtureRequest -from metricflow_semantics.sql.sql_join_type import SqlJoinType -from metricflow_semantics.sql.sql_table import SqlTable, SqlTableType -from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration - -from metricflow.protocols.sql_client import SqlClient -from metricflow.sql.sql_exprs import ( +from metricflow_semantics.sql.sql_exprs import ( SqlAggregateFunctionExpression, SqlColumnReference, SqlColumnReferenceExpression, @@ -19,6 +14,11 @@ SqlFunction, SqlStringExpression, ) +from metricflow_semantics.sql.sql_join_type import SqlJoinType +from metricflow_semantics.sql.sql_table import SqlTable, SqlTableType +from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration + +from metricflow.protocols.sql_client import SqlClient from metricflow.sql.sql_plan import ( SqlCreateTableAsNode, SqlJoinDescription, diff --git a/tests_metricflow/sql_clients/test_date_time_operations.py b/tests_metricflow/sql_clients/test_date_time_operations.py index 0370ade60e..b0453b68ff 100644 --- a/tests_metricflow/sql_clients/test_date_time_operations.py +++ b/tests_metricflow/sql_clients/test_date_time_operations.py @@ -23,16 +23,16 @@ import pytest from dbt_semantic_interfaces.type_enums import TimeGranularity from dbt_semantic_interfaces.type_enums.date_part import DatePart - -from metricflow.data_table.mf_table import MetricFlowDataTable -from metricflow.protocols.sql_client import SqlClient -from metricflow.sql.sql_exprs import ( +from metricflow_semantics.sql.sql_exprs import ( SqlCastToTimestampExpression, SqlDateTruncExpression, SqlExtractExpression, SqlStringLiteralExpression, ) +from metricflow.data_table.mf_table import MetricFlowDataTable +from metricflow.protocols.sql_client import SqlClient + logger = logging.getLogger(__name__) From 216bd0f50cdd24ab08fe4978f9d4bb6ec2173633 Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Wed, 18 Dec 2024 09:31:26 -0800 Subject: [PATCH 02/13] Add SQL exprs needed for custom offset window This includes a CASE expression, an integer expression, and some updates to the add time expression & the window function expression. --- .../metricflow_semantics/dag/id_prefix.py | 3 + .../metricflow_semantics/sql/sql_exprs.py | 237 +++++++++++++++++- metricflow/sql/render/big_query.py | 4 +- metricflow/sql/render/duckdb_renderer.py | 23 +- metricflow/sql/render/expr_renderer.py | 48 +++- metricflow/sql/render/postgres.py | 23 +- metricflow/sql/render/trino.py | 23 +- 7 files changed, 331 insertions(+), 30 deletions(-) diff --git a/metricflow-semantics/metricflow_semantics/dag/id_prefix.py b/metricflow-semantics/metricflow_semantics/dag/id_prefix.py index 8c2a6d1b4e..61fdcc5f7d 100644 --- a/metricflow-semantics/metricflow_semantics/dag/id_prefix.py +++ b/metricflow-semantics/metricflow_semantics/dag/id_prefix.py @@ -75,6 +75,9 @@ class StaticIdPrefix(IdPrefix, Enum, metaclass=EnumMetaClassHelper): SQL_EXPR_BETWEEN_PREFIX = "betw" SQL_EXPR_WINDOW_FUNCTION_ID_PREFIX = "wfnc" SQL_EXPR_GENERATE_UUID_PREFIX = "uuid" + SQL_EXPR_CASE_PREFIX = "case" + SQL_EXPR_ARITHMETIC_PREFIX = "arit" + SQL_EXPR_INTEGER_PREFIX = "int" SQL_PLAN_SELECT_STATEMENT_ID_PREFIX = "ss" SQL_PLAN_TABLE_FROM_CLAUSE_ID_PREFIX = "tfc" diff --git a/metricflow-semantics/metricflow_semantics/sql/sql_exprs.py b/metricflow-semantics/metricflow_semantics/sql/sql_exprs.py index ec7866f001..c7d39aed4e 100644 --- a/metricflow-semantics/metricflow_semantics/sql/sql_exprs.py +++ b/metricflow-semantics/metricflow_semantics/sql/sql_exprs.py @@ -14,12 +14,13 @@ from dbt_semantic_interfaces.type_enums.date_part import DatePart from dbt_semantic_interfaces.type_enums.period_agg import PeriodAggregation from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity +from typing_extensions import override + from metricflow_semantics.collection_helpers.merger import Mergeable from metricflow_semantics.dag.id_prefix import IdPrefix, StaticIdPrefix from metricflow_semantics.dag.mf_dag import DagNode, DisplayedProperty from metricflow_semantics.sql.sql_bind_parameters import SqlBindParameterSet from metricflow_semantics.visitor import Visitable, VisitorOutputT -from typing_extensions import override @dataclass(frozen=True, eq=False) @@ -237,6 +238,18 @@ def visit_window_function_expr(self, node: SqlWindowFunctionExpression) -> Visit def visit_generate_uuid_expr(self, node: SqlGenerateUuidExpression) -> VisitorOutputT: # noqa: D102 pass + @abstractmethod + def visit_case_expr(self, node: SqlCaseExpression) -> VisitorOutputT: # noqa: D102 + pass + + @abstractmethod + def visit_arithmetic_expr(self, node: SqlArithmeticExpression) -> VisitorOutputT: # noqa: D102 + pass + + @abstractmethod + def visit_integer_expr(self, node: SqlIntegerExpression) -> VisitorOutputT: # noqa: D102 + pass + @dataclass(frozen=True, eq=False) class SqlStringExpression(SqlExpressionNode): @@ -375,6 +388,59 @@ def matches(self, other: SqlExpressionNode) -> bool: # noqa: D102 return self.literal_value == other.literal_value +@dataclass(frozen=True, eq=False) +class SqlIntegerExpression(SqlExpressionNode): + """An integer like 1.""" + + integer_value: int + + @staticmethod + def create(integer_value: int) -> SqlIntegerExpression: # noqa: D102 + return SqlIntegerExpression(parent_nodes=(), integer_value=integer_value) + + @classmethod + def id_prefix(cls) -> IdPrefix: # noqa: D102 + return StaticIdPrefix.SQL_EXPR_INTEGER_PREFIX + + def accept(self, visitor: SqlExpressionNodeVisitor[VisitorOutputT]) -> VisitorOutputT: # noqa: D102 + return visitor.visit_integer_expr(self) + + @property + def description(self) -> str: # noqa: D102 + return f"Integer: {self.integer_value}" + + @property + def displayed_properties(self) -> Sequence[DisplayedProperty]: # noqa: D102 + return tuple(super().displayed_properties) + (DisplayedProperty("value", self.integer_value),) + + @property + def requires_parenthesis(self) -> bool: # noqa: D102 + return False + + @property + def bind_parameter_set(self) -> SqlBindParameterSet: # noqa: D102 + return SqlBindParameterSet() + + def __repr__(self) -> str: # noqa: D105 + return f"{self.__class__.__name__}(node_id={self.node_id}, integer_value={self.integer_value})" + + def rewrite( # noqa: D102 + self, + column_replacements: Optional[SqlColumnReplacements] = None, + should_render_table_alias: Optional[bool] = None, + ) -> SqlExpressionNode: + return self + + @property + def lineage(self) -> SqlExpressionTreeLineage: # noqa: D102 + return SqlExpressionTreeLineage(other_exprs=(self,)) + + def matches(self, other: SqlExpressionNode) -> bool: # noqa: D102 + if not isinstance(other, SqlIntegerExpression): + return False + return self.integer_value == other.integer_value + + @dataclass(frozen=True) class SqlColumnReference: """Used with string expressions to specify what columns are referred to in the string expression.""" @@ -950,11 +1016,18 @@ class SqlWindowFunction(Enum): FIRST_VALUE = "FIRST_VALUE" LAST_VALUE = "LAST_VALUE" AVERAGE = "AVG" + ROW_NUMBER = "ROW_NUMBER" + LEAD = "LEAD" @property def requires_ordering(self) -> bool: """Asserts whether or not ordering the window function will have an impact on the resulting value.""" - if self is SqlWindowFunction.FIRST_VALUE or self is SqlWindowFunction.LAST_VALUE: + if ( + self is SqlWindowFunction.FIRST_VALUE + or self is SqlWindowFunction.LAST_VALUE + or self is SqlWindowFunction.ROW_NUMBER + or self is SqlWindowFunction.LEAD + ): return True elif self is SqlWindowFunction.AVERAGE: return False @@ -1106,7 +1179,8 @@ def matches(self, other: SqlExpressionNode) -> bool: # noqa: D102 return ( self.sql_function == other.sql_function and self.order_by_args == other.order_by_args - and self._parents_match(other) + and self.partition_by_args == other.partition_by_args + and self.sql_function_args == other.sql_function_args ) @@ -1367,7 +1441,7 @@ def rewrite( # noqa: D102 ) -> SqlExpressionNode: return SqlAddTimeExpression.create( arg=self.arg.rewrite(column_replacements, should_render_table_alias), - count_expr=self.count_expr, + count_expr=self.count_expr.rewrite(column_replacements, should_render_table_alias), granularity=self.granularity, ) @@ -1719,3 +1793,158 @@ def lineage(self) -> SqlExpressionTreeLineage: # noqa: D102 def matches(self, other: SqlExpressionNode) -> bool: # noqa: D102 return False + + +@dataclass(frozen=True, eq=False) +class SqlCaseExpression(SqlExpressionNode): + """Renders a CASE WHEN expression.""" + + when_to_then_exprs: Dict[SqlExpressionNode, SqlExpressionNode] + else_expr: Optional[SqlExpressionNode] + + @staticmethod + def create( # noqa: D102 + when_to_then_exprs: Dict[SqlExpressionNode, SqlExpressionNode], else_expr: Optional[SqlExpressionNode] = None + ) -> SqlCaseExpression: + parent_nodes: Tuple[SqlExpressionNode, ...] = () + for when, then in when_to_then_exprs.items(): + parent_nodes += (when,) + parent_nodes += (then,) + + if else_expr: + parent_nodes += (else_expr,) + + return SqlCaseExpression(parent_nodes=parent_nodes, when_to_then_exprs=when_to_then_exprs, else_expr=else_expr) + + @classmethod + def id_prefix(cls) -> IdPrefix: # noqa: D102 + return StaticIdPrefix.SQL_EXPR_CASE_PREFIX + + def accept(self, visitor: SqlExpressionNodeVisitor[VisitorOutputT]) -> VisitorOutputT: # noqa: D102 + return visitor.visit_case_expr(self) + + @property + def description(self) -> str: # noqa: D102 + return "Case expression" + + @property + def displayed_properties(self) -> Sequence[DisplayedProperty]: # noqa: D102 + return super().displayed_properties + + @property + def requires_parenthesis(self) -> bool: # noqa: D102 + return False + + @property + def bind_parameter_set(self) -> SqlBindParameterSet: # noqa: D102 + return SqlBindParameterSet() + + def __repr__(self) -> str: # noqa: D105 + return f"{self.__class__.__name__}(node_id={self.node_id})" + + def rewrite( # noqa: D102 + self, + column_replacements: Optional[SqlColumnReplacements] = None, + should_render_table_alias: Optional[bool] = None, + ) -> SqlExpressionNode: + return SqlCaseExpression.create( + when_to_then_exprs={ + when.rewrite(column_replacements, should_render_table_alias): then.rewrite( + column_replacements, should_render_table_alias + ) + for when, then in self.when_to_then_exprs.items() + }, + else_expr=( + self.else_expr.rewrite(column_replacements, should_render_table_alias) if self.else_expr else None + ), + ) + + @property + def lineage(self) -> SqlExpressionTreeLineage: # noqa: D102 + return SqlExpressionTreeLineage.merge_iterable( + tuple(x.lineage for x in self.parent_nodes) + (SqlExpressionTreeLineage(other_exprs=(self,)),) + ) + + def matches(self, other: SqlExpressionNode) -> bool: # noqa: D102 + if not isinstance(other, SqlCaseExpression): + return False + return self.when_to_then_exprs == other.when_to_then_exprs and self.else_expr == other.else_expr + + +class SqlArithmeticOperator(Enum): + """Arithmetic operator used to do math in a SQL expression.""" + + ADD = "+" + SUBTRACT = "-" + MULTIPLY = "*" + DIVIDE = "/" + + +@dataclass(frozen=True, eq=False) +class SqlArithmeticExpression(SqlExpressionNode): + """An arithmetic expression using +, -, *, /. + + e.g. my_table.my_column + my_table.other_column + + Attributes: + left_expr: The expression on the left side of the operator + operator: The operator to use on the expressions + right_expr: The expression on the right side of the operator + """ + + left_expr: SqlExpressionNode + operator: SqlArithmeticOperator + right_expr: SqlExpressionNode + + @staticmethod + def create( # noqa: D102 + left_expr: SqlExpressionNode, operator: SqlArithmeticOperator, right_expr: SqlExpressionNode + ) -> SqlArithmeticExpression: + return SqlArithmeticExpression( + parent_nodes=(left_expr, right_expr), left_expr=left_expr, operator=operator, right_expr=right_expr + ) + + @classmethod + def id_prefix(cls) -> IdPrefix: # noqa: D102 + return StaticIdPrefix.SQL_EXPR_ARITHMETIC_PREFIX + + def accept(self, visitor: SqlExpressionNodeVisitor[VisitorOutputT]) -> VisitorOutputT: # noqa: D102 + return visitor.visit_arithmetic_expr(self) + + @property + def description(self) -> str: # noqa: D102 + return "Arithmetic Expression" + + @property + def displayed_properties(self) -> Sequence[DisplayedProperty]: # noqa: D102 + return tuple(super().displayed_properties) + ( + DisplayedProperty("left_expr", self.left_expr), + DisplayedProperty("operator", self.operator.value), + DisplayedProperty("right_expr", self.right_expr), + ) + + @property + def requires_parenthesis(self) -> bool: # noqa: D102 + return True + + def rewrite( # noqa: D102 + self, + column_replacements: Optional[SqlColumnReplacements] = None, + should_render_table_alias: Optional[bool] = None, + ) -> SqlExpressionNode: + return SqlArithmeticExpression.create( + left_expr=self.left_expr.rewrite(column_replacements, should_render_table_alias), + operator=self.operator, + right_expr=self.right_expr.rewrite(column_replacements, should_render_table_alias), + ) + + @property + def lineage(self) -> SqlExpressionTreeLineage: # noqa: D102 + return SqlExpressionTreeLineage.merge_iterable( + tuple(x.lineage for x in self.parent_nodes) + (SqlExpressionTreeLineage(other_exprs=(self,)),) + ) + + def matches(self, other: SqlExpressionNode) -> bool: # noqa: D102 + if not isinstance(other, SqlArithmeticExpression): + return False + return self.operator == other.operator and self._parents_match(other) diff --git a/metricflow/sql/render/big_query.py b/metricflow/sql/render/big_query.py index 5745ab2f8e..186f231108 100644 --- a/metricflow/sql/render/big_query.py +++ b/metricflow/sql/render/big_query.py @@ -184,8 +184,8 @@ def visit_add_time_expr(self, node: SqlAddTimeExpression) -> SqlExpressionRender count = node.count_expr.accept(self) return SqlExpressionRenderResult( - sql=f"DATE_ADD(CAST({column.sql} AS {self.timestamp_data_type}), INTERVAL {count} {node.granularity.value})", - bind_parameter_set=column.bind_parameter_set, + sql=f"DATE_ADD(CAST({column.sql} AS {self.timestamp_data_type}), INTERVAL {count.sql} {node.granularity.value})", + bind_parameter_set=column.bind_parameter_set.merge(count.bind_parameter_set), ) @override diff --git a/metricflow/sql/render/duckdb_renderer.py b/metricflow/sql/render/duckdb_renderer.py index ecfca54f52..48d0c16722 100644 --- a/metricflow/sql/render/duckdb_renderer.py +++ b/metricflow/sql/render/duckdb_renderer.py @@ -7,7 +7,10 @@ from metricflow_semantics.sql.sql_bind_parameters import SqlBindParameterSet from metricflow_semantics.sql.sql_exprs import ( SqlAddTimeExpression, + SqlArithmeticExpression, + SqlArithmeticOperator, SqlGenerateUuidExpression, + SqlIntegerExpression, SqlPercentileExpression, SqlPercentileFunctionType, SqlSubtractTimeIntervalExpression, @@ -56,17 +59,25 @@ def visit_subtract_time_interval_expr(self, node: SqlSubtractTimeIntervalExpress @override def visit_add_time_expr(self, node: SqlAddTimeExpression) -> SqlExpressionRenderResult: """Render time delta expression for DuckDB, which requires slightly different syntax from other engines.""" - arg_rendered = node.arg.accept(self) - count_rendered = node.count_expr.accept(self).sql - granularity = node.granularity + count_expr = node.count_expr if granularity is TimeGranularity.QUARTER: granularity = TimeGranularity.MONTH - count_rendered = f"({count_rendered} * 3)" + count_expr = SqlArithmeticExpression.create( + left_expr=node.count_expr, + operator=SqlArithmeticOperator.MULTIPLY, + right_expr=SqlIntegerExpression.create(3), + ) + + arg_rendered = node.arg.accept(self) + count_rendered = count_expr.accept(self) + count_sql = f"({count_rendered.sql})" if count_expr.requires_parenthesis else count_rendered.sql return SqlExpressionRenderResult( - sql=f"{arg_rendered.sql} + INTERVAL {count_rendered} {granularity.value}", - bind_parameter_set=arg_rendered.bind_parameter_set, + sql=f"{arg_rendered.sql} + INTERVAL {count_sql} {granularity.value}", + bind_parameter_set=SqlBindParameterSet.merge_iterable( + (arg_rendered.bind_parameter_set, count_rendered.bind_parameter_set) + ), ) @override diff --git a/metricflow/sql/render/expr_renderer.py b/metricflow/sql/render/expr_renderer.py index 10e3d748b9..a89dc2abba 100644 --- a/metricflow/sql/render/expr_renderer.py +++ b/metricflow/sql/render/expr_renderer.py @@ -15,7 +15,10 @@ from metricflow_semantics.sql.sql_exprs import ( SqlAddTimeExpression, SqlAggregateFunctionExpression, + SqlArithmeticExpression, + SqlArithmeticOperator, SqlBetweenExpression, + SqlCaseExpression, SqlCastToTimestampExpression, SqlColumnAliasReferenceExpression, SqlColumnReferenceExpression, @@ -26,6 +29,7 @@ SqlExtractExpression, SqlFunction, SqlGenerateUuidExpression, + SqlIntegerExpression, SqlIsNullExpression, SqlLogicalExpression, SqlNullExpression, @@ -320,17 +324,25 @@ def visit_subtract_time_interval_expr( # noqa: D102 ) def visit_add_time_expr(self, node: SqlAddTimeExpression) -> SqlExpressionRenderResult: # noqa: D102 - arg_rendered = node.arg.accept(self) - count_rendered = node.count_expr.accept(self).sql - granularity = node.granularity + count_expr = node.count_expr if granularity is TimeGranularity.QUARTER: granularity = TimeGranularity.MONTH - count_rendered = f"({count_rendered} * 3)" + count_expr = SqlArithmeticExpression.create( + left_expr=node.count_expr, + operator=SqlArithmeticOperator.MULTIPLY, + right_expr=SqlIntegerExpression.create(3), + ) + + arg_rendered = node.arg.accept(self) + count_rendered = count_expr.accept(self) + count_sql = f"({count_rendered.sql})" if count_expr.requires_parenthesis else count_rendered.sql return SqlExpressionRenderResult( - sql=f"DATEADD({granularity.value}, {count_rendered}, {arg_rendered.sql})", - bind_parameter_set=arg_rendered.bind_parameter_set, + sql=f"DATEADD({granularity.value}, {count_sql}, {arg_rendered.sql})", + bind_parameter_set=SqlBindParameterSet.merge_iterable( + (arg_rendered.bind_parameter_set, count_rendered.bind_parameter_set) + ), ) def visit_ratio_computation_expr(self, node: SqlRatioComputationExpression) -> SqlExpressionRenderResult: @@ -438,3 +450,27 @@ def visit_generate_uuid_expr(self, node: SqlGenerateUuidExpression) -> SqlExpres sql="UUID()", bind_parameter_set=SqlBindParameterSet(), ) + + def visit_case_expr(self, node: SqlCaseExpression) -> SqlExpressionRenderResult: # noqa: D102 + sql = "CASE\n" + for when, then in node.when_to_then_exprs.items(): + sql += indent( + f"WHEN {self.render_sql_expr(when).sql}\n", indent_prefix=SqlRenderingConstants.INDENT + ) + indent( + f"THEN {self.render_sql_expr(then).sql}\n", + indent_prefix=SqlRenderingConstants.INDENT * 2, + ) + if node.else_expr: + sql += indent( + f"ELSE {self.render_sql_expr(node.else_expr).sql}\n", + indent_prefix=SqlRenderingConstants.INDENT, + ) + sql += "END" + return SqlExpressionRenderResult(sql=sql, bind_parameter_set=SqlBindParameterSet()) + + def visit_arithmetic_expr(self, node: SqlArithmeticExpression) -> SqlExpressionRenderResult: # noqa: D102 + sql = f"{self.render_sql_expr(node.left_expr).sql} {node.operator.value} {self.render_sql_expr(node.right_expr).sql}" + return SqlExpressionRenderResult(sql=sql, bind_parameter_set=SqlBindParameterSet()) + + def visit_integer_expr(self, node: SqlIntegerExpression) -> SqlExpressionRenderResult: # noqa: D102 + return SqlExpressionRenderResult(sql=str(node.integer_value), bind_parameter_set=SqlBindParameterSet()) diff --git a/metricflow/sql/render/postgres.py b/metricflow/sql/render/postgres.py index 2509dfc243..f5a4a88581 100644 --- a/metricflow/sql/render/postgres.py +++ b/metricflow/sql/render/postgres.py @@ -8,7 +8,10 @@ from metricflow_semantics.sql.sql_bind_parameters import SqlBindParameterSet from metricflow_semantics.sql.sql_exprs import ( SqlAddTimeExpression, + SqlArithmeticExpression, + SqlArithmeticOperator, SqlGenerateUuidExpression, + SqlIntegerExpression, SqlPercentileExpression, SqlPercentileFunctionType, SqlSubtractTimeIntervalExpression, @@ -58,17 +61,25 @@ def visit_subtract_time_interval_expr(self, node: SqlSubtractTimeIntervalExpress @override def visit_add_time_expr(self, node: SqlAddTimeExpression) -> SqlExpressionRenderResult: """Render time delta operations for PostgreSQL, which needs custom support for quarterly granularity.""" - arg_rendered = node.arg.accept(self) - count_rendered = node.count_expr.accept(self).sql - granularity = node.granularity + count_expr = node.count_expr if granularity is TimeGranularity.QUARTER: granularity = TimeGranularity.MONTH - count_rendered = f"({count_rendered} * 3)" + SqlArithmeticExpression.create( + left_expr=node.count_expr, + operator=SqlArithmeticOperator.MULTIPLY, + right_expr=SqlIntegerExpression.create(3), + ) + + arg_rendered = node.arg.accept(self) + count_rendered = count_expr.accept(self) + count_sql = f"({count_rendered.sql})" if count_expr.requires_parenthesis else count_rendered.sql return SqlExpressionRenderResult( - sql=f"{arg_rendered.sql} + MAKE_INTERVAL({granularity.value}s => {count_rendered})", - bind_parameter_set=arg_rendered.bind_parameter_set, + sql=f"{arg_rendered.sql} + MAKE_INTERVAL({granularity.value}s => CAST ({count_sql} AS INTEGER))", + bind_parameter_set=SqlBindParameterSet.merge_iterable( + (arg_rendered.bind_parameter_set, count_rendered.bind_parameter_set) + ), ) @override diff --git a/metricflow/sql/render/trino.py b/metricflow/sql/render/trino.py index bd3a581597..f0a8ea2da4 100644 --- a/metricflow/sql/render/trino.py +++ b/metricflow/sql/render/trino.py @@ -9,8 +9,11 @@ from metricflow_semantics.sql.sql_bind_parameters import SqlBindParameterSet from metricflow_semantics.sql.sql_exprs import ( SqlAddTimeExpression, + SqlArithmeticExpression, + SqlArithmeticOperator, SqlBetweenExpression, SqlGenerateUuidExpression, + SqlIntegerExpression, SqlPercentileExpression, SqlPercentileFunctionType, SqlSubtractTimeIntervalExpression, @@ -63,17 +66,25 @@ def visit_subtract_time_interval_expr(self, node: SqlSubtractTimeIntervalExpress @override def visit_add_time_expr(self, node: SqlAddTimeExpression) -> SqlExpressionRenderResult: """Render time delta for Trino, require granularity in quotes and function name change.""" - arg_rendered = node.arg.accept(self) - count_rendered = node.count_expr.accept(self).sql - granularity = node.granularity + count_expr = node.count_expr if granularity is TimeGranularity.QUARTER: granularity = TimeGranularity.MONTH - count_rendered = f"({count_rendered} * 3)" + SqlArithmeticExpression.create( + left_expr=node.count_expr, + operator=SqlArithmeticOperator.MULTIPLY, + right_expr=SqlIntegerExpression.create(3), + ) + + arg_rendered = node.arg.accept(self) + count_rendered = count_expr.accept(self) + count_sql = f"({count_rendered.sql})" if count_expr.requires_parenthesis else count_rendered.sql return SqlExpressionRenderResult( - sql=f"DATE_ADD('{granularity.value}', {count_rendered}, {arg_rendered.sql})", - bind_parameter_set=arg_rendered.bind_parameter_set, + sql=f"DATE_ADD('{granularity.value}', {count_sql}, {arg_rendered.sql})", + bind_parameter_set=SqlBindParameterSet.merge_iterable( + (arg_rendered.bind_parameter_set, count_rendered.bind_parameter_set) + ), ) @override From 9d56d3344a26a2ee6458e43506c08ffc95ec8ea1 Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Wed, 18 Dec 2024 09:44:54 -0800 Subject: [PATCH 03/13] Update SQL engine snapshots for add time expr test Not totally relevant to this PR, but these seem to have been removed somehow. --- .../SqlPlan/BigQuery/test_add_time_expr__plan0.sql | 10 ++++++++++ .../SqlPlan/Databricks/test_add_time_expr__plan0.sql | 10 ++++++++++ .../SqlPlan/DuckDB/test_add_time_expr__plan0.sql | 10 ++++++++++ .../SqlPlan/Postgres/test_add_time_expr__plan0.sql | 10 ++++++++++ .../SqlPlan/Redshift/test_add_time_expr__plan0.sql | 10 ++++++++++ .../SqlPlan/Snowflake/test_add_time_expr__plan0.sql | 10 ++++++++++ .../SqlPlan/Trino/test_add_time_expr__plan0.sql | 10 ++++++++++ 7 files changed, 70 insertions(+) create mode 100644 tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/BigQuery/test_add_time_expr__plan0.sql create mode 100644 tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Databricks/test_add_time_expr__plan0.sql create mode 100644 tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/DuckDB/test_add_time_expr__plan0.sql create mode 100644 tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Postgres/test_add_time_expr__plan0.sql create mode 100644 tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Redshift/test_add_time_expr__plan0.sql create mode 100644 tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Snowflake/test_add_time_expr__plan0.sql create mode 100644 tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Trino/test_add_time_expr__plan0.sql diff --git a/tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/BigQuery/test_add_time_expr__plan0.sql b/tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/BigQuery/test_add_time_expr__plan0.sql new file mode 100644 index 0000000000..3d2190d3eb --- /dev/null +++ b/tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/BigQuery/test_add_time_expr__plan0.sql @@ -0,0 +1,10 @@ +test_name: test_add_time_expr +test_filename: test_engine_specific_rendering.py +docstring: + Tests rendering of the SqlAddTimeExpr in a query. +sql_engine: BigQuery +--- +-- Test Add Time Expression +SELECT + DATE_ADD(CAST('2020-01-01' AS DATETIME), INTERVAL 1 quarter) AS add_time +FROM foo.bar a diff --git a/tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Databricks/test_add_time_expr__plan0.sql b/tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Databricks/test_add_time_expr__plan0.sql new file mode 100644 index 0000000000..3f6f5e12d4 --- /dev/null +++ b/tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Databricks/test_add_time_expr__plan0.sql @@ -0,0 +1,10 @@ +test_name: test_add_time_expr +test_filename: test_engine_specific_rendering.py +docstring: + Tests rendering of the SqlAddTimeExpr in a query. +sql_engine: Databricks +--- +-- Test Add Time Expression +SELECT + DATEADD(month, (1 * 3), '2020-01-01') AS add_time +FROM foo.bar a diff --git a/tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/DuckDB/test_add_time_expr__plan0.sql b/tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/DuckDB/test_add_time_expr__plan0.sql new file mode 100644 index 0000000000..984e2096f6 --- /dev/null +++ b/tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/DuckDB/test_add_time_expr__plan0.sql @@ -0,0 +1,10 @@ +test_name: test_add_time_expr +test_filename: test_engine_specific_rendering.py +docstring: + Tests rendering of the SqlAddTimeExpr in a query. +sql_engine: DuckDB +--- +-- Test Add Time Expression +SELECT + '2020-01-01' + INTERVAL (1 * 3) month AS add_time +FROM foo.bar a diff --git a/tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Postgres/test_add_time_expr__plan0.sql b/tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Postgres/test_add_time_expr__plan0.sql new file mode 100644 index 0000000000..c24fe44c52 --- /dev/null +++ b/tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Postgres/test_add_time_expr__plan0.sql @@ -0,0 +1,10 @@ +test_name: test_add_time_expr +test_filename: test_engine_specific_rendering.py +docstring: + Tests rendering of the SqlAddTimeExpr in a query. +sql_engine: Postgres +--- +-- Test Add Time Expression +SELECT + '2020-01-01' + MAKE_INTERVAL(months => CAST ((1) AS INTEGER)) AS add_time +FROM foo.bar a diff --git a/tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Redshift/test_add_time_expr__plan0.sql b/tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Redshift/test_add_time_expr__plan0.sql new file mode 100644 index 0000000000..bac4dc733c --- /dev/null +++ b/tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Redshift/test_add_time_expr__plan0.sql @@ -0,0 +1,10 @@ +test_name: test_add_time_expr +test_filename: test_engine_specific_rendering.py +docstring: + Tests rendering of the SqlAddTimeExpr in a query. +sql_engine: Redshift +--- +-- Test Add Time Expression +SELECT + DATEADD(month, (1 * 3), '2020-01-01') AS add_time +FROM foo.bar a diff --git a/tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Snowflake/test_add_time_expr__plan0.sql b/tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Snowflake/test_add_time_expr__plan0.sql new file mode 100644 index 0000000000..b83e173387 --- /dev/null +++ b/tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Snowflake/test_add_time_expr__plan0.sql @@ -0,0 +1,10 @@ +test_name: test_add_time_expr +test_filename: test_engine_specific_rendering.py +docstring: + Tests rendering of the SqlAddTimeExpr in a query. +sql_engine: Snowflake +--- +-- Test Add Time Expression +SELECT + DATEADD(month, (1 * 3), '2020-01-01') AS add_time +FROM foo.bar a diff --git a/tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Trino/test_add_time_expr__plan0.sql b/tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Trino/test_add_time_expr__plan0.sql new file mode 100644 index 0000000000..61e35c5e04 --- /dev/null +++ b/tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Trino/test_add_time_expr__plan0.sql @@ -0,0 +1,10 @@ +test_name: test_add_time_expr +test_filename: test_engine_specific_rendering.py +docstring: + Tests rendering of the SqlAddTimeExpr in a query. +sql_engine: Trino +--- +-- Test Add Time Expression +SELECT + DATE_ADD('month', (1), '2020-01-01') AS add_time +FROM foo.bar a From e1932281e7ccd805e65562a994719cc84b89e64c Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Wed, 18 Dec 2024 15:12:42 -0800 Subject: [PATCH 04/13] Handle window function frame cause appropriately --- .../metricflow_semantics/sql/sql_exprs.py | 14 ++++++++++++++ metricflow/sql/render/expr_renderer.py | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/metricflow-semantics/metricflow_semantics/sql/sql_exprs.py b/metricflow-semantics/metricflow_semantics/sql/sql_exprs.py index c7d39aed4e..2b8d8e6673 100644 --- a/metricflow-semantics/metricflow_semantics/sql/sql_exprs.py +++ b/metricflow-semantics/metricflow_semantics/sql/sql_exprs.py @@ -1034,6 +1034,20 @@ def requires_ordering(self) -> bool: else: assert_values_exhausted(self) + @property + def allows_frame_clause(self) -> bool: + """Whether the function allows a frame clause, e.g., 'ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING'.""" + if ( + self is SqlWindowFunction.FIRST_VALUE + or self is SqlWindowFunction.LAST_VALUE + or self is SqlWindowFunction.AVERAGE + ): + return True + if self is SqlWindowFunction.ROW_NUMBER or self is SqlWindowFunction.LEAD: + return False + else: + assert_values_exhausted(self) + @classmethod def get_window_function_for_period_agg(cls, period_agg: PeriodAggregation) -> SqlWindowFunction: """Get the window function to use for given period agg option.""" diff --git a/metricflow/sql/render/expr_renderer.py b/metricflow/sql/render/expr_renderer.py index a89dc2abba..158c074ed0 100644 --- a/metricflow/sql/render/expr_renderer.py +++ b/metricflow/sql/render/expr_renderer.py @@ -428,7 +428,7 @@ def visit_window_function_expr(self, node: SqlWindowFunctionExpression) -> SqlEx ) ) - if len(order_by_args_rendered) > 0: + if len(order_by_args_rendered) > 0 and node.sql_function.allows_frame_clause: window_string_lines.append("ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING") window_string = "\n".join(window_string_lines) From 16e91bd021a59c88550d5ef60489a06f5aca8bf5 Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Wed, 18 Dec 2024 09:59:17 -0800 Subject: [PATCH 05/13] Cleanup --- metricflow-semantics/metricflow_semantics/instances.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/metricflow-semantics/metricflow_semantics/instances.py b/metricflow-semantics/metricflow_semantics/instances.py index 6cd85fcbd8..45d9560e5c 100644 --- a/metricflow-semantics/metricflow_semantics/instances.py +++ b/metricflow-semantics/metricflow_semantics/instances.py @@ -164,11 +164,7 @@ def with_entity_prefix( ) -> TimeDimensionInstance: """Returns a new instance with the entity prefix added to the entity links.""" transformed_spec = self.spec.with_entity_prefix(entity_prefix) - return TimeDimensionInstance( - associated_columns=(column_association_resolver.resolve_spec(transformed_spec),), - defined_from=self.defined_from, - spec=transformed_spec, - ) + return self.with_new_spec(transformed_spec, column_association_resolver) def with_new_defined_from(self, defined_from: Sequence[SemanticModelElementReference]) -> TimeDimensionInstance: """Returns a new instance with the defined_from field replaced.""" From 05304dab21721692f36a2ff1aaa74323b62dcba8 Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Wed, 18 Dec 2024 09:59:41 -0800 Subject: [PATCH 06/13] Remove unneeded param from DunderColumnAssociationResolver --- .../dunder_column_association_resolver.py | 8 ++------ .../fixtures/manifest_fixtures.py | 2 +- metricflow/engine/metricflow_engine.py | 18 +++++++++--------- .../data_warehouse_model_validator.py | 12 ++++-------- scripts/ci_tests/metricflow_package_test.py | 6 ++---- .../dataflow/builder/test_node_data_set.py | 4 ++-- .../dataflow/builder/test_node_evaluator.py | 4 ++-- tests_metricflow/examples/test_node_sql.py | 6 ++---- tests_metricflow/fixtures/manifest_fixtures.py | 6 ++---- tests_metricflow/integration/conftest.py | 4 +--- .../integration/test_rendered_query.py | 4 +--- ..._select_columns_with_measures_aggregated.py | 16 ++++++++-------- .../test_dataflow_to_execution.py | 2 +- 13 files changed, 37 insertions(+), 55 deletions(-) diff --git a/metricflow-semantics/metricflow_semantics/specs/dunder_column_association_resolver.py b/metricflow-semantics/metricflow_semantics/specs/dunder_column_association_resolver.py index 3473618c74..8f2fead24b 100644 --- a/metricflow-semantics/metricflow_semantics/specs/dunder_column_association_resolver.py +++ b/metricflow-semantics/metricflow_semantics/specs/dunder_column_association_resolver.py @@ -1,6 +1,5 @@ from __future__ import annotations -from metricflow_semantics.model.semantic_manifest_lookup import SemanticManifestLookup from metricflow_semantics.naming.linkable_spec_name import DUNDER from metricflow_semantics.specs.column_assoc import ( ColumnAssociation, @@ -28,8 +27,8 @@ class DunderColumnAssociationResolver(ColumnAssociationResolver): listing__country """ - def __init__(self, semantic_manifest_lookup: SemanticManifestLookup) -> None: # noqa: D107 - self._visitor_helper = DunderColumnAssociationResolverVisitor(semantic_manifest_lookup) + def __init__(self) -> None: # noqa: D107 + self._visitor_helper = DunderColumnAssociationResolverVisitor() def resolve_spec(self, spec: InstanceSpec) -> ColumnAssociation: # noqa: D102 return spec.accept(self._visitor_helper) @@ -38,9 +37,6 @@ def resolve_spec(self, spec: InstanceSpec) -> ColumnAssociation: # noqa: D102 class DunderColumnAssociationResolverVisitor(InstanceSpecVisitor[ColumnAssociation]): """Visitor helper class for DefaultColumnAssociationResolver2.""" - def __init__(self, semantic_manifest_lookup: SemanticManifestLookup) -> None: # noqa: D107 - self._semantic_manifest_lookup = semantic_manifest_lookup - def visit_metric_spec(self, metric_spec: MetricSpec) -> ColumnAssociation: # noqa: D102 return ColumnAssociation(metric_spec.element_name if metric_spec.alias is None else metric_spec.alias) diff --git a/metricflow-semantics/tests_metricflow_semantics/fixtures/manifest_fixtures.py b/metricflow-semantics/tests_metricflow_semantics/fixtures/manifest_fixtures.py index 00964fc8da..401a2680c9 100644 --- a/metricflow-semantics/tests_metricflow_semantics/fixtures/manifest_fixtures.py +++ b/metricflow-semantics/tests_metricflow_semantics/fixtures/manifest_fixtures.py @@ -137,7 +137,7 @@ def cyclic_join_semantic_manifest_lookup( # noqa: D103 def column_association_resolver( # noqa: D103 simple_semantic_manifest_lookup: SemanticManifestLookup, ) -> ColumnAssociationResolver: - return DunderColumnAssociationResolver(simple_semantic_manifest_lookup) + return DunderColumnAssociationResolver() @pytest.fixture(scope="session") diff --git a/metricflow/engine/metricflow_engine.py b/metricflow/engine/metricflow_engine.py index b4343c527d..9d490a4cdb 100644 --- a/metricflow/engine/metricflow_engine.py +++ b/metricflow/engine/metricflow_engine.py @@ -364,9 +364,7 @@ def __init__( SequentialIdGenerator.reset(MetricFlowEngine._ID_ENUMERATION_START_VALUE_FOR_INITIALIZER) self._semantic_manifest_lookup = semantic_manifest_lookup self._sql_client = sql_client - self._column_association_resolver = column_association_resolver or ( - DunderColumnAssociationResolver(semantic_manifest_lookup) - ) + self._column_association_resolver = column_association_resolver or (DunderColumnAssociationResolver()) self._time_source = time_source self._time_spine_sources = TimeSpineSource.build_standard_time_spine_sources( semantic_manifest_lookup.semantic_manifest @@ -463,12 +461,14 @@ def _create_execution_plan(self, mf_query_request: MetricFlowQueryRequest) -> Me raise InvalidQueryException("Group by items can't be specified with a saved query.") query_spec = self._query_parser.parse_and_validate_saved_query( saved_query_parameter=SavedQueryParameter(mf_query_request.saved_query_name), - where_filters=[ - PydanticWhereFilter(where_sql_template=where_constraint) - for where_constraint in mf_query_request.where_constraints - ] - if mf_query_request.where_constraints is not None - else None, + where_filters=( + [ + PydanticWhereFilter(where_sql_template=where_constraint) + for where_constraint in mf_query_request.where_constraints + ] + if mf_query_request.where_constraints is not None + else None + ), limit=mf_query_request.limit, time_constraint_start=mf_query_request.time_constraint_start, time_constraint_end=mf_query_request.time_constraint_end, diff --git a/metricflow/validation/data_warehouse_model_validator.py b/metricflow/validation/data_warehouse_model_validator.py index 95efadcb3e..b24afc187d 100644 --- a/metricflow/validation/data_warehouse_model_validator.py +++ b/metricflow/validation/data_warehouse_model_validator.py @@ -63,20 +63,16 @@ class QueryRenderingTools: def __init__(self, manifest: SemanticManifest) -> None: # noqa: D107 self.semantic_manifest_lookup = SemanticManifestLookup(semantic_manifest=manifest) self.source_node_builder = SourceNodeBuilder( - column_association_resolver=DunderColumnAssociationResolver(self.semantic_manifest_lookup), + column_association_resolver=DunderColumnAssociationResolver(), semantic_manifest_lookup=self.semantic_manifest_lookup, ) - self.converter = SemanticModelToDataSetConverter( - column_association_resolver=DunderColumnAssociationResolver( - semantic_manifest_lookup=self.semantic_manifest_lookup - ) - ) + self.converter = SemanticModelToDataSetConverter(column_association_resolver=DunderColumnAssociationResolver()) self.plan_converter = DataflowToSqlQueryPlanConverter( - column_association_resolver=DunderColumnAssociationResolver(self.semantic_manifest_lookup), + column_association_resolver=DunderColumnAssociationResolver(), semantic_manifest_lookup=self.semantic_manifest_lookup, ) self.node_resolver = DataflowPlanNodeOutputDataSetResolver( - column_association_resolver=DunderColumnAssociationResolver(self.semantic_manifest_lookup), + column_association_resolver=DunderColumnAssociationResolver(), semantic_manifest_lookup=self.semantic_manifest_lookup, ) diff --git a/scripts/ci_tests/metricflow_package_test.py b/scripts/ci_tests/metricflow_package_test.py index 81e055c24d..7a25559108 100644 --- a/scripts/ci_tests/metricflow_package_test.py +++ b/scripts/ci_tests/metricflow_package_test.py @@ -64,9 +64,7 @@ def _create_data_sets( semantic_models: Sequence[SemanticModel] = semantic_manifest_lookup.semantic_manifest.semantic_models semantic_models = sorted(semantic_models, key=lambda x: x.name) - converter = SemanticModelToDataSetConverter( - column_association_resolver=DunderColumnAssociationResolver(semantic_manifest_lookup) - ) + converter = SemanticModelToDataSetConverter(column_association_resolver=DunderColumnAssociationResolver()) for semantic_model in semantic_models: data_sets[semantic_model.name] = converter.create_sql_source_data_set(semantic_model) @@ -138,7 +136,7 @@ def log_dataflow_plan() -> None: # noqa: D103 semantic_manifest = _semantic_manifest() semantic_manifest_lookup = SemanticManifestLookup(semantic_manifest) data_set_mapping = _create_data_sets(semantic_manifest_lookup) - column_association_resolver = DunderColumnAssociationResolver(semantic_manifest_lookup) + column_association_resolver = DunderColumnAssociationResolver() source_node_builder = SourceNodeBuilder(column_association_resolver, semantic_manifest_lookup) source_node_set = source_node_builder.create_from_data_sets(list(data_set_mapping.values())) diff --git a/tests_metricflow/dataflow/builder/test_node_data_set.py b/tests_metricflow/dataflow/builder/test_node_data_set.py index 5e369b3386..5f7238cbd3 100644 --- a/tests_metricflow/dataflow/builder/test_node_data_set.py +++ b/tests_metricflow/dataflow/builder/test_node_data_set.py @@ -43,7 +43,7 @@ def test_no_parent_node_data_set( ) -> None: """Tests getting the data set from a single node.""" resolver: DataflowPlanNodeOutputDataSetResolver = DataflowPlanNodeOutputDataSetResolver( - column_association_resolver=DunderColumnAssociationResolver(simple_semantic_manifest_lookup), + column_association_resolver=DunderColumnAssociationResolver(), semantic_manifest_lookup=simple_semantic_manifest_lookup, ) @@ -96,7 +96,7 @@ def test_joined_node_data_set( ) -> None: """Tests getting the data set from a dataflow plan with a join.""" resolver: DataflowPlanNodeOutputDataSetResolver = DataflowPlanNodeOutputDataSetResolver( - column_association_resolver=DunderColumnAssociationResolver(simple_semantic_manifest_lookup), + column_association_resolver=DunderColumnAssociationResolver(), semantic_manifest_lookup=simple_semantic_manifest_lookup, ) diff --git a/tests_metricflow/dataflow/builder/test_node_evaluator.py b/tests_metricflow/dataflow/builder/test_node_evaluator.py index f4785806e4..d559973615 100644 --- a/tests_metricflow/dataflow/builder/test_node_evaluator.py +++ b/tests_metricflow/dataflow/builder/test_node_evaluator.py @@ -60,7 +60,7 @@ def make_multihop_node_evaluator( ) -> NodeEvaluatorForLinkableInstances: """Return a node evaluator using the nodes in multihop_semantic_model_name_to_nodes.""" node_data_set_resolver: DataflowPlanNodeOutputDataSetResolver = DataflowPlanNodeOutputDataSetResolver( - column_association_resolver=DunderColumnAssociationResolver(semantic_manifest_lookup_with_multihop_links), + column_association_resolver=DunderColumnAssociationResolver(), semantic_manifest_lookup=semantic_manifest_lookup_with_multihop_links, ) @@ -510,7 +510,7 @@ def test_node_evaluator_with_scd_target( ) -> None: """Tests the case where the joined node is an SCD with a validity window filter.""" node_data_set_resolver: DataflowPlanNodeOutputDataSetResolver = DataflowPlanNodeOutputDataSetResolver( - column_association_resolver=DunderColumnAssociationResolver(scd_semantic_manifest_lookup), + column_association_resolver=DunderColumnAssociationResolver(), semantic_manifest_lookup=scd_semantic_manifest_lookup, ) diff --git a/tests_metricflow/examples/test_node_sql.py b/tests_metricflow/examples/test_node_sql.py index d0a0f281cb..3e43f885d6 100644 --- a/tests_metricflow/examples/test_node_sql.py +++ b/tests_metricflow/examples/test_node_sql.py @@ -35,13 +35,11 @@ def test_view_sql_generated_at_a_node( SemanticModelReference(semantic_model_name="bookings_source") ) assert bookings_semantic_model - column_association_resolver = DunderColumnAssociationResolver( - semantic_manifest_lookup=simple_semantic_manifest_lookup, - ) + column_association_resolver = DunderColumnAssociationResolver() to_data_set_converter = SemanticModelToDataSetConverter(column_association_resolver) to_sql_plan_converter = DataflowToSqlQueryPlanConverter( - column_association_resolver=DunderColumnAssociationResolver(simple_semantic_manifest_lookup), + column_association_resolver=DunderColumnAssociationResolver(), semantic_manifest_lookup=simple_semantic_manifest_lookup, ) sql_renderer: SqlQueryPlanRenderer = sql_client.sql_query_plan_renderer diff --git a/tests_metricflow/fixtures/manifest_fixtures.py b/tests_metricflow/fixtures/manifest_fixtures.py index d5f2026b1e..8c00673c13 100644 --- a/tests_metricflow/fixtures/manifest_fixtures.py +++ b/tests_metricflow/fixtures/manifest_fixtures.py @@ -169,7 +169,7 @@ def from_parameters( # noqa: D102 semantic_manifest_lookup = SemanticManifestLookup(semantic_manifest) data_set_mapping = MetricFlowEngineTestFixture._create_data_sets(semantic_manifest_lookup) read_node_mapping = MetricFlowEngineTestFixture._data_set_to_read_nodes(data_set_mapping) - column_association_resolver = DunderColumnAssociationResolver(semantic_manifest_lookup) + column_association_resolver = DunderColumnAssociationResolver() source_node_builder = SourceNodeBuilder(column_association_resolver, semantic_manifest_lookup) source_node_set = source_node_builder.create_from_data_sets(list(data_set_mapping.values())) node_output_resolver = DataflowPlanNodeOutputDataSetResolver( @@ -247,9 +247,7 @@ def _create_data_sets( semantic_models: Sequence[SemanticModel] = semantic_manifest_lookup.semantic_manifest.semantic_models semantic_models = sorted(semantic_models, key=lambda x: x.name) - converter = SemanticModelToDataSetConverter( - column_association_resolver=DunderColumnAssociationResolver(semantic_manifest_lookup) - ) + converter = SemanticModelToDataSetConverter(column_association_resolver=DunderColumnAssociationResolver()) for semantic_model in semantic_models: data_sets[semantic_model.name] = converter.create_sql_source_data_set(semantic_model) diff --git a/tests_metricflow/integration/conftest.py b/tests_metricflow/integration/conftest.py index 5c0da3bdb1..b546dbac51 100644 --- a/tests_metricflow/integration/conftest.py +++ b/tests_metricflow/integration/conftest.py @@ -38,9 +38,7 @@ def it_helpers( # noqa: D103 mf_engine=MetricFlowEngine( semantic_manifest_lookup=simple_semantic_manifest_lookup, sql_client=sql_client, - column_association_resolver=DunderColumnAssociationResolver( - semantic_manifest_lookup=simple_semantic_manifest_lookup - ), + column_association_resolver=DunderColumnAssociationResolver(), time_source=ConfigurableTimeSource(as_datetime("2020-01-01")), ), mf_system_schema=mf_test_configuration.mf_system_schema, diff --git a/tests_metricflow/integration/test_rendered_query.py b/tests_metricflow/integration/test_rendered_query.py index 7bc004a0d5..f940448477 100644 --- a/tests_metricflow/integration/test_rendered_query.py +++ b/tests_metricflow/integration/test_rendered_query.py @@ -46,9 +46,7 @@ def test_id_enumeration( # noqa: D103 mf_engine = MetricFlowEngine( semantic_manifest_lookup=simple_semantic_manifest_lookup, sql_client=sql_client, - column_association_resolver=DunderColumnAssociationResolver( - semantic_manifest_lookup=simple_semantic_manifest_lookup - ), + column_association_resolver=DunderColumnAssociationResolver(), time_source=ConfigurableTimeSource(as_datetime("2020-01-01")), consistent_id_enumeration=True, ) diff --git a/tests_metricflow/plan_conversion/instance_converters/test_create_select_columns_with_measures_aggregated.py b/tests_metricflow/plan_conversion/instance_converters/test_create_select_columns_with_measures_aggregated.py index 1c188dffe2..28d177829a 100644 --- a/tests_metricflow/plan_conversion/instance_converters/test_create_select_columns_with_measures_aggregated.py +++ b/tests_metricflow/plan_conversion/instance_converters/test_create_select_columns_with_measures_aggregated.py @@ -49,7 +49,7 @@ def test_sum_aggregation( select_column_set: SelectColumnSet = CreateSelectColumnsWithMeasuresAggregated( __SOURCE_TABLE_ALIAS, - DunderColumnAssociationResolver(simple_semantic_manifest_lookup), + DunderColumnAssociationResolver(), simple_semantic_manifest_lookup.semantic_model_lookup, (MetricInputMeasureSpec(measure_spec=MeasureSpec(element_name="booking_value")),), ).transform(instance_set=instance_set) @@ -71,7 +71,7 @@ def test_sum_boolean_aggregation( select_column_set: SelectColumnSet = CreateSelectColumnsWithMeasuresAggregated( __SOURCE_TABLE_ALIAS, - DunderColumnAssociationResolver(simple_semantic_manifest_lookup), + DunderColumnAssociationResolver(), simple_semantic_manifest_lookup.semantic_model_lookup, (MetricInputMeasureSpec(measure_spec=MeasureSpec(element_name="instant_bookings")),), ).transform(instance_set=instance_set) @@ -94,7 +94,7 @@ def test_avg_aggregation( select_column_set: SelectColumnSet = CreateSelectColumnsWithMeasuresAggregated( __SOURCE_TABLE_ALIAS, - DunderColumnAssociationResolver(simple_semantic_manifest_lookup), + DunderColumnAssociationResolver(), simple_semantic_manifest_lookup.semantic_model_lookup, (MetricInputMeasureSpec(measure_spec=MeasureSpec(element_name="average_booking_value")),), ).transform(instance_set=instance_set) @@ -116,7 +116,7 @@ def test_count_distinct_aggregation( select_column_set: SelectColumnSet = CreateSelectColumnsWithMeasuresAggregated( __SOURCE_TABLE_ALIAS, - DunderColumnAssociationResolver(simple_semantic_manifest_lookup), + DunderColumnAssociationResolver(), simple_semantic_manifest_lookup.semantic_model_lookup, (MetricInputMeasureSpec(measure_spec=MeasureSpec(element_name="bookers")),), ).transform(instance_set=instance_set) @@ -138,7 +138,7 @@ def test_max_aggregation( select_column_set: SelectColumnSet = CreateSelectColumnsWithMeasuresAggregated( __SOURCE_TABLE_ALIAS, - DunderColumnAssociationResolver(simple_semantic_manifest_lookup), + DunderColumnAssociationResolver(), simple_semantic_manifest_lookup.semantic_model_lookup, (MetricInputMeasureSpec(measure_spec=MeasureSpec(element_name="largest_listing")),), ).transform(instance_set=instance_set) @@ -160,7 +160,7 @@ def test_min_aggregation( select_column_set: SelectColumnSet = CreateSelectColumnsWithMeasuresAggregated( __SOURCE_TABLE_ALIAS, - DunderColumnAssociationResolver(simple_semantic_manifest_lookup), + DunderColumnAssociationResolver(), simple_semantic_manifest_lookup.semantic_model_lookup, (MetricInputMeasureSpec(measure_spec=MeasureSpec(element_name="smallest_listing")),), ).transform(instance_set=instance_set) @@ -182,7 +182,7 @@ def test_aliased_sum( select_column_set: SelectColumnSet = CreateSelectColumnsWithMeasuresAggregated( __SOURCE_TABLE_ALIAS, - DunderColumnAssociationResolver(simple_semantic_manifest_lookup), + DunderColumnAssociationResolver(), simple_semantic_manifest_lookup.semantic_model_lookup, (MetricInputMeasureSpec(measure_spec=MeasureSpec(element_name="booking_value"), alias="bvalue"),), ).transform(instance_set=instance_set) @@ -205,7 +205,7 @@ def test_percentile_aggregation( select_column_set: SelectColumnSet = CreateSelectColumnsWithMeasuresAggregated( __SOURCE_TABLE_ALIAS, - DunderColumnAssociationResolver(simple_semantic_manifest_lookup), + DunderColumnAssociationResolver(), simple_semantic_manifest_lookup.semantic_model_lookup, (MetricInputMeasureSpec(measure_spec=MeasureSpec(element_name="booking_value_p99")),), ).transform(instance_set=instance_set) diff --git a/tests_metricflow/plan_conversion/test_dataflow_to_execution.py b/tests_metricflow/plan_conversion/test_dataflow_to_execution.py index 08db7d27e0..cd5425e7d4 100644 --- a/tests_metricflow/plan_conversion/test_dataflow_to_execution.py +++ b/tests_metricflow/plan_conversion/test_dataflow_to_execution.py @@ -26,7 +26,7 @@ def make_execution_plan_converter( # noqa: D103 ) -> DataflowToExecutionPlanConverter: return DataflowToExecutionPlanConverter( sql_plan_converter=DataflowToSqlQueryPlanConverter( - column_association_resolver=DunderColumnAssociationResolver(semantic_manifest_lookup), + column_association_resolver=DunderColumnAssociationResolver(), semantic_manifest_lookup=semantic_manifest_lookup, ), sql_plan_renderer=DefaultSqlQueryPlanRenderer(), From a9a6f123132b91d298688ab19368d4a06c39d1b8 Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Wed, 18 Dec 2024 10:02:12 -0800 Subject: [PATCH 07/13] Use dunder column resolver instead of qualified name to display specs in FilterElementsNode This will more accurately match the column name since it includes more information about the spec --- metricflow/dataflow/nodes/filter_elements.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/metricflow/dataflow/nodes/filter_elements.py b/metricflow/dataflow/nodes/filter_elements.py index abcd5b5bb4..93b160ee47 100644 --- a/metricflow/dataflow/nodes/filter_elements.py +++ b/metricflow/dataflow/nodes/filter_elements.py @@ -6,6 +6,7 @@ from metricflow_semantics.dag.id_prefix import IdPrefix, StaticIdPrefix from metricflow_semantics.dag.mf_dag import DisplayedProperty from metricflow_semantics.mf_logging.pretty_print import mf_pformat +from metricflow_semantics.specs.dunder_column_association_resolver import DunderColumnAssociationResolver from metricflow_semantics.specs.spec_set import InstanceSpecSet from metricflow_semantics.visitor import VisitorOutputT @@ -57,7 +58,8 @@ def description(self) -> str: # noqa: D102 if self.replace_description: return self.replace_description - return f"Pass Only Elements: {mf_pformat([x.qualified_name for x in self.include_specs.all_specs])}" + column_resolver = DunderColumnAssociationResolver() + return f"Pass Only Elements: {mf_pformat([column_resolver.resolve_spec(spec).column_name for spec in self.include_specs.all_specs])}" @property def displayed_properties(self) -> Sequence[DisplayedProperty]: # noqa: D102 From ca93230676d144da4561d5539dc3aefd40aa1464 Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Wed, 18 Dec 2024 10:04:24 -0800 Subject: [PATCH 08/13] Add window_function attribute to TimeDimensionSpec This will allow us to track which specs have had a window function applied between DataflowPlan nodes --- .../dunder_column_association_resolver.py | 5 +++++ .../specs/time_dimension_spec.py | 22 +++++++++++++++++++ .../collection_helpers/test_pretty_print.py | 1 + 3 files changed, 28 insertions(+) diff --git a/metricflow-semantics/metricflow_semantics/specs/dunder_column_association_resolver.py b/metricflow-semantics/metricflow_semantics/specs/dunder_column_association_resolver.py index 8f2fead24b..ad852f3838 100644 --- a/metricflow-semantics/metricflow_semantics/specs/dunder_column_association_resolver.py +++ b/metricflow-semantics/metricflow_semantics/specs/dunder_column_association_resolver.py @@ -54,6 +54,11 @@ def visit_time_dimension_spec(self, time_dimension_spec: TimeDimensionSpec) -> C if time_dimension_spec.aggregation_state else "" ) + + ( + f"{DUNDER}{time_dimension_spec.window_function.value.lower()}" + if time_dimension_spec.window_function + else "" + ) ) def visit_entity_spec(self, entity_spec: EntitySpec) -> ColumnAssociation: # noqa: D102 diff --git a/metricflow-semantics/metricflow_semantics/specs/time_dimension_spec.py b/metricflow-semantics/metricflow_semantics/specs/time_dimension_spec.py index fd47c80a69..dec834adce 100644 --- a/metricflow-semantics/metricflow_semantics/specs/time_dimension_spec.py +++ b/metricflow-semantics/metricflow_semantics/specs/time_dimension_spec.py @@ -15,6 +15,7 @@ from metricflow_semantics.naming.linkable_spec_name import StructuredLinkableSpecName from metricflow_semantics.specs.dimension_spec import DimensionSpec from metricflow_semantics.specs.instance_spec import InstanceSpecVisitor +from metricflow_semantics.sql.sql_exprs import SqlWindowFunction from metricflow_semantics.time.granularity import ExpandedTimeGranularity from metricflow_semantics.visitor import VisitorOutputT @@ -91,6 +92,8 @@ class TimeDimensionSpec(DimensionSpec): # noqa: D101 # Used for semi-additive joins. Some more thought is needed, but this may be useful in InstanceSpec. aggregation_state: Optional[AggregationState] = None + window_function: Optional[SqlWindowFunction] = None + @property def without_first_entity_link(self) -> TimeDimensionSpec: # noqa: D102 assert len(self.entity_links) > 0, f"Spec does not have any entity links: {self}" @@ -99,6 +102,8 @@ def without_first_entity_link(self) -> TimeDimensionSpec: # noqa: D102 entity_links=self.entity_links[1:], time_granularity=self.time_granularity, date_part=self.date_part, + aggregation_state=self.aggregation_state, + window_function=self.window_function, ) @property @@ -108,6 +113,8 @@ def without_entity_links(self) -> TimeDimensionSpec: # noqa: D102 time_granularity=self.time_granularity, date_part=self.date_part, entity_links=(), + aggregation_state=self.aggregation_state, + window_function=self.window_function, ) @property @@ -153,6 +160,7 @@ def with_grain(self, time_granularity: ExpandedTimeGranularity) -> TimeDimension time_granularity=time_granularity, date_part=self.date_part, aggregation_state=self.aggregation_state, + window_function=self.window_function, ) def with_base_grain(self) -> TimeDimensionSpec: # noqa: D102 @@ -162,6 +170,7 @@ def with_base_grain(self) -> TimeDimensionSpec: # noqa: D102 time_granularity=ExpandedTimeGranularity.from_time_granularity(self.time_granularity.base_granularity), date_part=self.date_part, aggregation_state=self.aggregation_state, + window_function=self.window_function, ) def with_grain_and_date_part( # noqa: D102 @@ -173,6 +182,7 @@ def with_grain_and_date_part( # noqa: D102 time_granularity=time_granularity, date_part=date_part, aggregation_state=self.aggregation_state, + window_function=self.window_function, ) def with_aggregation_state(self, aggregation_state: AggregationState) -> TimeDimensionSpec: # noqa: D102 @@ -182,6 +192,17 @@ def with_aggregation_state(self, aggregation_state: AggregationState) -> TimeDim time_granularity=self.time_granularity, date_part=self.date_part, aggregation_state=aggregation_state, + window_function=self.window_function, + ) + + def with_window_function(self, window_function: SqlWindowFunction) -> TimeDimensionSpec: # noqa: D102 + return TimeDimensionSpec( + element_name=self.element_name, + entity_links=self.entity_links, + time_granularity=self.time_granularity, + date_part=self.date_part, + aggregation_state=self.aggregation_state, + window_function=window_function, ) def comparison_key(self, exclude_fields: Sequence[TimeDimensionSpecField] = ()) -> TimeDimensionSpecComparisonKey: @@ -243,6 +264,7 @@ def with_entity_prefix(self, entity_prefix: EntityReference) -> TimeDimensionSpe time_granularity=self.time_granularity, date_part=self.date_part, aggregation_state=self.aggregation_state, + window_function=self.window_function, ) @staticmethod diff --git a/metricflow-semantics/tests_metricflow_semantics/collection_helpers/test_pretty_print.py b/metricflow-semantics/tests_metricflow_semantics/collection_helpers/test_pretty_print.py index c09422caa1..86a4c446c9 100644 --- a/metricflow-semantics/tests_metricflow_semantics/collection_helpers/test_pretty_print.py +++ b/metricflow-semantics/tests_metricflow_semantics/collection_helpers/test_pretty_print.py @@ -47,6 +47,7 @@ def test_classes() -> None: # noqa: D103 time_granularity=ExpandedTimeGranularity(name='day', base_granularity=DAY), date_part=None, aggregation_state=None, + window_function=None, ) """ ).rstrip() From 3b94632d0a05ea4c99dc08bde26880d11cc2233f Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Wed, 18 Dec 2024 10:26:10 -0800 Subject: [PATCH 09/13] Fix bug in JoinToTimeSpine dataflow plans We weren't tracking the parent nodes properly, which resulted in improper optimization and nodes missing when displaying the plan. This should not impact the output data, but will hopefully improve query efficiency now that more CTEs are enabled. --- .../dataflow/builder/dataflow_plan_builder.py | 6 +++--- metricflow/dataflow/nodes/join_to_time_spine.py | 13 +++++-------- metricflow/plan_conversion/dataflow_to_sql.py | 2 +- .../optimizer/test_predicate_pushdown_optimizer.py | 3 +++ 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/metricflow/dataflow/builder/dataflow_plan_builder.py b/metricflow/dataflow/builder/dataflow_plan_builder.py index 348ba5b4e8..d433dd11ed 100644 --- a/metricflow/dataflow/builder/dataflow_plan_builder.py +++ b/metricflow/dataflow/builder/dataflow_plan_builder.py @@ -660,7 +660,7 @@ def _build_derived_metric_output_node( # TODO: move this to a helper method time_spine_node = self._build_time_spine_node(queried_agg_time_dimension_specs) output_node = JoinToTimeSpineNode.create( - parent_node=output_node, + metric_source_node=output_node, time_spine_node=time_spine_node, requested_agg_time_dimension_specs=queried_agg_time_dimension_specs, join_on_time_dimension_spec=self._sort_by_base_granularity(queried_agg_time_dimension_specs)[0], @@ -1651,7 +1651,7 @@ def _build_aggregated_measure_from_measure_source_node( required_time_spine_specs = (join_on_time_dimension_spec,) + base_queried_agg_time_dimension_specs time_spine_node = self._build_time_spine_node(required_time_spine_specs) unaggregated_measure_node = JoinToTimeSpineNode.create( - parent_node=unaggregated_measure_node, + metric_source_node=unaggregated_measure_node, time_spine_node=time_spine_node, requested_agg_time_dimension_specs=base_queried_agg_time_dimension_specs, join_on_time_dimension_spec=join_on_time_dimension_spec, @@ -1725,7 +1725,7 @@ def _build_aggregated_measure_from_measure_source_node( where_filter_specs=agg_time_only_filters, ) output_node: DataflowPlanNode = JoinToTimeSpineNode.create( - parent_node=aggregate_measures_node, + metric_source_node=aggregate_measures_node, time_spine_node=time_spine_node, requested_agg_time_dimension_specs=queried_agg_time_dimension_specs, join_on_time_dimension_spec=self._sort_by_base_granularity(queried_agg_time_dimension_specs)[0], diff --git a/metricflow/dataflow/nodes/join_to_time_spine.py b/metricflow/dataflow/nodes/join_to_time_spine.py index b33a3ff6d1..27557bf36c 100644 --- a/metricflow/dataflow/nodes/join_to_time_spine.py +++ b/metricflow/dataflow/nodes/join_to_time_spine.py @@ -29,6 +29,7 @@ class JoinToTimeSpineNode(DataflowPlanNode, ABC): """ time_spine_node: DataflowPlanNode + metric_source_node: DataflowPlanNode requested_agg_time_dimension_specs: Sequence[TimeDimensionSpec] join_on_time_dimension_spec: TimeDimensionSpec join_type: SqlJoinType @@ -37,7 +38,6 @@ class JoinToTimeSpineNode(DataflowPlanNode, ABC): def __post_init__(self) -> None: # noqa: D105 super().__post_init__() - assert len(self.parent_nodes) == 1 assert not ( self.offset_window and self.offset_to_grain @@ -48,7 +48,7 @@ def __post_init__(self) -> None: # noqa: D105 @staticmethod def create( # noqa: D102 - parent_node: DataflowPlanNode, + metric_source_node: DataflowPlanNode, time_spine_node: DataflowPlanNode, requested_agg_time_dimension_specs: Sequence[TimeDimensionSpec], join_on_time_dimension_spec: TimeDimensionSpec, @@ -57,7 +57,8 @@ def create( # noqa: D102 offset_to_grain: Optional[TimeGranularity] = None, ) -> JoinToTimeSpineNode: return JoinToTimeSpineNode( - parent_nodes=(parent_node,), + parent_nodes=(metric_source_node, time_spine_node), + metric_source_node=metric_source_node, time_spine_node=time_spine_node, requested_agg_time_dimension_specs=tuple(requested_agg_time_dimension_specs), join_on_time_dimension_spec=join_on_time_dimension_spec, @@ -90,10 +91,6 @@ def displayed_properties(self) -> Sequence[DisplayedProperty]: # noqa: D102 props += (DisplayedProperty("offset_to_grain", self.offset_to_grain),) return props - @property - def parent_node(self) -> DataflowPlanNode: # noqa: D102 - return self.parent_nodes[0] - def functionally_identical(self, other_node: DataflowPlanNode) -> bool: # noqa: D102 return ( isinstance(other_node, self.__class__) @@ -107,7 +104,7 @@ def functionally_identical(self, other_node: DataflowPlanNode) -> bool: # noqa: def with_new_parents(self, new_parent_nodes: Sequence[DataflowPlanNode]) -> JoinToTimeSpineNode: # noqa: D102 assert len(new_parent_nodes) == 1 return JoinToTimeSpineNode.create( - parent_node=new_parent_nodes[0], + metric_source_node=self.metric_source_node, time_spine_node=self.time_spine_node, requested_agg_time_dimension_specs=self.requested_agg_time_dimension_specs, offset_window=self.offset_window, diff --git a/metricflow/plan_conversion/dataflow_to_sql.py b/metricflow/plan_conversion/dataflow_to_sql.py index d6c52dfbb0..cd6b92a2b0 100644 --- a/metricflow/plan_conversion/dataflow_to_sql.py +++ b/metricflow/plan_conversion/dataflow_to_sql.py @@ -1433,7 +1433,7 @@ def _choose_instance_for_time_spine_join( return agg_time_dimension_instances[0] def visit_join_to_time_spine_node(self, node: JoinToTimeSpineNode) -> SqlDataSet: # noqa: D102 - parent_data_set = node.parent_node.accept(self) + parent_data_set = node.metric_source_node.accept(self) parent_alias = self._next_unique_table_alias() time_spine_data_set = node.time_spine_node.accept(self) time_spine_alias = self._next_unique_table_alias() diff --git a/tests_metricflow/dataflow/optimizer/test_predicate_pushdown_optimizer.py b/tests_metricflow/dataflow/optimizer/test_predicate_pushdown_optimizer.py index e9aa84fb0a..e10329f4d8 100644 --- a/tests_metricflow/dataflow/optimizer/test_predicate_pushdown_optimizer.py +++ b/tests_metricflow/dataflow/optimizer/test_predicate_pushdown_optimizer.py @@ -325,6 +325,7 @@ def test_aggregate_output_join_metric_predicate_pushdown( ) +@pytest.mark.skip("Predicate pushdown is not implemented for some of the nodes in this plan") def test_offset_metric_predicate_pushdown( request: FixtureRequest, mf_test_configuration: MetricFlowTestConfiguration, @@ -354,6 +355,7 @@ def test_offset_metric_predicate_pushdown( ) +@pytest.mark.skip("Predicate pushdown is not implemented for some of the nodes in this plan") def test_fill_nulls_time_spine_metric_predicate_pushdown( request: FixtureRequest, mf_test_configuration: MetricFlowTestConfiguration, @@ -382,6 +384,7 @@ def test_fill_nulls_time_spine_metric_predicate_pushdown( ) +@pytest.mark.skip("Predicate pushdown is not implemented for some of the nodes in this plan") def test_fill_nulls_time_spine_metric_with_post_agg_join_predicate_pushdown( request: FixtureRequest, mf_test_configuration: MetricFlowTestConfiguration, From 5d66c54d5e5d7525ed45f48e09cca5650c8eb5d6 Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Wed, 18 Dec 2024 10:27:01 -0800 Subject: [PATCH 10/13] Update basic snapshots --- ...and_fill_nulls_with_0__plan0_optimized.sql | 19 ++- ..._derived_metric_offset_to_grain__dfp_0.xml | 43 ++++++ ...st_derived_metric_offset_window__dfp_0.xml | 43 ++++++ ..._metric_offset_with_granularity__dfp_0.xml | 59 ++++++++ ...erived_offset_cumulative_metric__dfp_0.xml | 43 ++++++ ...in_to_time_spine_derived_metric__dfp_0.xml | 126 ++++++++++++++++++ ...join_to_time_spine_with_filters__dfp_0.xml | 85 ++++++++++++ ..._to_time_spine_with_metric_time__dfp_0.xml | 35 +++++ ...erived_metric_with_outer_offset__dfp_0.xml | 85 ++++++++++++ ...ry_have_different_granularities__dfp_0.xml | 62 +++++++++ ...ry_have_different_granularities__dfp_0.xml | 66 +++++++++ ...w_and_offset_to_grain__plan0_optimized.sql | 23 ++-- ...grain_and_granularity__plan0_optimized.sql | 26 ++-- ...nstraint_not_selected__plan0_optimized.sql | 23 ++-- .../test_nested_offsets__plan0_optimized.sql | 23 ++-- ..._with_time_constraint__plan0_optimized.sql | 25 ++-- ...with_where_constraint__plan0_optimized.sql | 23 ++-- ..._for_one_input_metric__plan0_optimized.sql | 21 ++- ...ic_predicate_pushdown__plan0_optimized.sql | 25 ++-- 19 files changed, 783 insertions(+), 72 deletions(-) diff --git a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlPlan/DuckDB/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlPlan/DuckDB/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql index 1bab2d34dc..679bf3b37b 100644 --- a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlPlan/DuckDB/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlPlan/DuckDB/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql @@ -15,6 +15,13 @@ WITH sma_28019_cte AS ( FROM ***************************.fct_visits visits_source_src_28000 ) +, rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT metric_time__day AS metric_time__day , CAST(buys AS DOUBLE) / CAST(NULLIF(visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days_fill_nulls_with_0 @@ -27,9 +34,9 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_26.visits AS visits - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte LEFT OUTER JOIN ( -- Read From CTE For node_id=sma_28019 -- Pass Only Elements: ['visits', 'metric_time__day'] @@ -42,14 +49,14 @@ FROM ( metric_time__day ) subq_26 ON - time_spine_src_28006.ds = subq_26.metric_time__day + rss_28018_cte.ds__day = subq_26.metric_time__day ) subq_30 FULL OUTER JOIN ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_39.buys AS buys - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte LEFT OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'metric_time__day'] @@ -113,7 +120,7 @@ FROM ( metric_time__day ) subq_39 ON - time_spine_src_28006.ds = subq_39.metric_time__day + rss_28018_cte.ds__day = subq_39.metric_time__day ) subq_43 ON subq_30.metric_time__day = subq_43.metric_time__day diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_to_grain__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_to_grain__dfp_0.xml index 895447530c..2aa21a5915 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_to_grain__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_to_grain__dfp_0.xml @@ -95,6 +95,49 @@ docstring: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_window__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_window__dfp_0.xml index 7c4a6e7d13..3205a56667 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_window__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_window__dfp_0.xml @@ -61,6 +61,49 @@ docstring: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_with_granularity__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_with_granularity__dfp_0.xml index 89a252d0c3..1f2f626d45 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_with_granularity__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_with_granularity__dfp_0.xml @@ -59,6 +59,65 @@ test_filename: test_dataflow_plan_builder.py + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_offset_cumulative_metric__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_offset_cumulative_metric__dfp_0.xml index 6e835d608e..2e15cc47f5 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_offset_cumulative_metric__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_offset_cumulative_metric__dfp_0.xml @@ -72,6 +72,49 @@ test_filename: test_dataflow_plan_builder.py + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_derived_metric__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_derived_metric__dfp_0.xml index c28929cd56..673f4b0e43 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_derived_metric__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_derived_metric__dfp_0.xml @@ -62,6 +62,44 @@ test_filename: test_dataflow_plan_builder.py + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -130,9 +168,97 @@ test_filename: test_dataflow_plan_builder.py + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_with_filters__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_with_filters__dfp_0.xml index eafb91229f..bdf347c5ec 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_with_filters__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_with_filters__dfp_0.xml @@ -150,6 +150,91 @@ docstring: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_with_metric_time__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_with_metric_time__dfp_0.xml index c4855938b4..a96969a0f2 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_with_metric_time__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_with_metric_time__dfp_0.xml @@ -51,6 +51,41 @@ test_filename: test_dataflow_plan_builder.py + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_nested_derived_metric_with_outer_offset__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_nested_derived_metric_with_outer_offset__dfp_0.xml index 0fe9a4187b..a940f96ca4 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_nested_derived_metric_with_outer_offset__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_nested_derived_metric_with_outer_offset__dfp_0.xml @@ -84,11 +84,96 @@ test_filename: test_dataflow_plan_builder.py + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_offset_to_grain_metric_filter_and_query_have_different_granularities__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_offset_to_grain_metric_filter_and_query_have_different_granularities__dfp_0.xml index 24643e555e..22b037b1ee 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_offset_to_grain_metric_filter_and_query_have_different_granularities__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_offset_to_grain_metric_filter_and_query_have_different_granularities__dfp_0.xml @@ -187,6 +187,68 @@ docstring: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_offset_window_metric_filter_and_query_have_different_granularities__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_offset_window_metric_filter_and_query_have_different_granularities__dfp_0.xml index 9888e180e5..fe934c12c6 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_offset_window_metric_filter_and_query_have_different_granularities__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_offset_window_metric_filter_and_query_have_different_granularities__dfp_0.xml @@ -192,6 +192,72 @@ docstring: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql index 55af5dcf29..d1ff51240e 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql @@ -12,6 +12,13 @@ WITH sma_28009_cte AS ( FROM ***************************.fct_bookings bookings_source_src_28000 ) +, rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT metric_time__day AS metric_time__day , month_start_bookings - bookings_1_month_ago AS bookings_month_start_compared_to_1_month_prior @@ -27,15 +34,15 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(sma_28009_cte.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - DATE_TRUNC('month', time_spine_src_28006.ds) = sma_28009_cte.metric_time__day + DATE_TRUNC('month', rss_28018_cte.ds__day) = sma_28009_cte.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset @@ -43,15 +50,15 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(sma_28009_cte.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - time_spine_src_28006.ds - INTERVAL 1 month = sma_28009_cte.metric_time__day + rss_28018_cte.ds__day - INTERVAL 1 month = sma_28009_cte.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day ) subq_35 ON subq_27.metric_time__day = subq_35.metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql index 1bc7c8040f..5e12f42132 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql @@ -12,6 +12,14 @@ WITH sma_28009_cte AS ( FROM ***************************.fct_bookings bookings_source_src_28000 ) +, rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + , DATE_TRUNC('year', ds) AS ds__year + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT metric_time__year AS metric_time__year , month_start_bookings - bookings_1_month_ago AS bookings_month_start_compared_to_1_month_prior @@ -27,16 +35,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('year', time_spine_src_28006.ds) AS metric_time__year + rss_28018_cte.ds__year AS metric_time__year , SUM(sma_28009_cte.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - DATE_TRUNC('month', time_spine_src_28006.ds) = sma_28009_cte.metric_time__day - WHERE DATE_TRUNC('year', time_spine_src_28006.ds) = time_spine_src_28006.ds + DATE_TRUNC('month', rss_28018_cte.ds__day) = sma_28009_cte.metric_time__day + WHERE rss_28018_cte.ds__year = rss_28018_cte.ds__day GROUP BY - DATE_TRUNC('year', time_spine_src_28006.ds) + rss_28018_cte.ds__year ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset @@ -44,15 +52,15 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('year', time_spine_src_28006.ds) AS metric_time__year + rss_28018_cte.ds__year AS metric_time__year , SUM(sma_28009_cte.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - time_spine_src_28006.ds - INTERVAL 1 month = sma_28009_cte.metric_time__day + rss_28018_cte.ds__day - INTERVAL 1 month = sma_28009_cte.metric_time__day GROUP BY - DATE_TRUNC('year', time_spine_src_28006.ds) + rss_28018_cte.ds__year ) subq_35 ON subq_27.metric_time__year = subq_35.metric_time__year diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql index 42b7243264..c513d92b95 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql @@ -3,8 +3,15 @@ test_filename: test_derived_metric_rendering.py sql_engine: DuckDB --- -- Compute Metrics via Expressions +WITH rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT - metric_time__day + metric_time__day AS metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Constrain Output with WHERE @@ -15,10 +22,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_25.booking__is_instant AS booking__is_instant , subq_25.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -31,10 +38,10 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_17.booking__is_instant AS booking__is_instant , SUM(subq_17.bookings) AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -45,14 +52,14 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_17 ON - time_spine_src_28006.ds - INTERVAL 5 day = subq_17.metric_time__day + rss_28018_cte.ds__day - INTERVAL 5 day = subq_17.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day , subq_17.booking__is_instant ) subq_24 ) subq_25 ON - time_spine_src_28006.ds - INTERVAL 2 day = subq_25.metric_time__day + rss_28018_cte.ds__day - INTERVAL 2 day = subq_25.metric_time__day ) subq_29 WHERE booking__is_instant ) subq_31 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_offsets__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_offsets__plan0_optimized.sql index fe15c86bd4..807a5bbaa0 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_offsets__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_offsets__plan0_optimized.sql @@ -3,15 +3,22 @@ test_filename: test_derived_metric_rendering.py sql_engine: DuckDB --- -- Compute Metrics via Expressions +WITH rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT - metric_time__day + metric_time__day AS metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_23.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -23,9 +30,9 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(subq_15.bookings) AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -35,11 +42,11 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_15 ON - time_spine_src_28006.ds - INTERVAL 5 day = subq_15.metric_time__day + rss_28018_cte.ds__day - INTERVAL 5 day = subq_15.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day ) subq_22 ) subq_23 ON - time_spine_src_28006.ds - INTERVAL 2 day = subq_23.metric_time__day + rss_28018_cte.ds__day - INTERVAL 2 day = subq_23.metric_time__day ) subq_27 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_offsets_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_offsets_with_time_constraint__plan0_optimized.sql index 6a16e0902d..2a56455358 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_offsets_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_offsets_with_time_constraint__plan0_optimized.sql @@ -3,16 +3,23 @@ test_filename: test_derived_metric_rendering.py sql_engine: DuckDB --- -- Compute Metrics via Expressions +WITH rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT - metric_time__day + metric_time__day AS metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Join to Time Spine Dataset -- Constrain Time Range to [2020-01-12T00:00:00, 2020-01-13T00:00:00] SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_24.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -24,9 +31,9 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(subq_16.bookings) AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -36,12 +43,12 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_16 ON - time_spine_src_28006.ds - INTERVAL 5 day = subq_16.metric_time__day + rss_28018_cte.ds__day - INTERVAL 5 day = subq_16.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day ) subq_23 ) subq_24 ON - time_spine_src_28006.ds - INTERVAL 2 day = subq_24.metric_time__day - WHERE time_spine_src_28006.ds BETWEEN '2020-01-12' AND '2020-01-13' + rss_28018_cte.ds__day - INTERVAL 2 day = subq_24.metric_time__day + WHERE rss_28018_cte.ds__day BETWEEN '2020-01-12' AND '2020-01-13' ) subq_29 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_offsets_with_where_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_offsets_with_where_constraint__plan0_optimized.sql index c25d4f0b95..59b3664d7d 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_offsets_with_where_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_offsets_with_where_constraint__plan0_optimized.sql @@ -3,8 +3,15 @@ test_filename: test_derived_metric_rendering.py sql_engine: DuckDB --- -- Compute Metrics via Expressions +WITH rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT - metric_time__day + metric_time__day AS metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Constrain Output with WHERE @@ -14,9 +21,9 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_24.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -28,9 +35,9 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(subq_16.bookings) AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -40,13 +47,13 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_16 ON - time_spine_src_28006.ds - INTERVAL 5 day = subq_16.metric_time__day + rss_28018_cte.ds__day - INTERVAL 5 day = subq_16.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day ) subq_23 ) subq_24 ON - time_spine_src_28006.ds - INTERVAL 2 day = subq_24.metric_time__day + rss_28018_cte.ds__day - INTERVAL 2 day = subq_24.metric_time__day ) subq_28 WHERE metric_time__day = '2020-01-12' or metric_time__day = '2020-01-13' ) subq_29 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql index 303e4e7bae..04ccd15223 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql @@ -12,6 +12,13 @@ WITH sma_28009_cte AS ( FROM ***************************.fct_bookings bookings_source_src_28000 ) +, rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT metric_time__day AS metric_time__day , bookings_fill_nulls_with_0 - bookings_2_weeks_ago AS bookings_growth_2_weeks_fill_nulls_with_0_for_non_offset @@ -29,9 +36,9 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_22.bookings AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte LEFT OUTER JOIN ( -- Read From CTE For node_id=sma_28009 -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -44,7 +51,7 @@ FROM ( metric_time__day ) subq_22 ON - time_spine_src_28006.ds = subq_22.metric_time__day + rss_28018_cte.ds__day = subq_22.metric_time__day ) subq_26 ) subq_27 FULL OUTER JOIN ( @@ -53,15 +60,15 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(sma_28009_cte.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - time_spine_src_28006.ds - INTERVAL 14 day = sma_28009_cte.metric_time__day + rss_28018_cte.ds__day - INTERVAL 14 day = sma_28009_cte.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day ) subq_35 ON subq_27.metric_time__day = subq_35.metric_time__day diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/DuckDB/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/DuckDB/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql index 6e7efd837d..4c3453d4bd 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/DuckDB/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/DuckDB/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql @@ -27,6 +27,13 @@ WITH sma_28009_cte AS ( FROM ***************************.dim_listings_latest listings_latest_src_28000 ) +, rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT metric_time__day AS metric_time__day , listing__country_latest AS listing__country_latest @@ -47,10 +54,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_41.listing__country_latest AS listing__country_latest , subq_41.bookings AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -78,7 +85,7 @@ FROM ( , listing__country_latest ) subq_41 ON - time_spine_src_28006.ds = subq_41.metric_time__day + rss_28018_cte.ds__day = subq_41.metric_time__day ) subq_45 ) subq_46 FULL OUTER JOIN ( @@ -90,10 +97,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_57.listing__country_latest AS listing__country_latest , subq_57.bookings AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -112,15 +119,15 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , sma_28009_cte.listing AS listing , sma_28009_cte.booking__is_instant AS booking__is_instant , sma_28009_cte.bookings AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - time_spine_src_28006.ds - INTERVAL 14 day = sma_28009_cte.metric_time__day + rss_28018_cte.ds__day - INTERVAL 14 day = sma_28009_cte.metric_time__day ) subq_51 LEFT OUTER JOIN sma_28014_cte sma_28014_cte @@ -133,7 +140,7 @@ FROM ( , listing__country_latest ) subq_57 ON - time_spine_src_28006.ds = subq_57.metric_time__day + rss_28018_cte.ds__day = subq_57.metric_time__day ) subq_61 ) subq_62 ON From eeb0105c5142b6feba04c0873137464fe48bc00f Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Wed, 18 Dec 2024 10:27:15 -0800 Subject: [PATCH 11/13] Update snapshots for other SQL engines --- ...and_fill_nulls_with_0__plan0_optimized.sql | 19 +++++++++----- ...and_fill_nulls_with_0__plan0_optimized.sql | 19 +++++++++----- ...and_fill_nulls_with_0__plan0_optimized.sql | 19 +++++++++----- ...and_fill_nulls_with_0__plan0_optimized.sql | 19 +++++++++----- ...and_fill_nulls_with_0__plan0_optimized.sql | 19 +++++++++----- ...and_fill_nulls_with_0__plan0_optimized.sql | 19 +++++++++----- ...w_and_offset_to_grain__plan0_optimized.sql | 19 +++++++++----- ...grain_and_granularity__plan0_optimized.sql | 22 +++++++++++----- ...nstraint_not_selected__plan0_optimized.sql | 21 ++++++++++----- .../test_nested_offsets__plan0_optimized.sql | 21 ++++++++++----- ..._with_time_constraint__plan0_optimized.sql | 23 ++++++++++------ ...with_where_constraint__plan0_optimized.sql | 21 ++++++++++----- ...w_and_offset_to_grain__plan0_optimized.sql | 23 ++++++++++------ ...grain_and_granularity__plan0_optimized.sql | 26 ++++++++++++------- ...nstraint_not_selected__plan0_optimized.sql | 23 ++++++++++------ .../test_nested_offsets__plan0_optimized.sql | 23 ++++++++++------ ..._with_time_constraint__plan0_optimized.sql | 25 +++++++++++------- ...with_where_constraint__plan0_optimized.sql | 23 ++++++++++------ ...w_and_offset_to_grain__plan0_optimized.sql | 23 ++++++++++------ ...grain_and_granularity__plan0_optimized.sql | 26 ++++++++++++------- ...nstraint_not_selected__plan0_optimized.sql | 23 ++++++++++------ .../test_nested_offsets__plan0_optimized.sql | 23 ++++++++++------ ..._with_time_constraint__plan0_optimized.sql | 25 +++++++++++------- ...with_where_constraint__plan0_optimized.sql | 23 ++++++++++------ ...w_and_offset_to_grain__plan0_optimized.sql | 23 ++++++++++------ ...grain_and_granularity__plan0_optimized.sql | 26 ++++++++++++------- ...nstraint_not_selected__plan0_optimized.sql | 23 ++++++++++------ .../test_nested_offsets__plan0_optimized.sql | 23 ++++++++++------ ..._with_time_constraint__plan0_optimized.sql | 25 +++++++++++------- ...with_where_constraint__plan0_optimized.sql | 23 ++++++++++------ ...w_and_offset_to_grain__plan0_optimized.sql | 23 ++++++++++------ ...grain_and_granularity__plan0_optimized.sql | 26 ++++++++++++------- ...nstraint_not_selected__plan0_optimized.sql | 23 ++++++++++------ .../test_nested_offsets__plan0_optimized.sql | 23 ++++++++++------ ..._with_time_constraint__plan0_optimized.sql | 25 +++++++++++------- ...with_where_constraint__plan0_optimized.sql | 23 ++++++++++------ ...w_and_offset_to_grain__plan0_optimized.sql | 23 ++++++++++------ ...grain_and_granularity__plan0_optimized.sql | 26 ++++++++++++------- ...nstraint_not_selected__plan0_optimized.sql | 23 ++++++++++------ .../test_nested_offsets__plan0_optimized.sql | 23 ++++++++++------ ..._with_time_constraint__plan0_optimized.sql | 25 +++++++++++------- ...with_where_constraint__plan0_optimized.sql | 23 ++++++++++------ ..._for_one_input_metric__plan0_optimized.sql | 19 +++++++++----- ..._for_one_input_metric__plan0_optimized.sql | 21 ++++++++++----- ..._for_one_input_metric__plan0_optimized.sql | 21 ++++++++++----- ..._for_one_input_metric__plan0_optimized.sql | 21 ++++++++++----- ..._for_one_input_metric__plan0_optimized.sql | 21 ++++++++++----- ..._for_one_input_metric__plan0_optimized.sql | 21 ++++++++++----- ...ic_predicate_pushdown__plan0_optimized.sql | 25 +++++++++++------- ...ic_predicate_pushdown__plan0_optimized.sql | 25 +++++++++++------- ...ic_predicate_pushdown__plan0_optimized.sql | 25 +++++++++++------- ...ic_predicate_pushdown__plan0_optimized.sql | 25 +++++++++++------- ...ic_predicate_pushdown__plan0_optimized.sql | 25 +++++++++++------- ...ic_predicate_pushdown__plan0_optimized.sql | 25 +++++++++++------- 54 files changed, 807 insertions(+), 423 deletions(-) diff --git a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlPlan/BigQuery/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlPlan/BigQuery/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql index 04e97e0af2..d337455f10 100644 --- a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlPlan/BigQuery/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlPlan/BigQuery/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql @@ -15,6 +15,13 @@ WITH sma_28019_cte AS ( FROM ***************************.fct_visits visits_source_src_28000 ) +, rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT metric_time__day AS metric_time__day , CAST(buys AS FLOAT64) / CAST(NULLIF(visits, 0) AS FLOAT64) AS visit_buy_conversion_rate_7days_fill_nulls_with_0 @@ -27,9 +34,9 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_26.visits AS visits - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte LEFT OUTER JOIN ( -- Read From CTE For node_id=sma_28019 -- Pass Only Elements: ['visits', 'metric_time__day'] @@ -42,14 +49,14 @@ FROM ( metric_time__day ) subq_26 ON - time_spine_src_28006.ds = subq_26.metric_time__day + rss_28018_cte.ds__day = subq_26.metric_time__day ) subq_30 FULL OUTER JOIN ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_39.buys AS buys - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte LEFT OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'metric_time__day'] @@ -113,7 +120,7 @@ FROM ( metric_time__day ) subq_39 ON - time_spine_src_28006.ds = subq_39.metric_time__day + rss_28018_cte.ds__day = subq_39.metric_time__day ) subq_43 ON subq_30.metric_time__day = subq_43.metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlPlan/Databricks/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlPlan/Databricks/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql index 388b9302b7..09a99150ad 100644 --- a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlPlan/Databricks/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlPlan/Databricks/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql @@ -15,6 +15,13 @@ WITH sma_28019_cte AS ( FROM ***************************.fct_visits visits_source_src_28000 ) +, rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT metric_time__day AS metric_time__day , CAST(buys AS DOUBLE) / CAST(NULLIF(visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days_fill_nulls_with_0 @@ -27,9 +34,9 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_26.visits AS visits - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte LEFT OUTER JOIN ( -- Read From CTE For node_id=sma_28019 -- Pass Only Elements: ['visits', 'metric_time__day'] @@ -42,14 +49,14 @@ FROM ( metric_time__day ) subq_26 ON - time_spine_src_28006.ds = subq_26.metric_time__day + rss_28018_cte.ds__day = subq_26.metric_time__day ) subq_30 FULL OUTER JOIN ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_39.buys AS buys - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte LEFT OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'metric_time__day'] @@ -113,7 +120,7 @@ FROM ( metric_time__day ) subq_39 ON - time_spine_src_28006.ds = subq_39.metric_time__day + rss_28018_cte.ds__day = subq_39.metric_time__day ) subq_43 ON subq_30.metric_time__day = subq_43.metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlPlan/Postgres/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlPlan/Postgres/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql index cd6c238dc3..a89d4f5762 100644 --- a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlPlan/Postgres/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlPlan/Postgres/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql @@ -15,6 +15,13 @@ WITH sma_28019_cte AS ( FROM ***************************.fct_visits visits_source_src_28000 ) +, rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT metric_time__day AS metric_time__day , CAST(buys AS DOUBLE PRECISION) / CAST(NULLIF(visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days_fill_nulls_with_0 @@ -27,9 +34,9 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_26.visits AS visits - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte LEFT OUTER JOIN ( -- Read From CTE For node_id=sma_28019 -- Pass Only Elements: ['visits', 'metric_time__day'] @@ -42,14 +49,14 @@ FROM ( metric_time__day ) subq_26 ON - time_spine_src_28006.ds = subq_26.metric_time__day + rss_28018_cte.ds__day = subq_26.metric_time__day ) subq_30 FULL OUTER JOIN ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_39.buys AS buys - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte LEFT OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'metric_time__day'] @@ -113,7 +120,7 @@ FROM ( metric_time__day ) subq_39 ON - time_spine_src_28006.ds = subq_39.metric_time__day + rss_28018_cte.ds__day = subq_39.metric_time__day ) subq_43 ON subq_30.metric_time__day = subq_43.metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlPlan/Redshift/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlPlan/Redshift/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql index b7de22a306..2a00c0c434 100644 --- a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlPlan/Redshift/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlPlan/Redshift/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql @@ -15,6 +15,13 @@ WITH sma_28019_cte AS ( FROM ***************************.fct_visits visits_source_src_28000 ) +, rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT metric_time__day AS metric_time__day , CAST(buys AS DOUBLE PRECISION) / CAST(NULLIF(visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days_fill_nulls_with_0 @@ -27,9 +34,9 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_26.visits AS visits - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte LEFT OUTER JOIN ( -- Read From CTE For node_id=sma_28019 -- Pass Only Elements: ['visits', 'metric_time__day'] @@ -42,14 +49,14 @@ FROM ( metric_time__day ) subq_26 ON - time_spine_src_28006.ds = subq_26.metric_time__day + rss_28018_cte.ds__day = subq_26.metric_time__day ) subq_30 FULL OUTER JOIN ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_39.buys AS buys - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte LEFT OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'metric_time__day'] @@ -113,7 +120,7 @@ FROM ( metric_time__day ) subq_39 ON - time_spine_src_28006.ds = subq_39.metric_time__day + rss_28018_cte.ds__day = subq_39.metric_time__day ) subq_43 ON subq_30.metric_time__day = subq_43.metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlPlan/Snowflake/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlPlan/Snowflake/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql index 3e17a6cacb..08c910d3db 100644 --- a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlPlan/Snowflake/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlPlan/Snowflake/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql @@ -15,6 +15,13 @@ WITH sma_28019_cte AS ( FROM ***************************.fct_visits visits_source_src_28000 ) +, rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT metric_time__day AS metric_time__day , CAST(buys AS DOUBLE) / CAST(NULLIF(visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days_fill_nulls_with_0 @@ -27,9 +34,9 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_26.visits AS visits - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte LEFT OUTER JOIN ( -- Read From CTE For node_id=sma_28019 -- Pass Only Elements: ['visits', 'metric_time__day'] @@ -42,14 +49,14 @@ FROM ( metric_time__day ) subq_26 ON - time_spine_src_28006.ds = subq_26.metric_time__day + rss_28018_cte.ds__day = subq_26.metric_time__day ) subq_30 FULL OUTER JOIN ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_39.buys AS buys - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte LEFT OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'metric_time__day'] @@ -113,7 +120,7 @@ FROM ( metric_time__day ) subq_39 ON - time_spine_src_28006.ds = subq_39.metric_time__day + rss_28018_cte.ds__day = subq_39.metric_time__day ) subq_43 ON subq_30.metric_time__day = subq_43.metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlPlan/Trino/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlPlan/Trino/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql index 9224c66d0e..7221a05c1e 100644 --- a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlPlan/Trino/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlPlan/Trino/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql @@ -15,6 +15,13 @@ WITH sma_28019_cte AS ( FROM ***************************.fct_visits visits_source_src_28000 ) +, rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT metric_time__day AS metric_time__day , CAST(buys AS DOUBLE) / CAST(NULLIF(visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days_fill_nulls_with_0 @@ -27,9 +34,9 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_26.visits AS visits - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte LEFT OUTER JOIN ( -- Read From CTE For node_id=sma_28019 -- Pass Only Elements: ['visits', 'metric_time__day'] @@ -42,14 +49,14 @@ FROM ( metric_time__day ) subq_26 ON - time_spine_src_28006.ds = subq_26.metric_time__day + rss_28018_cte.ds__day = subq_26.metric_time__day ) subq_30 FULL OUTER JOIN ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_39.buys AS buys - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte LEFT OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'metric_time__day'] @@ -113,7 +120,7 @@ FROM ( metric_time__day ) subq_39 ON - time_spine_src_28006.ds = subq_39.metric_time__day + rss_28018_cte.ds__day = subq_39.metric_time__day ) subq_43 ON subq_30.metric_time__day = subq_43.metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql index 7ab10e3f9a..2484f394e9 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql @@ -12,6 +12,13 @@ WITH sma_28009_cte AS ( FROM ***************************.fct_bookings bookings_source_src_28000 ) +, rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT metric_time__day AS metric_time__day , month_start_bookings - bookings_1_month_ago AS bookings_month_start_compared_to_1_month_prior @@ -27,13 +34,13 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(sma_28009_cte.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - DATETIME_TRUNC(time_spine_src_28006.ds, month) = sma_28009_cte.metric_time__day + DATETIME_TRUNC(rss_28018_cte.ds__day, month) = sma_28009_cte.metric_time__day GROUP BY metric_time__day ) subq_27 @@ -43,13 +50,13 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(sma_28009_cte.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - DATE_SUB(CAST(time_spine_src_28006.ds AS DATETIME), INTERVAL 1 month) = sma_28009_cte.metric_time__day + DATE_SUB(CAST(rss_28018_cte.ds__day AS DATETIME), INTERVAL 1 month) = sma_28009_cte.metric_time__day GROUP BY metric_time__day ) subq_35 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql index 3b0d975dab..a6480c552a 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql @@ -12,6 +12,14 @@ WITH sma_28009_cte AS ( FROM ***************************.fct_bookings bookings_source_src_28000 ) +, rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + , DATETIME_TRUNC(ds, year) AS ds__year + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT metric_time__year AS metric_time__year , month_start_bookings - bookings_1_month_ago AS bookings_month_start_compared_to_1_month_prior @@ -27,14 +35,14 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATETIME_TRUNC(time_spine_src_28006.ds, year) AS metric_time__year + rss_28018_cte.ds__year AS metric_time__year , SUM(sma_28009_cte.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - DATETIME_TRUNC(time_spine_src_28006.ds, month) = sma_28009_cte.metric_time__day - WHERE DATETIME_TRUNC(time_spine_src_28006.ds, year) = time_spine_src_28006.ds + DATETIME_TRUNC(rss_28018_cte.ds__day, month) = sma_28009_cte.metric_time__day + WHERE rss_28018_cte.ds__year = rss_28018_cte.ds__day GROUP BY metric_time__year ) subq_27 @@ -44,13 +52,13 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATETIME_TRUNC(time_spine_src_28006.ds, year) AS metric_time__year + rss_28018_cte.ds__year AS metric_time__year , SUM(sma_28009_cte.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - DATE_SUB(CAST(time_spine_src_28006.ds AS DATETIME), INTERVAL 1 month) = sma_28009_cte.metric_time__day + DATE_SUB(CAST(rss_28018_cte.ds__day AS DATETIME), INTERVAL 1 month) = sma_28009_cte.metric_time__day GROUP BY metric_time__year ) subq_35 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql index 95f6f4f23e..d447bef70a 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql @@ -3,8 +3,15 @@ test_filename: test_derived_metric_rendering.py sql_engine: BigQuery --- -- Compute Metrics via Expressions +WITH rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT - metric_time__day + metric_time__day AS metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Constrain Output with WHERE @@ -15,10 +22,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_25.booking__is_instant AS booking__is_instant , subq_25.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -31,10 +38,10 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_17.booking__is_instant AS booking__is_instant , SUM(subq_17.bookings) AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -45,14 +52,14 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_17 ON - DATE_SUB(CAST(time_spine_src_28006.ds AS DATETIME), INTERVAL 5 day) = subq_17.metric_time__day + DATE_SUB(CAST(rss_28018_cte.ds__day AS DATETIME), INTERVAL 5 day) = subq_17.metric_time__day GROUP BY metric_time__day , booking__is_instant ) subq_24 ) subq_25 ON - DATE_SUB(CAST(time_spine_src_28006.ds AS DATETIME), INTERVAL 2 day) = subq_25.metric_time__day + DATE_SUB(CAST(rss_28018_cte.ds__day AS DATETIME), INTERVAL 2 day) = subq_25.metric_time__day ) subq_29 WHERE booking__is_instant ) subq_31 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_nested_offsets__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_nested_offsets__plan0_optimized.sql index 6af166cd3e..3b8f44affc 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_nested_offsets__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_nested_offsets__plan0_optimized.sql @@ -3,15 +3,22 @@ test_filename: test_derived_metric_rendering.py sql_engine: BigQuery --- -- Compute Metrics via Expressions +WITH rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT - metric_time__day + metric_time__day AS metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_23.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -23,9 +30,9 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(subq_15.bookings) AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -35,11 +42,11 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_15 ON - DATE_SUB(CAST(time_spine_src_28006.ds AS DATETIME), INTERVAL 5 day) = subq_15.metric_time__day + DATE_SUB(CAST(rss_28018_cte.ds__day AS DATETIME), INTERVAL 5 day) = subq_15.metric_time__day GROUP BY metric_time__day ) subq_22 ) subq_23 ON - DATE_SUB(CAST(time_spine_src_28006.ds AS DATETIME), INTERVAL 2 day) = subq_23.metric_time__day + DATE_SUB(CAST(rss_28018_cte.ds__day AS DATETIME), INTERVAL 2 day) = subq_23.metric_time__day ) subq_27 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_nested_offsets_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_nested_offsets_with_time_constraint__plan0_optimized.sql index 0f735319da..cc6167fe4f 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_nested_offsets_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_nested_offsets_with_time_constraint__plan0_optimized.sql @@ -3,16 +3,23 @@ test_filename: test_derived_metric_rendering.py sql_engine: BigQuery --- -- Compute Metrics via Expressions +WITH rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT - metric_time__day + metric_time__day AS metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Join to Time Spine Dataset -- Constrain Time Range to [2020-01-12T00:00:00, 2020-01-13T00:00:00] SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_24.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -24,9 +31,9 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(subq_16.bookings) AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -36,12 +43,12 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_16 ON - DATE_SUB(CAST(time_spine_src_28006.ds AS DATETIME), INTERVAL 5 day) = subq_16.metric_time__day + DATE_SUB(CAST(rss_28018_cte.ds__day AS DATETIME), INTERVAL 5 day) = subq_16.metric_time__day GROUP BY metric_time__day ) subq_23 ) subq_24 ON - DATE_SUB(CAST(time_spine_src_28006.ds AS DATETIME), INTERVAL 2 day) = subq_24.metric_time__day - WHERE time_spine_src_28006.ds BETWEEN '2020-01-12' AND '2020-01-13' + DATE_SUB(CAST(rss_28018_cte.ds__day AS DATETIME), INTERVAL 2 day) = subq_24.metric_time__day + WHERE rss_28018_cte.ds__day BETWEEN '2020-01-12' AND '2020-01-13' ) subq_29 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_nested_offsets_with_where_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_nested_offsets_with_where_constraint__plan0_optimized.sql index 46d5423668..84340cf9eb 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_nested_offsets_with_where_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_nested_offsets_with_where_constraint__plan0_optimized.sql @@ -3,8 +3,15 @@ test_filename: test_derived_metric_rendering.py sql_engine: BigQuery --- -- Compute Metrics via Expressions +WITH rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT - metric_time__day + metric_time__day AS metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Constrain Output with WHERE @@ -14,9 +21,9 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_24.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -28,9 +35,9 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(subq_16.bookings) AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -40,13 +47,13 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_16 ON - DATE_SUB(CAST(time_spine_src_28006.ds AS DATETIME), INTERVAL 5 day) = subq_16.metric_time__day + DATE_SUB(CAST(rss_28018_cte.ds__day AS DATETIME), INTERVAL 5 day) = subq_16.metric_time__day GROUP BY metric_time__day ) subq_23 ) subq_24 ON - DATE_SUB(CAST(time_spine_src_28006.ds AS DATETIME), INTERVAL 2 day) = subq_24.metric_time__day + DATE_SUB(CAST(rss_28018_cte.ds__day AS DATETIME), INTERVAL 2 day) = subq_24.metric_time__day ) subq_28 WHERE metric_time__day = '2020-01-12' or metric_time__day = '2020-01-13' ) subq_29 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql index 3c0b65baf5..208d1e0e55 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql @@ -12,6 +12,13 @@ WITH sma_28009_cte AS ( FROM ***************************.fct_bookings bookings_source_src_28000 ) +, rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT metric_time__day AS metric_time__day , month_start_bookings - bookings_1_month_ago AS bookings_month_start_compared_to_1_month_prior @@ -27,15 +34,15 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(sma_28009_cte.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - DATE_TRUNC('month', time_spine_src_28006.ds) = sma_28009_cte.metric_time__day + DATE_TRUNC('month', rss_28018_cte.ds__day) = sma_28009_cte.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset @@ -43,15 +50,15 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(sma_28009_cte.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - DATEADD(month, -1, time_spine_src_28006.ds) = sma_28009_cte.metric_time__day + DATEADD(month, -1, rss_28018_cte.ds__day) = sma_28009_cte.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day ) subq_35 ON subq_27.metric_time__day = subq_35.metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql index cb23b153ba..355d59fdd4 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql @@ -12,6 +12,14 @@ WITH sma_28009_cte AS ( FROM ***************************.fct_bookings bookings_source_src_28000 ) +, rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + , DATE_TRUNC('year', ds) AS ds__year + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT metric_time__year AS metric_time__year , month_start_bookings - bookings_1_month_ago AS bookings_month_start_compared_to_1_month_prior @@ -27,16 +35,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('year', time_spine_src_28006.ds) AS metric_time__year + rss_28018_cte.ds__year AS metric_time__year , SUM(sma_28009_cte.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - DATE_TRUNC('month', time_spine_src_28006.ds) = sma_28009_cte.metric_time__day - WHERE DATE_TRUNC('year', time_spine_src_28006.ds) = time_spine_src_28006.ds + DATE_TRUNC('month', rss_28018_cte.ds__day) = sma_28009_cte.metric_time__day + WHERE rss_28018_cte.ds__year = rss_28018_cte.ds__day GROUP BY - DATE_TRUNC('year', time_spine_src_28006.ds) + rss_28018_cte.ds__year ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset @@ -44,15 +52,15 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('year', time_spine_src_28006.ds) AS metric_time__year + rss_28018_cte.ds__year AS metric_time__year , SUM(sma_28009_cte.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - DATEADD(month, -1, time_spine_src_28006.ds) = sma_28009_cte.metric_time__day + DATEADD(month, -1, rss_28018_cte.ds__day) = sma_28009_cte.metric_time__day GROUP BY - DATE_TRUNC('year', time_spine_src_28006.ds) + rss_28018_cte.ds__year ) subq_35 ON subq_27.metric_time__year = subq_35.metric_time__year diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql index 89bcc32f7b..a309d6c482 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql @@ -3,8 +3,15 @@ test_filename: test_derived_metric_rendering.py sql_engine: Databricks --- -- Compute Metrics via Expressions +WITH rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT - metric_time__day + metric_time__day AS metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Constrain Output with WHERE @@ -15,10 +22,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_25.booking__is_instant AS booking__is_instant , subq_25.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -31,10 +38,10 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_17.booking__is_instant AS booking__is_instant , SUM(subq_17.bookings) AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -45,14 +52,14 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_17 ON - DATEADD(day, -5, time_spine_src_28006.ds) = subq_17.metric_time__day + DATEADD(day, -5, rss_28018_cte.ds__day) = subq_17.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day , subq_17.booking__is_instant ) subq_24 ) subq_25 ON - DATEADD(day, -2, time_spine_src_28006.ds) = subq_25.metric_time__day + DATEADD(day, -2, rss_28018_cte.ds__day) = subq_25.metric_time__day ) subq_29 WHERE booking__is_instant ) subq_31 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_nested_offsets__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_nested_offsets__plan0_optimized.sql index 9aec36d400..8a71a475c4 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_nested_offsets__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_nested_offsets__plan0_optimized.sql @@ -3,15 +3,22 @@ test_filename: test_derived_metric_rendering.py sql_engine: Databricks --- -- Compute Metrics via Expressions +WITH rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT - metric_time__day + metric_time__day AS metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_23.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -23,9 +30,9 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(subq_15.bookings) AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -35,11 +42,11 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_15 ON - DATEADD(day, -5, time_spine_src_28006.ds) = subq_15.metric_time__day + DATEADD(day, -5, rss_28018_cte.ds__day) = subq_15.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day ) subq_22 ) subq_23 ON - DATEADD(day, -2, time_spine_src_28006.ds) = subq_23.metric_time__day + DATEADD(day, -2, rss_28018_cte.ds__day) = subq_23.metric_time__day ) subq_27 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_nested_offsets_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_nested_offsets_with_time_constraint__plan0_optimized.sql index 837d11c0c1..3d8a5abf9e 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_nested_offsets_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_nested_offsets_with_time_constraint__plan0_optimized.sql @@ -3,16 +3,23 @@ test_filename: test_derived_metric_rendering.py sql_engine: Databricks --- -- Compute Metrics via Expressions +WITH rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT - metric_time__day + metric_time__day AS metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Join to Time Spine Dataset -- Constrain Time Range to [2020-01-12T00:00:00, 2020-01-13T00:00:00] SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_24.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -24,9 +31,9 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(subq_16.bookings) AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -36,12 +43,12 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_16 ON - DATEADD(day, -5, time_spine_src_28006.ds) = subq_16.metric_time__day + DATEADD(day, -5, rss_28018_cte.ds__day) = subq_16.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day ) subq_23 ) subq_24 ON - DATEADD(day, -2, time_spine_src_28006.ds) = subq_24.metric_time__day - WHERE time_spine_src_28006.ds BETWEEN '2020-01-12' AND '2020-01-13' + DATEADD(day, -2, rss_28018_cte.ds__day) = subq_24.metric_time__day + WHERE rss_28018_cte.ds__day BETWEEN '2020-01-12' AND '2020-01-13' ) subq_29 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_nested_offsets_with_where_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_nested_offsets_with_where_constraint__plan0_optimized.sql index 7f46354fce..6140bc3676 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_nested_offsets_with_where_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_nested_offsets_with_where_constraint__plan0_optimized.sql @@ -3,8 +3,15 @@ test_filename: test_derived_metric_rendering.py sql_engine: Databricks --- -- Compute Metrics via Expressions +WITH rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT - metric_time__day + metric_time__day AS metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Constrain Output with WHERE @@ -14,9 +21,9 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_24.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -28,9 +35,9 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(subq_16.bookings) AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -40,13 +47,13 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_16 ON - DATEADD(day, -5, time_spine_src_28006.ds) = subq_16.metric_time__day + DATEADD(day, -5, rss_28018_cte.ds__day) = subq_16.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day ) subq_23 ) subq_24 ON - DATEADD(day, -2, time_spine_src_28006.ds) = subq_24.metric_time__day + DATEADD(day, -2, rss_28018_cte.ds__day) = subq_24.metric_time__day ) subq_28 WHERE metric_time__day = '2020-01-12' or metric_time__day = '2020-01-13' ) subq_29 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql index 3a017678ac..a8f86c1b55 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql @@ -12,6 +12,13 @@ WITH sma_28009_cte AS ( FROM ***************************.fct_bookings bookings_source_src_28000 ) +, rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT metric_time__day AS metric_time__day , month_start_bookings - bookings_1_month_ago AS bookings_month_start_compared_to_1_month_prior @@ -27,15 +34,15 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(sma_28009_cte.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - DATE_TRUNC('month', time_spine_src_28006.ds) = sma_28009_cte.metric_time__day + DATE_TRUNC('month', rss_28018_cte.ds__day) = sma_28009_cte.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset @@ -43,15 +50,15 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(sma_28009_cte.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - time_spine_src_28006.ds - MAKE_INTERVAL(months => 1) = sma_28009_cte.metric_time__day + rss_28018_cte.ds__day - MAKE_INTERVAL(months => 1) = sma_28009_cte.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day ) subq_35 ON subq_27.metric_time__day = subq_35.metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql index fc91a0d498..eed16fab47 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql @@ -12,6 +12,14 @@ WITH sma_28009_cte AS ( FROM ***************************.fct_bookings bookings_source_src_28000 ) +, rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + , DATE_TRUNC('year', ds) AS ds__year + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT metric_time__year AS metric_time__year , month_start_bookings - bookings_1_month_ago AS bookings_month_start_compared_to_1_month_prior @@ -27,16 +35,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('year', time_spine_src_28006.ds) AS metric_time__year + rss_28018_cte.ds__year AS metric_time__year , SUM(sma_28009_cte.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - DATE_TRUNC('month', time_spine_src_28006.ds) = sma_28009_cte.metric_time__day - WHERE DATE_TRUNC('year', time_spine_src_28006.ds) = time_spine_src_28006.ds + DATE_TRUNC('month', rss_28018_cte.ds__day) = sma_28009_cte.metric_time__day + WHERE rss_28018_cte.ds__year = rss_28018_cte.ds__day GROUP BY - DATE_TRUNC('year', time_spine_src_28006.ds) + rss_28018_cte.ds__year ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset @@ -44,15 +52,15 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('year', time_spine_src_28006.ds) AS metric_time__year + rss_28018_cte.ds__year AS metric_time__year , SUM(sma_28009_cte.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - time_spine_src_28006.ds - MAKE_INTERVAL(months => 1) = sma_28009_cte.metric_time__day + rss_28018_cte.ds__day - MAKE_INTERVAL(months => 1) = sma_28009_cte.metric_time__day GROUP BY - DATE_TRUNC('year', time_spine_src_28006.ds) + rss_28018_cte.ds__year ) subq_35 ON subq_27.metric_time__year = subq_35.metric_time__year diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql index cd6a43d881..c27292f69a 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql @@ -3,8 +3,15 @@ test_filename: test_derived_metric_rendering.py sql_engine: Postgres --- -- Compute Metrics via Expressions +WITH rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT - metric_time__day + metric_time__day AS metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Constrain Output with WHERE @@ -15,10 +22,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_25.booking__is_instant AS booking__is_instant , subq_25.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -31,10 +38,10 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_17.booking__is_instant AS booking__is_instant , SUM(subq_17.bookings) AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -45,14 +52,14 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_17 ON - time_spine_src_28006.ds - MAKE_INTERVAL(days => 5) = subq_17.metric_time__day + rss_28018_cte.ds__day - MAKE_INTERVAL(days => 5) = subq_17.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day , subq_17.booking__is_instant ) subq_24 ) subq_25 ON - time_spine_src_28006.ds - MAKE_INTERVAL(days => 2) = subq_25.metric_time__day + rss_28018_cte.ds__day - MAKE_INTERVAL(days => 2) = subq_25.metric_time__day ) subq_29 WHERE booking__is_instant ) subq_31 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_nested_offsets__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_nested_offsets__plan0_optimized.sql index 0cf2bf2811..ead5c3ff38 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_nested_offsets__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_nested_offsets__plan0_optimized.sql @@ -3,15 +3,22 @@ test_filename: test_derived_metric_rendering.py sql_engine: Postgres --- -- Compute Metrics via Expressions +WITH rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT - metric_time__day + metric_time__day AS metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_23.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -23,9 +30,9 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(subq_15.bookings) AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -35,11 +42,11 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_15 ON - time_spine_src_28006.ds - MAKE_INTERVAL(days => 5) = subq_15.metric_time__day + rss_28018_cte.ds__day - MAKE_INTERVAL(days => 5) = subq_15.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day ) subq_22 ) subq_23 ON - time_spine_src_28006.ds - MAKE_INTERVAL(days => 2) = subq_23.metric_time__day + rss_28018_cte.ds__day - MAKE_INTERVAL(days => 2) = subq_23.metric_time__day ) subq_27 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_nested_offsets_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_nested_offsets_with_time_constraint__plan0_optimized.sql index 47a6aadd20..fd46b219c3 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_nested_offsets_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_nested_offsets_with_time_constraint__plan0_optimized.sql @@ -3,16 +3,23 @@ test_filename: test_derived_metric_rendering.py sql_engine: Postgres --- -- Compute Metrics via Expressions +WITH rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT - metric_time__day + metric_time__day AS metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Join to Time Spine Dataset -- Constrain Time Range to [2020-01-12T00:00:00, 2020-01-13T00:00:00] SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_24.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -24,9 +31,9 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(subq_16.bookings) AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -36,12 +43,12 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_16 ON - time_spine_src_28006.ds - MAKE_INTERVAL(days => 5) = subq_16.metric_time__day + rss_28018_cte.ds__day - MAKE_INTERVAL(days => 5) = subq_16.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day ) subq_23 ) subq_24 ON - time_spine_src_28006.ds - MAKE_INTERVAL(days => 2) = subq_24.metric_time__day - WHERE time_spine_src_28006.ds BETWEEN '2020-01-12' AND '2020-01-13' + rss_28018_cte.ds__day - MAKE_INTERVAL(days => 2) = subq_24.metric_time__day + WHERE rss_28018_cte.ds__day BETWEEN '2020-01-12' AND '2020-01-13' ) subq_29 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_nested_offsets_with_where_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_nested_offsets_with_where_constraint__plan0_optimized.sql index 52405830a7..b413336664 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_nested_offsets_with_where_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_nested_offsets_with_where_constraint__plan0_optimized.sql @@ -3,8 +3,15 @@ test_filename: test_derived_metric_rendering.py sql_engine: Postgres --- -- Compute Metrics via Expressions +WITH rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT - metric_time__day + metric_time__day AS metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Constrain Output with WHERE @@ -14,9 +21,9 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_24.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -28,9 +35,9 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(subq_16.bookings) AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -40,13 +47,13 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_16 ON - time_spine_src_28006.ds - MAKE_INTERVAL(days => 5) = subq_16.metric_time__day + rss_28018_cte.ds__day - MAKE_INTERVAL(days => 5) = subq_16.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day ) subq_23 ) subq_24 ON - time_spine_src_28006.ds - MAKE_INTERVAL(days => 2) = subq_24.metric_time__day + rss_28018_cte.ds__day - MAKE_INTERVAL(days => 2) = subq_24.metric_time__day ) subq_28 WHERE metric_time__day = '2020-01-12' or metric_time__day = '2020-01-13' ) subq_29 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql index 1292c54d78..4959d9f2e3 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql @@ -12,6 +12,13 @@ WITH sma_28009_cte AS ( FROM ***************************.fct_bookings bookings_source_src_28000 ) +, rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT metric_time__day AS metric_time__day , month_start_bookings - bookings_1_month_ago AS bookings_month_start_compared_to_1_month_prior @@ -27,15 +34,15 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(sma_28009_cte.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - DATE_TRUNC('month', time_spine_src_28006.ds) = sma_28009_cte.metric_time__day + DATE_TRUNC('month', rss_28018_cte.ds__day) = sma_28009_cte.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset @@ -43,15 +50,15 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(sma_28009_cte.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - DATEADD(month, -1, time_spine_src_28006.ds) = sma_28009_cte.metric_time__day + DATEADD(month, -1, rss_28018_cte.ds__day) = sma_28009_cte.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day ) subq_35 ON subq_27.metric_time__day = subq_35.metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql index 6d06b64f19..3e2075160e 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql @@ -12,6 +12,14 @@ WITH sma_28009_cte AS ( FROM ***************************.fct_bookings bookings_source_src_28000 ) +, rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + , DATE_TRUNC('year', ds) AS ds__year + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT metric_time__year AS metric_time__year , month_start_bookings - bookings_1_month_ago AS bookings_month_start_compared_to_1_month_prior @@ -27,16 +35,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('year', time_spine_src_28006.ds) AS metric_time__year + rss_28018_cte.ds__year AS metric_time__year , SUM(sma_28009_cte.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - DATE_TRUNC('month', time_spine_src_28006.ds) = sma_28009_cte.metric_time__day - WHERE DATE_TRUNC('year', time_spine_src_28006.ds) = time_spine_src_28006.ds + DATE_TRUNC('month', rss_28018_cte.ds__day) = sma_28009_cte.metric_time__day + WHERE rss_28018_cte.ds__year = rss_28018_cte.ds__day GROUP BY - DATE_TRUNC('year', time_spine_src_28006.ds) + rss_28018_cte.ds__year ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset @@ -44,15 +52,15 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('year', time_spine_src_28006.ds) AS metric_time__year + rss_28018_cte.ds__year AS metric_time__year , SUM(sma_28009_cte.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - DATEADD(month, -1, time_spine_src_28006.ds) = sma_28009_cte.metric_time__day + DATEADD(month, -1, rss_28018_cte.ds__day) = sma_28009_cte.metric_time__day GROUP BY - DATE_TRUNC('year', time_spine_src_28006.ds) + rss_28018_cte.ds__year ) subq_35 ON subq_27.metric_time__year = subq_35.metric_time__year diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql index e2a58e9666..2db37a9542 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql @@ -3,8 +3,15 @@ test_filename: test_derived_metric_rendering.py sql_engine: Redshift --- -- Compute Metrics via Expressions +WITH rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT - metric_time__day + metric_time__day AS metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Constrain Output with WHERE @@ -15,10 +22,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_25.booking__is_instant AS booking__is_instant , subq_25.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -31,10 +38,10 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_17.booking__is_instant AS booking__is_instant , SUM(subq_17.bookings) AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -45,14 +52,14 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_17 ON - DATEADD(day, -5, time_spine_src_28006.ds) = subq_17.metric_time__day + DATEADD(day, -5, rss_28018_cte.ds__day) = subq_17.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day , subq_17.booking__is_instant ) subq_24 ) subq_25 ON - DATEADD(day, -2, time_spine_src_28006.ds) = subq_25.metric_time__day + DATEADD(day, -2, rss_28018_cte.ds__day) = subq_25.metric_time__day ) subq_29 WHERE booking__is_instant ) subq_31 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_nested_offsets__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_nested_offsets__plan0_optimized.sql index 78c6b87a94..bc92f162b8 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_nested_offsets__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_nested_offsets__plan0_optimized.sql @@ -3,15 +3,22 @@ test_filename: test_derived_metric_rendering.py sql_engine: Redshift --- -- Compute Metrics via Expressions +WITH rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT - metric_time__day + metric_time__day AS metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_23.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -23,9 +30,9 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(subq_15.bookings) AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -35,11 +42,11 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_15 ON - DATEADD(day, -5, time_spine_src_28006.ds) = subq_15.metric_time__day + DATEADD(day, -5, rss_28018_cte.ds__day) = subq_15.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day ) subq_22 ) subq_23 ON - DATEADD(day, -2, time_spine_src_28006.ds) = subq_23.metric_time__day + DATEADD(day, -2, rss_28018_cte.ds__day) = subq_23.metric_time__day ) subq_27 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_nested_offsets_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_nested_offsets_with_time_constraint__plan0_optimized.sql index abff7fdb59..0a8f2e646f 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_nested_offsets_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_nested_offsets_with_time_constraint__plan0_optimized.sql @@ -3,16 +3,23 @@ test_filename: test_derived_metric_rendering.py sql_engine: Redshift --- -- Compute Metrics via Expressions +WITH rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT - metric_time__day + metric_time__day AS metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Join to Time Spine Dataset -- Constrain Time Range to [2020-01-12T00:00:00, 2020-01-13T00:00:00] SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_24.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -24,9 +31,9 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(subq_16.bookings) AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -36,12 +43,12 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_16 ON - DATEADD(day, -5, time_spine_src_28006.ds) = subq_16.metric_time__day + DATEADD(day, -5, rss_28018_cte.ds__day) = subq_16.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day ) subq_23 ) subq_24 ON - DATEADD(day, -2, time_spine_src_28006.ds) = subq_24.metric_time__day - WHERE time_spine_src_28006.ds BETWEEN '2020-01-12' AND '2020-01-13' + DATEADD(day, -2, rss_28018_cte.ds__day) = subq_24.metric_time__day + WHERE rss_28018_cte.ds__day BETWEEN '2020-01-12' AND '2020-01-13' ) subq_29 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_nested_offsets_with_where_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_nested_offsets_with_where_constraint__plan0_optimized.sql index b75545623c..a5aa73f434 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_nested_offsets_with_where_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_nested_offsets_with_where_constraint__plan0_optimized.sql @@ -3,8 +3,15 @@ test_filename: test_derived_metric_rendering.py sql_engine: Redshift --- -- Compute Metrics via Expressions +WITH rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT - metric_time__day + metric_time__day AS metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Constrain Output with WHERE @@ -14,9 +21,9 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_24.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -28,9 +35,9 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(subq_16.bookings) AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -40,13 +47,13 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_16 ON - DATEADD(day, -5, time_spine_src_28006.ds) = subq_16.metric_time__day + DATEADD(day, -5, rss_28018_cte.ds__day) = subq_16.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day ) subq_23 ) subq_24 ON - DATEADD(day, -2, time_spine_src_28006.ds) = subq_24.metric_time__day + DATEADD(day, -2, rss_28018_cte.ds__day) = subq_24.metric_time__day ) subq_28 WHERE metric_time__day = '2020-01-12' or metric_time__day = '2020-01-13' ) subq_29 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql index 4c95cb1435..1d48535d3c 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql @@ -12,6 +12,13 @@ WITH sma_28009_cte AS ( FROM ***************************.fct_bookings bookings_source_src_28000 ) +, rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT metric_time__day AS metric_time__day , month_start_bookings - bookings_1_month_ago AS bookings_month_start_compared_to_1_month_prior @@ -27,15 +34,15 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(sma_28009_cte.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - DATE_TRUNC('month', time_spine_src_28006.ds) = sma_28009_cte.metric_time__day + DATE_TRUNC('month', rss_28018_cte.ds__day) = sma_28009_cte.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset @@ -43,15 +50,15 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(sma_28009_cte.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - DATEADD(month, -1, time_spine_src_28006.ds) = sma_28009_cte.metric_time__day + DATEADD(month, -1, rss_28018_cte.ds__day) = sma_28009_cte.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day ) subq_35 ON subq_27.metric_time__day = subq_35.metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql index 8b847c8492..e3b8257ea7 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql @@ -12,6 +12,14 @@ WITH sma_28009_cte AS ( FROM ***************************.fct_bookings bookings_source_src_28000 ) +, rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + , DATE_TRUNC('year', ds) AS ds__year + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT metric_time__year AS metric_time__year , month_start_bookings - bookings_1_month_ago AS bookings_month_start_compared_to_1_month_prior @@ -27,16 +35,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('year', time_spine_src_28006.ds) AS metric_time__year + rss_28018_cte.ds__year AS metric_time__year , SUM(sma_28009_cte.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - DATE_TRUNC('month', time_spine_src_28006.ds) = sma_28009_cte.metric_time__day - WHERE DATE_TRUNC('year', time_spine_src_28006.ds) = time_spine_src_28006.ds + DATE_TRUNC('month', rss_28018_cte.ds__day) = sma_28009_cte.metric_time__day + WHERE rss_28018_cte.ds__year = rss_28018_cte.ds__day GROUP BY - DATE_TRUNC('year', time_spine_src_28006.ds) + rss_28018_cte.ds__year ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset @@ -44,15 +52,15 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('year', time_spine_src_28006.ds) AS metric_time__year + rss_28018_cte.ds__year AS metric_time__year , SUM(sma_28009_cte.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - DATEADD(month, -1, time_spine_src_28006.ds) = sma_28009_cte.metric_time__day + DATEADD(month, -1, rss_28018_cte.ds__day) = sma_28009_cte.metric_time__day GROUP BY - DATE_TRUNC('year', time_spine_src_28006.ds) + rss_28018_cte.ds__year ) subq_35 ON subq_27.metric_time__year = subq_35.metric_time__year diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql index be9fa2df7a..76d14a20cc 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql @@ -3,8 +3,15 @@ test_filename: test_derived_metric_rendering.py sql_engine: Snowflake --- -- Compute Metrics via Expressions +WITH rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT - metric_time__day + metric_time__day AS metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Constrain Output with WHERE @@ -15,10 +22,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_25.booking__is_instant AS booking__is_instant , subq_25.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -31,10 +38,10 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_17.booking__is_instant AS booking__is_instant , SUM(subq_17.bookings) AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -45,14 +52,14 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_17 ON - DATEADD(day, -5, time_spine_src_28006.ds) = subq_17.metric_time__day + DATEADD(day, -5, rss_28018_cte.ds__day) = subq_17.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day , subq_17.booking__is_instant ) subq_24 ) subq_25 ON - DATEADD(day, -2, time_spine_src_28006.ds) = subq_25.metric_time__day + DATEADD(day, -2, rss_28018_cte.ds__day) = subq_25.metric_time__day ) subq_29 WHERE booking__is_instant ) subq_31 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_nested_offsets__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_nested_offsets__plan0_optimized.sql index b21ee2333a..8e6206d4a3 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_nested_offsets__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_nested_offsets__plan0_optimized.sql @@ -3,15 +3,22 @@ test_filename: test_derived_metric_rendering.py sql_engine: Snowflake --- -- Compute Metrics via Expressions +WITH rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT - metric_time__day + metric_time__day AS metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_23.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -23,9 +30,9 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(subq_15.bookings) AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -35,11 +42,11 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_15 ON - DATEADD(day, -5, time_spine_src_28006.ds) = subq_15.metric_time__day + DATEADD(day, -5, rss_28018_cte.ds__day) = subq_15.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day ) subq_22 ) subq_23 ON - DATEADD(day, -2, time_spine_src_28006.ds) = subq_23.metric_time__day + DATEADD(day, -2, rss_28018_cte.ds__day) = subq_23.metric_time__day ) subq_27 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_nested_offsets_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_nested_offsets_with_time_constraint__plan0_optimized.sql index 96fb239f13..57fd1ac31e 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_nested_offsets_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_nested_offsets_with_time_constraint__plan0_optimized.sql @@ -3,16 +3,23 @@ test_filename: test_derived_metric_rendering.py sql_engine: Snowflake --- -- Compute Metrics via Expressions +WITH rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT - metric_time__day + metric_time__day AS metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Join to Time Spine Dataset -- Constrain Time Range to [2020-01-12T00:00:00, 2020-01-13T00:00:00] SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_24.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -24,9 +31,9 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(subq_16.bookings) AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -36,12 +43,12 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_16 ON - DATEADD(day, -5, time_spine_src_28006.ds) = subq_16.metric_time__day + DATEADD(day, -5, rss_28018_cte.ds__day) = subq_16.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day ) subq_23 ) subq_24 ON - DATEADD(day, -2, time_spine_src_28006.ds) = subq_24.metric_time__day - WHERE time_spine_src_28006.ds BETWEEN '2020-01-12' AND '2020-01-13' + DATEADD(day, -2, rss_28018_cte.ds__day) = subq_24.metric_time__day + WHERE rss_28018_cte.ds__day BETWEEN '2020-01-12' AND '2020-01-13' ) subq_29 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_nested_offsets_with_where_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_nested_offsets_with_where_constraint__plan0_optimized.sql index 1b0f2830a4..253b59aea6 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_nested_offsets_with_where_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_nested_offsets_with_where_constraint__plan0_optimized.sql @@ -3,8 +3,15 @@ test_filename: test_derived_metric_rendering.py sql_engine: Snowflake --- -- Compute Metrics via Expressions +WITH rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT - metric_time__day + metric_time__day AS metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Constrain Output with WHERE @@ -14,9 +21,9 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_24.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -28,9 +35,9 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(subq_16.bookings) AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -40,13 +47,13 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_16 ON - DATEADD(day, -5, time_spine_src_28006.ds) = subq_16.metric_time__day + DATEADD(day, -5, rss_28018_cte.ds__day) = subq_16.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day ) subq_23 ) subq_24 ON - DATEADD(day, -2, time_spine_src_28006.ds) = subq_24.metric_time__day + DATEADD(day, -2, rss_28018_cte.ds__day) = subq_24.metric_time__day ) subq_28 WHERE metric_time__day = '2020-01-12' or metric_time__day = '2020-01-13' ) subq_29 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql index f5a5f9b9a9..b975395437 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql @@ -12,6 +12,13 @@ WITH sma_28009_cte AS ( FROM ***************************.fct_bookings bookings_source_src_28000 ) +, rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT metric_time__day AS metric_time__day , month_start_bookings - bookings_1_month_ago AS bookings_month_start_compared_to_1_month_prior @@ -27,15 +34,15 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(sma_28009_cte.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - DATE_TRUNC('month', time_spine_src_28006.ds) = sma_28009_cte.metric_time__day + DATE_TRUNC('month', rss_28018_cte.ds__day) = sma_28009_cte.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset @@ -43,15 +50,15 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(sma_28009_cte.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - DATE_ADD('month', -1, time_spine_src_28006.ds) = sma_28009_cte.metric_time__day + DATE_ADD('month', -1, rss_28018_cte.ds__day) = sma_28009_cte.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day ) subq_35 ON subq_27.metric_time__day = subq_35.metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql index 0e82437efe..875e4ca7f2 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql @@ -12,6 +12,14 @@ WITH sma_28009_cte AS ( FROM ***************************.fct_bookings bookings_source_src_28000 ) +, rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + , DATE_TRUNC('year', ds) AS ds__year + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT metric_time__year AS metric_time__year , month_start_bookings - bookings_1_month_ago AS bookings_month_start_compared_to_1_month_prior @@ -27,16 +35,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('year', time_spine_src_28006.ds) AS metric_time__year + rss_28018_cte.ds__year AS metric_time__year , SUM(sma_28009_cte.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - DATE_TRUNC('month', time_spine_src_28006.ds) = sma_28009_cte.metric_time__day - WHERE DATE_TRUNC('year', time_spine_src_28006.ds) = time_spine_src_28006.ds + DATE_TRUNC('month', rss_28018_cte.ds__day) = sma_28009_cte.metric_time__day + WHERE rss_28018_cte.ds__year = rss_28018_cte.ds__day GROUP BY - DATE_TRUNC('year', time_spine_src_28006.ds) + rss_28018_cte.ds__year ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset @@ -44,15 +52,15 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('year', time_spine_src_28006.ds) AS metric_time__year + rss_28018_cte.ds__year AS metric_time__year , SUM(sma_28009_cte.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - DATE_ADD('month', -1, time_spine_src_28006.ds) = sma_28009_cte.metric_time__day + DATE_ADD('month', -1, rss_28018_cte.ds__day) = sma_28009_cte.metric_time__day GROUP BY - DATE_TRUNC('year', time_spine_src_28006.ds) + rss_28018_cte.ds__year ) subq_35 ON subq_27.metric_time__year = subq_35.metric_time__year diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql index 01dab6b8e5..634ea78921 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql @@ -3,8 +3,15 @@ test_filename: test_derived_metric_rendering.py sql_engine: Trino --- -- Compute Metrics via Expressions +WITH rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT - metric_time__day + metric_time__day AS metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Constrain Output with WHERE @@ -15,10 +22,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_25.booking__is_instant AS booking__is_instant , subq_25.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -31,10 +38,10 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_17.booking__is_instant AS booking__is_instant , SUM(subq_17.bookings) AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -45,14 +52,14 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_17 ON - DATE_ADD('day', -5, time_spine_src_28006.ds) = subq_17.metric_time__day + DATE_ADD('day', -5, rss_28018_cte.ds__day) = subq_17.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day , subq_17.booking__is_instant ) subq_24 ) subq_25 ON - DATE_ADD('day', -2, time_spine_src_28006.ds) = subq_25.metric_time__day + DATE_ADD('day', -2, rss_28018_cte.ds__day) = subq_25.metric_time__day ) subq_29 WHERE booking__is_instant ) subq_31 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_nested_offsets__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_nested_offsets__plan0_optimized.sql index e59300d868..4a84ae80ba 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_nested_offsets__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_nested_offsets__plan0_optimized.sql @@ -3,15 +3,22 @@ test_filename: test_derived_metric_rendering.py sql_engine: Trino --- -- Compute Metrics via Expressions +WITH rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT - metric_time__day + metric_time__day AS metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_23.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -23,9 +30,9 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(subq_15.bookings) AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -35,11 +42,11 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_15 ON - DATE_ADD('day', -5, time_spine_src_28006.ds) = subq_15.metric_time__day + DATE_ADD('day', -5, rss_28018_cte.ds__day) = subq_15.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day ) subq_22 ) subq_23 ON - DATE_ADD('day', -2, time_spine_src_28006.ds) = subq_23.metric_time__day + DATE_ADD('day', -2, rss_28018_cte.ds__day) = subq_23.metric_time__day ) subq_27 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_nested_offsets_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_nested_offsets_with_time_constraint__plan0_optimized.sql index b3018cd737..d6bf6030d8 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_nested_offsets_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_nested_offsets_with_time_constraint__plan0_optimized.sql @@ -3,16 +3,23 @@ test_filename: test_derived_metric_rendering.py sql_engine: Trino --- -- Compute Metrics via Expressions +WITH rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT - metric_time__day + metric_time__day AS metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Join to Time Spine Dataset -- Constrain Time Range to [2020-01-12T00:00:00, 2020-01-13T00:00:00] SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_24.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -24,9 +31,9 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(subq_16.bookings) AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -36,12 +43,12 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_16 ON - DATE_ADD('day', -5, time_spine_src_28006.ds) = subq_16.metric_time__day + DATE_ADD('day', -5, rss_28018_cte.ds__day) = subq_16.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day ) subq_23 ) subq_24 ON - DATE_ADD('day', -2, time_spine_src_28006.ds) = subq_24.metric_time__day - WHERE time_spine_src_28006.ds BETWEEN timestamp '2020-01-12' AND timestamp '2020-01-13' + DATE_ADD('day', -2, rss_28018_cte.ds__day) = subq_24.metric_time__day + WHERE rss_28018_cte.ds__day BETWEEN timestamp '2020-01-12' AND timestamp '2020-01-13' ) subq_29 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_nested_offsets_with_where_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_nested_offsets_with_where_constraint__plan0_optimized.sql index 38d6d2753d..bb18ead16a 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_nested_offsets_with_where_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_nested_offsets_with_where_constraint__plan0_optimized.sql @@ -3,8 +3,15 @@ test_filename: test_derived_metric_rendering.py sql_engine: Trino --- -- Compute Metrics via Expressions +WITH rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT - metric_time__day + metric_time__day AS metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Constrain Output with WHERE @@ -14,9 +21,9 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_24.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -28,9 +35,9 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(subq_16.bookings) AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -40,13 +47,13 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_16 ON - DATE_ADD('day', -5, time_spine_src_28006.ds) = subq_16.metric_time__day + DATE_ADD('day', -5, rss_28018_cte.ds__day) = subq_16.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day ) subq_23 ) subq_24 ON - DATE_ADD('day', -2, time_spine_src_28006.ds) = subq_24.metric_time__day + DATE_ADD('day', -2, rss_28018_cte.ds__day) = subq_24.metric_time__day ) subq_28 WHERE metric_time__day = '2020-01-12' or metric_time__day = '2020-01-13' ) subq_29 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/BigQuery/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/BigQuery/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql index bc4c76ab9f..403db7de6f 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/BigQuery/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/BigQuery/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql @@ -12,6 +12,13 @@ WITH sma_28009_cte AS ( FROM ***************************.fct_bookings bookings_source_src_28000 ) +, rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT metric_time__day AS metric_time__day , bookings_fill_nulls_with_0 - bookings_2_weeks_ago AS bookings_growth_2_weeks_fill_nulls_with_0_for_non_offset @@ -29,9 +36,9 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_22.bookings AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte LEFT OUTER JOIN ( -- Read From CTE For node_id=sma_28009 -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -44,7 +51,7 @@ FROM ( metric_time__day ) subq_22 ON - time_spine_src_28006.ds = subq_22.metric_time__day + rss_28018_cte.ds__day = subq_22.metric_time__day ) subq_26 ) subq_27 FULL OUTER JOIN ( @@ -53,13 +60,13 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(sma_28009_cte.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - DATE_SUB(CAST(time_spine_src_28006.ds AS DATETIME), INTERVAL 14 day) = sma_28009_cte.metric_time__day + DATE_SUB(CAST(rss_28018_cte.ds__day AS DATETIME), INTERVAL 14 day) = sma_28009_cte.metric_time__day GROUP BY metric_time__day ) subq_35 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Databricks/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Databricks/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql index b89168fc0c..05ed03750a 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Databricks/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Databricks/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql @@ -12,6 +12,13 @@ WITH sma_28009_cte AS ( FROM ***************************.fct_bookings bookings_source_src_28000 ) +, rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT metric_time__day AS metric_time__day , bookings_fill_nulls_with_0 - bookings_2_weeks_ago AS bookings_growth_2_weeks_fill_nulls_with_0_for_non_offset @@ -29,9 +36,9 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_22.bookings AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte LEFT OUTER JOIN ( -- Read From CTE For node_id=sma_28009 -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -44,7 +51,7 @@ FROM ( metric_time__day ) subq_22 ON - time_spine_src_28006.ds = subq_22.metric_time__day + rss_28018_cte.ds__day = subq_22.metric_time__day ) subq_26 ) subq_27 FULL OUTER JOIN ( @@ -53,15 +60,15 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(sma_28009_cte.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - DATEADD(day, -14, time_spine_src_28006.ds) = sma_28009_cte.metric_time__day + DATEADD(day, -14, rss_28018_cte.ds__day) = sma_28009_cte.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day ) subq_35 ON subq_27.metric_time__day = subq_35.metric_time__day diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Postgres/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Postgres/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql index 9cb9ff0f3a..17633a2fca 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Postgres/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Postgres/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql @@ -12,6 +12,13 @@ WITH sma_28009_cte AS ( FROM ***************************.fct_bookings bookings_source_src_28000 ) +, rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT metric_time__day AS metric_time__day , bookings_fill_nulls_with_0 - bookings_2_weeks_ago AS bookings_growth_2_weeks_fill_nulls_with_0_for_non_offset @@ -29,9 +36,9 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_22.bookings AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte LEFT OUTER JOIN ( -- Read From CTE For node_id=sma_28009 -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -44,7 +51,7 @@ FROM ( metric_time__day ) subq_22 ON - time_spine_src_28006.ds = subq_22.metric_time__day + rss_28018_cte.ds__day = subq_22.metric_time__day ) subq_26 ) subq_27 FULL OUTER JOIN ( @@ -53,15 +60,15 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(sma_28009_cte.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - time_spine_src_28006.ds - MAKE_INTERVAL(days => 14) = sma_28009_cte.metric_time__day + rss_28018_cte.ds__day - MAKE_INTERVAL(days => 14) = sma_28009_cte.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day ) subq_35 ON subq_27.metric_time__day = subq_35.metric_time__day diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Redshift/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Redshift/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql index a9f252ee25..1fed8fc201 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Redshift/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Redshift/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql @@ -12,6 +12,13 @@ WITH sma_28009_cte AS ( FROM ***************************.fct_bookings bookings_source_src_28000 ) +, rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT metric_time__day AS metric_time__day , bookings_fill_nulls_with_0 - bookings_2_weeks_ago AS bookings_growth_2_weeks_fill_nulls_with_0_for_non_offset @@ -29,9 +36,9 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_22.bookings AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte LEFT OUTER JOIN ( -- Read From CTE For node_id=sma_28009 -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -44,7 +51,7 @@ FROM ( metric_time__day ) subq_22 ON - time_spine_src_28006.ds = subq_22.metric_time__day + rss_28018_cte.ds__day = subq_22.metric_time__day ) subq_26 ) subq_27 FULL OUTER JOIN ( @@ -53,15 +60,15 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(sma_28009_cte.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - DATEADD(day, -14, time_spine_src_28006.ds) = sma_28009_cte.metric_time__day + DATEADD(day, -14, rss_28018_cte.ds__day) = sma_28009_cte.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day ) subq_35 ON subq_27.metric_time__day = subq_35.metric_time__day diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Snowflake/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Snowflake/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql index 2bf1ecb8ea..5b566d2991 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Snowflake/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Snowflake/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql @@ -12,6 +12,13 @@ WITH sma_28009_cte AS ( FROM ***************************.fct_bookings bookings_source_src_28000 ) +, rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT metric_time__day AS metric_time__day , bookings_fill_nulls_with_0 - bookings_2_weeks_ago AS bookings_growth_2_weeks_fill_nulls_with_0_for_non_offset @@ -29,9 +36,9 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_22.bookings AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte LEFT OUTER JOIN ( -- Read From CTE For node_id=sma_28009 -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -44,7 +51,7 @@ FROM ( metric_time__day ) subq_22 ON - time_spine_src_28006.ds = subq_22.metric_time__day + rss_28018_cte.ds__day = subq_22.metric_time__day ) subq_26 ) subq_27 FULL OUTER JOIN ( @@ -53,15 +60,15 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(sma_28009_cte.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - DATEADD(day, -14, time_spine_src_28006.ds) = sma_28009_cte.metric_time__day + DATEADD(day, -14, rss_28018_cte.ds__day) = sma_28009_cte.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day ) subq_35 ON subq_27.metric_time__day = subq_35.metric_time__day diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Trino/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Trino/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql index 425dab581c..561bc2d1b7 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Trino/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Trino/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql @@ -12,6 +12,13 @@ WITH sma_28009_cte AS ( FROM ***************************.fct_bookings bookings_source_src_28000 ) +, rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT metric_time__day AS metric_time__day , bookings_fill_nulls_with_0 - bookings_2_weeks_ago AS bookings_growth_2_weeks_fill_nulls_with_0_for_non_offset @@ -29,9 +36,9 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_22.bookings AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte LEFT OUTER JOIN ( -- Read From CTE For node_id=sma_28009 -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -44,7 +51,7 @@ FROM ( metric_time__day ) subq_22 ON - time_spine_src_28006.ds = subq_22.metric_time__day + rss_28018_cte.ds__day = subq_22.metric_time__day ) subq_26 ) subq_27 FULL OUTER JOIN ( @@ -53,15 +60,15 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , SUM(sma_28009_cte.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - DATE_ADD('day', -14, time_spine_src_28006.ds) = sma_28009_cte.metric_time__day + DATE_ADD('day', -14, rss_28018_cte.ds__day) = sma_28009_cte.metric_time__day GROUP BY - time_spine_src_28006.ds + rss_28018_cte.ds__day ) subq_35 ON subq_27.metric_time__day = subq_35.metric_time__day diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/BigQuery/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/BigQuery/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql index 1664f5cfc0..7d2250613c 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/BigQuery/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/BigQuery/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql @@ -27,6 +27,13 @@ WITH sma_28009_cte AS ( FROM ***************************.dim_listings_latest listings_latest_src_28000 ) +, rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT metric_time__day AS metric_time__day , listing__country_latest AS listing__country_latest @@ -47,10 +54,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_41.listing__country_latest AS listing__country_latest , subq_41.bookings AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -78,7 +85,7 @@ FROM ( , listing__country_latest ) subq_41 ON - time_spine_src_28006.ds = subq_41.metric_time__day + rss_28018_cte.ds__day = subq_41.metric_time__day ) subq_45 ) subq_46 FULL OUTER JOIN ( @@ -90,10 +97,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_57.listing__country_latest AS listing__country_latest , subq_57.bookings AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -112,15 +119,15 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , sma_28009_cte.listing AS listing , sma_28009_cte.booking__is_instant AS booking__is_instant , sma_28009_cte.bookings AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - DATE_SUB(CAST(time_spine_src_28006.ds AS DATETIME), INTERVAL 14 day) = sma_28009_cte.metric_time__day + DATE_SUB(CAST(rss_28018_cte.ds__day AS DATETIME), INTERVAL 14 day) = sma_28009_cte.metric_time__day ) subq_51 LEFT OUTER JOIN sma_28014_cte sma_28014_cte @@ -133,7 +140,7 @@ FROM ( , listing__country_latest ) subq_57 ON - time_spine_src_28006.ds = subq_57.metric_time__day + rss_28018_cte.ds__day = subq_57.metric_time__day ) subq_61 ) subq_62 ON diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Databricks/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Databricks/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql index d729f4a16a..5e97f5b59b 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Databricks/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Databricks/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql @@ -27,6 +27,13 @@ WITH sma_28009_cte AS ( FROM ***************************.dim_listings_latest listings_latest_src_28000 ) +, rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT metric_time__day AS metric_time__day , listing__country_latest AS listing__country_latest @@ -47,10 +54,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_41.listing__country_latest AS listing__country_latest , subq_41.bookings AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -78,7 +85,7 @@ FROM ( , listing__country_latest ) subq_41 ON - time_spine_src_28006.ds = subq_41.metric_time__day + rss_28018_cte.ds__day = subq_41.metric_time__day ) subq_45 ) subq_46 FULL OUTER JOIN ( @@ -90,10 +97,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_57.listing__country_latest AS listing__country_latest , subq_57.bookings AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -112,15 +119,15 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , sma_28009_cte.listing AS listing , sma_28009_cte.booking__is_instant AS booking__is_instant , sma_28009_cte.bookings AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - DATEADD(day, -14, time_spine_src_28006.ds) = sma_28009_cte.metric_time__day + DATEADD(day, -14, rss_28018_cte.ds__day) = sma_28009_cte.metric_time__day ) subq_51 LEFT OUTER JOIN sma_28014_cte sma_28014_cte @@ -133,7 +140,7 @@ FROM ( , listing__country_latest ) subq_57 ON - time_spine_src_28006.ds = subq_57.metric_time__day + rss_28018_cte.ds__day = subq_57.metric_time__day ) subq_61 ) subq_62 ON diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Postgres/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Postgres/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql index 0ae100186f..29cfc512f3 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Postgres/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Postgres/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql @@ -27,6 +27,13 @@ WITH sma_28009_cte AS ( FROM ***************************.dim_listings_latest listings_latest_src_28000 ) +, rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT metric_time__day AS metric_time__day , listing__country_latest AS listing__country_latest @@ -47,10 +54,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_41.listing__country_latest AS listing__country_latest , subq_41.bookings AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -78,7 +85,7 @@ FROM ( , listing__country_latest ) subq_41 ON - time_spine_src_28006.ds = subq_41.metric_time__day + rss_28018_cte.ds__day = subq_41.metric_time__day ) subq_45 ) subq_46 FULL OUTER JOIN ( @@ -90,10 +97,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_57.listing__country_latest AS listing__country_latest , subq_57.bookings AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -112,15 +119,15 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , sma_28009_cte.listing AS listing , sma_28009_cte.booking__is_instant AS booking__is_instant , sma_28009_cte.bookings AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - time_spine_src_28006.ds - MAKE_INTERVAL(days => 14) = sma_28009_cte.metric_time__day + rss_28018_cte.ds__day - MAKE_INTERVAL(days => 14) = sma_28009_cte.metric_time__day ) subq_51 LEFT OUTER JOIN sma_28014_cte sma_28014_cte @@ -133,7 +140,7 @@ FROM ( , listing__country_latest ) subq_57 ON - time_spine_src_28006.ds = subq_57.metric_time__day + rss_28018_cte.ds__day = subq_57.metric_time__day ) subq_61 ) subq_62 ON diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Redshift/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Redshift/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql index 321d4f55da..1b325d167a 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Redshift/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Redshift/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql @@ -27,6 +27,13 @@ WITH sma_28009_cte AS ( FROM ***************************.dim_listings_latest listings_latest_src_28000 ) +, rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT metric_time__day AS metric_time__day , listing__country_latest AS listing__country_latest @@ -47,10 +54,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_41.listing__country_latest AS listing__country_latest , subq_41.bookings AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -78,7 +85,7 @@ FROM ( , listing__country_latest ) subq_41 ON - time_spine_src_28006.ds = subq_41.metric_time__day + rss_28018_cte.ds__day = subq_41.metric_time__day ) subq_45 ) subq_46 FULL OUTER JOIN ( @@ -90,10 +97,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_57.listing__country_latest AS listing__country_latest , subq_57.bookings AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -112,15 +119,15 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , sma_28009_cte.listing AS listing , sma_28009_cte.booking__is_instant AS booking__is_instant , sma_28009_cte.bookings AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - DATEADD(day, -14, time_spine_src_28006.ds) = sma_28009_cte.metric_time__day + DATEADD(day, -14, rss_28018_cte.ds__day) = sma_28009_cte.metric_time__day ) subq_51 LEFT OUTER JOIN sma_28014_cte sma_28014_cte @@ -133,7 +140,7 @@ FROM ( , listing__country_latest ) subq_57 ON - time_spine_src_28006.ds = subq_57.metric_time__day + rss_28018_cte.ds__day = subq_57.metric_time__day ) subq_61 ) subq_62 ON diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Snowflake/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Snowflake/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql index a9bbc330cc..b67368ffd9 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Snowflake/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Snowflake/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql @@ -27,6 +27,13 @@ WITH sma_28009_cte AS ( FROM ***************************.dim_listings_latest listings_latest_src_28000 ) +, rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT metric_time__day AS metric_time__day , listing__country_latest AS listing__country_latest @@ -47,10 +54,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_41.listing__country_latest AS listing__country_latest , subq_41.bookings AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -78,7 +85,7 @@ FROM ( , listing__country_latest ) subq_41 ON - time_spine_src_28006.ds = subq_41.metric_time__day + rss_28018_cte.ds__day = subq_41.metric_time__day ) subq_45 ) subq_46 FULL OUTER JOIN ( @@ -90,10 +97,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_57.listing__country_latest AS listing__country_latest , subq_57.bookings AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -112,15 +119,15 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , sma_28009_cte.listing AS listing , sma_28009_cte.booking__is_instant AS booking__is_instant , sma_28009_cte.bookings AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - DATEADD(day, -14, time_spine_src_28006.ds) = sma_28009_cte.metric_time__day + DATEADD(day, -14, rss_28018_cte.ds__day) = sma_28009_cte.metric_time__day ) subq_51 LEFT OUTER JOIN sma_28014_cte sma_28014_cte @@ -133,7 +140,7 @@ FROM ( , listing__country_latest ) subq_57 ON - time_spine_src_28006.ds = subq_57.metric_time__day + rss_28018_cte.ds__day = subq_57.metric_time__day ) subq_61 ) subq_62 ON diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Trino/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Trino/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql index ff3f3308e9..4d398d2a63 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Trino/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Trino/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql @@ -27,6 +27,13 @@ WITH sma_28009_cte AS ( FROM ***************************.dim_listings_latest listings_latest_src_28000 ) +, rss_28018_cte AS ( + -- Read From Time Spine 'mf_time_spine' + SELECT + ds AS ds__day + FROM ***************************.mf_time_spine time_spine_src_28006 +) + SELECT metric_time__day AS metric_time__day , listing__country_latest AS listing__country_latest @@ -47,10 +54,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_41.listing__country_latest AS listing__country_latest , subq_41.bookings AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -78,7 +85,7 @@ FROM ( , listing__country_latest ) subq_41 ON - time_spine_src_28006.ds = subq_41.metric_time__day + rss_28018_cte.ds__day = subq_41.metric_time__day ) subq_45 ) subq_46 FULL OUTER JOIN ( @@ -90,10 +97,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , subq_57.listing__country_latest AS listing__country_latest , subq_57.bookings AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -112,15 +119,15 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - time_spine_src_28006.ds AS metric_time__day + rss_28018_cte.ds__day AS metric_time__day , sma_28009_cte.listing AS listing , sma_28009_cte.booking__is_instant AS booking__is_instant , sma_28009_cte.bookings AS bookings - FROM ***************************.mf_time_spine time_spine_src_28006 + FROM rss_28018_cte rss_28018_cte INNER JOIN sma_28009_cte sma_28009_cte ON - DATE_ADD('day', -14, time_spine_src_28006.ds) = sma_28009_cte.metric_time__day + DATE_ADD('day', -14, rss_28018_cte.ds__day) = sma_28009_cte.metric_time__day ) subq_51 LEFT OUTER JOIN sma_28014_cte sma_28014_cte @@ -133,7 +140,7 @@ FROM ( , listing__country_latest ) subq_57 ON - time_spine_src_28006.ds = subq_57.metric_time__day + rss_28018_cte.ds__day = subq_57.metric_time__day ) subq_61 ) subq_62 ON From c79153d13365699713cebf139d4469863beb39d6 Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Wed, 18 Dec 2024 12:50:28 -0800 Subject: [PATCH 12/13] Dedupe filter specs in join to time spine queries --- metricflow/dataflow/builder/dataflow_plan_builder.py | 4 +++- ...t_offset_metric_with_custom_granularity__plan0.sql | 2 +- ...stom_granularity_filter_not_in_group_by__plan0.sql | 2 +- ...t_offset_metric_with_custom_granularity__plan0.sql | 2 +- ...stom_granularity_filter_not_in_group_by__plan0.sql | 2 +- ...t_offset_metric_with_custom_granularity__plan0.sql | 2 +- ...stom_granularity_filter_not_in_group_by__plan0.sql | 2 +- ...t_offset_metric_with_custom_granularity__plan0.sql | 2 +- ...stom_granularity_filter_not_in_group_by__plan0.sql | 2 +- ...t_offset_metric_with_custom_granularity__plan0.sql | 2 +- ...stom_granularity_filter_not_in_group_by__plan0.sql | 2 +- ...t_offset_metric_with_custom_granularity__plan0.sql | 2 +- ...stom_granularity_filter_not_in_group_by__plan0.sql | 2 +- ...t_offset_metric_with_custom_granularity__plan0.sql | 2 +- ...stom_granularity_filter_not_in_group_by__plan0.sql | 2 +- .../test_derived_metric_offset_to_grain__dfp_0.xml | 7 +------ .../test_derived_metric_offset_window__dfp_0.xml | 7 +------ .../test_derived_offset_cumulative_metric__dfp_0.xml | 7 +------ .../test_join_to_time_spine_derived_metric__dfp_0.xml | 11 +---------- ...nested_derived_metric_with_outer_offset__dfp_0.xml | 11 +---------- ...time_offset_metric_with_time_constraint__plan0.sql | 2 +- ..._with_month_dimension_and_offset_window__plan0.sql | 2 +- ...h_dimension_and_offset_window__plan0_optimized.sql | 2 +- ...est_derived_metric_with_offset_to_grain__plan0.sql | 2 +- .../test_derived_metric_with_offset_window__plan0.sql | 2 +- ..._with_offset_window_and_offset_to_grain__plan0.sql | 4 ++-- ...tric_with_offset_window_and_time_filter__plan0.sql | 2 +- .../test_derived_offset_cumulative_metric__plan0.sql | 2 +- ...derived_offset_metric_with_agg_time_dim__plan0.sql | 2 +- ...ved_offset_metric_with_one_input_metric__plan0.sql | 2 +- ...th_joined_where_constraint_not_selected__plan0.sql | 2 +- .../SqlPlan/BigQuery/test_nested_offsets__plan0.sql | 2 +- ...est_nested_offsets_with_time_constraint__plan0.sql | 2 +- ...st_nested_offsets_with_where_constraint__plan0.sql | 2 +- ..._to_grain_metric_multiple_granularities__plan0.sql | 2 +- .../test_offset_to_grain_with_agg_time_dim__plan0.sql | 2 +- ...et_window_metric_multiple_granularities__plan0.sql | 2 +- .../test_offset_window_with_agg_time_dim__plan0.sql | 2 +- ...time_offset_metric_with_time_constraint__plan0.sql | 2 +- ...time_offset_metric_with_time_constraint__plan0.sql | 2 +- ..._with_month_dimension_and_offset_window__plan0.sql | 2 +- ...h_dimension_and_offset_window__plan0_optimized.sql | 2 +- ...est_derived_metric_with_offset_to_grain__plan0.sql | 2 +- .../test_derived_metric_with_offset_window__plan0.sql | 2 +- ..._with_offset_window_and_offset_to_grain__plan0.sql | 4 ++-- ...tric_with_offset_window_and_time_filter__plan0.sql | 2 +- .../test_derived_offset_cumulative_metric__plan0.sql | 2 +- ...derived_offset_metric_with_agg_time_dim__plan0.sql | 2 +- ...ved_offset_metric_with_one_input_metric__plan0.sql | 2 +- ...th_joined_where_constraint_not_selected__plan0.sql | 2 +- .../SqlPlan/Databricks/test_nested_offsets__plan0.sql | 2 +- ...est_nested_offsets_with_time_constraint__plan0.sql | 2 +- ...st_nested_offsets_with_where_constraint__plan0.sql | 2 +- ..._to_grain_metric_multiple_granularities__plan0.sql | 2 +- .../test_offset_to_grain_with_agg_time_dim__plan0.sql | 2 +- ...et_window_metric_multiple_granularities__plan0.sql | 2 +- .../test_offset_window_with_agg_time_dim__plan0.sql | 2 +- ...time_offset_metric_with_time_constraint__plan0.sql | 2 +- ...time_offset_metric_with_time_constraint__plan0.sql | 2 +- ..._with_month_dimension_and_offset_window__plan0.sql | 2 +- ...h_dimension_and_offset_window__plan0_optimized.sql | 2 +- ...est_derived_metric_with_offset_to_grain__plan0.sql | 2 +- .../test_derived_metric_with_offset_window__plan0.sql | 2 +- ..._with_offset_window_and_offset_to_grain__plan0.sql | 4 ++-- ...tric_with_offset_window_and_time_filter__plan0.sql | 2 +- .../test_derived_offset_cumulative_metric__plan0.sql | 2 +- ...derived_offset_metric_with_agg_time_dim__plan0.sql | 2 +- ...ved_offset_metric_with_one_input_metric__plan0.sql | 2 +- ...th_joined_where_constraint_not_selected__plan0.sql | 2 +- .../SqlPlan/DuckDB/test_nested_offsets__plan0.sql | 2 +- ...est_nested_offsets_with_time_constraint__plan0.sql | 2 +- ...st_nested_offsets_with_where_constraint__plan0.sql | 2 +- ..._to_grain_metric_multiple_granularities__plan0.sql | 2 +- .../test_offset_to_grain_with_agg_time_dim__plan0.sql | 2 +- ...et_window_metric_multiple_granularities__plan0.sql | 2 +- .../test_offset_window_with_agg_time_dim__plan0.sql | 2 +- ...time_offset_metric_with_time_constraint__plan0.sql | 2 +- ...time_offset_metric_with_time_constraint__plan0.sql | 2 +- ..._with_month_dimension_and_offset_window__plan0.sql | 2 +- ...h_dimension_and_offset_window__plan0_optimized.sql | 2 +- ...est_derived_metric_with_offset_to_grain__plan0.sql | 2 +- .../test_derived_metric_with_offset_window__plan0.sql | 2 +- ..._with_offset_window_and_offset_to_grain__plan0.sql | 4 ++-- ...tric_with_offset_window_and_time_filter__plan0.sql | 2 +- .../test_derived_offset_cumulative_metric__plan0.sql | 2 +- ...derived_offset_metric_with_agg_time_dim__plan0.sql | 2 +- ...ved_offset_metric_with_one_input_metric__plan0.sql | 2 +- ...th_joined_where_constraint_not_selected__plan0.sql | 2 +- .../SqlPlan/Postgres/test_nested_offsets__plan0.sql | 2 +- ...est_nested_offsets_with_time_constraint__plan0.sql | 2 +- ...st_nested_offsets_with_where_constraint__plan0.sql | 2 +- ..._to_grain_metric_multiple_granularities__plan0.sql | 2 +- .../test_offset_to_grain_with_agg_time_dim__plan0.sql | 2 +- ...et_window_metric_multiple_granularities__plan0.sql | 2 +- .../test_offset_window_with_agg_time_dim__plan0.sql | 2 +- ...time_offset_metric_with_time_constraint__plan0.sql | 2 +- ...time_offset_metric_with_time_constraint__plan0.sql | 2 +- ..._with_month_dimension_and_offset_window__plan0.sql | 2 +- ...h_dimension_and_offset_window__plan0_optimized.sql | 2 +- ...est_derived_metric_with_offset_to_grain__plan0.sql | 2 +- .../test_derived_metric_with_offset_window__plan0.sql | 2 +- ..._with_offset_window_and_offset_to_grain__plan0.sql | 4 ++-- ...tric_with_offset_window_and_time_filter__plan0.sql | 2 +- .../test_derived_offset_cumulative_metric__plan0.sql | 2 +- ...derived_offset_metric_with_agg_time_dim__plan0.sql | 2 +- ...ved_offset_metric_with_one_input_metric__plan0.sql | 2 +- ...th_joined_where_constraint_not_selected__plan0.sql | 2 +- .../SqlPlan/Redshift/test_nested_offsets__plan0.sql | 2 +- ...est_nested_offsets_with_time_constraint__plan0.sql | 2 +- ...st_nested_offsets_with_where_constraint__plan0.sql | 2 +- ..._to_grain_metric_multiple_granularities__plan0.sql | 2 +- .../test_offset_to_grain_with_agg_time_dim__plan0.sql | 2 +- ...et_window_metric_multiple_granularities__plan0.sql | 2 +- .../test_offset_window_with_agg_time_dim__plan0.sql | 2 +- ...time_offset_metric_with_time_constraint__plan0.sql | 2 +- ...time_offset_metric_with_time_constraint__plan0.sql | 2 +- ..._with_month_dimension_and_offset_window__plan0.sql | 2 +- ...h_dimension_and_offset_window__plan0_optimized.sql | 2 +- ...est_derived_metric_with_offset_to_grain__plan0.sql | 2 +- .../test_derived_metric_with_offset_window__plan0.sql | 2 +- ..._with_offset_window_and_offset_to_grain__plan0.sql | 4 ++-- ...tric_with_offset_window_and_time_filter__plan0.sql | 2 +- .../test_derived_offset_cumulative_metric__plan0.sql | 2 +- ...derived_offset_metric_with_agg_time_dim__plan0.sql | 2 +- ...ved_offset_metric_with_one_input_metric__plan0.sql | 2 +- ...th_joined_where_constraint_not_selected__plan0.sql | 2 +- .../SqlPlan/Snowflake/test_nested_offsets__plan0.sql | 2 +- ...est_nested_offsets_with_time_constraint__plan0.sql | 2 +- ...st_nested_offsets_with_where_constraint__plan0.sql | 2 +- ..._to_grain_metric_multiple_granularities__plan0.sql | 2 +- .../test_offset_to_grain_with_agg_time_dim__plan0.sql | 2 +- ...et_window_metric_multiple_granularities__plan0.sql | 2 +- .../test_offset_window_with_agg_time_dim__plan0.sql | 2 +- ...time_offset_metric_with_time_constraint__plan0.sql | 2 +- ...time_offset_metric_with_time_constraint__plan0.sql | 2 +- ..._with_month_dimension_and_offset_window__plan0.sql | 2 +- ...h_dimension_and_offset_window__plan0_optimized.sql | 2 +- ...est_derived_metric_with_offset_to_grain__plan0.sql | 2 +- .../test_derived_metric_with_offset_window__plan0.sql | 2 +- ..._with_offset_window_and_offset_to_grain__plan0.sql | 4 ++-- ...tric_with_offset_window_and_time_filter__plan0.sql | 2 +- .../test_derived_offset_cumulative_metric__plan0.sql | 2 +- ...derived_offset_metric_with_agg_time_dim__plan0.sql | 2 +- ...ved_offset_metric_with_one_input_metric__plan0.sql | 2 +- ...th_joined_where_constraint_not_selected__plan0.sql | 2 +- .../SqlPlan/Trino/test_nested_offsets__plan0.sql | 2 +- ...est_nested_offsets_with_time_constraint__plan0.sql | 2 +- ...st_nested_offsets_with_where_constraint__plan0.sql | 2 +- ..._to_grain_metric_multiple_granularities__plan0.sql | 2 +- .../test_offset_to_grain_with_agg_time_dim__plan0.sql | 2 +- ...et_window_metric_multiple_granularities__plan0.sql | 2 +- .../test_offset_window_with_agg_time_dim__plan0.sql | 2 +- ...time_offset_metric_with_time_constraint__plan0.sql | 2 +- ...derived_fill_nulls_for_one_input_metric__plan0.sql | 2 +- ...derived_fill_nulls_for_one_input_metric__plan0.sql | 2 +- ...derived_fill_nulls_for_one_input_metric__plan0.sql | 2 +- ...derived_fill_nulls_for_one_input_metric__plan0.sql | 2 +- ...derived_fill_nulls_for_one_input_metric__plan0.sql | 2 +- ...derived_fill_nulls_for_one_input_metric__plan0.sql | 2 +- ...derived_fill_nulls_for_one_input_metric__plan0.sql | 2 +- .../test_subdaily_offset_to_grain_metric__plan0.sql | 2 +- .../test_subdaily_offset_window_metric__plan0.sql | 2 +- .../test_subdaily_offset_to_grain_metric__plan0.sql | 2 +- .../test_subdaily_offset_window_metric__plan0.sql | 2 +- .../test_subdaily_offset_to_grain_metric__plan0.sql | 2 +- .../test_subdaily_offset_window_metric__plan0.sql | 2 +- .../test_subdaily_offset_to_grain_metric__plan0.sql | 2 +- .../test_subdaily_offset_window_metric__plan0.sql | 2 +- .../test_subdaily_offset_to_grain_metric__plan0.sql | 2 +- .../test_subdaily_offset_window_metric__plan0.sql | 2 +- .../test_subdaily_offset_to_grain_metric__plan0.sql | 2 +- .../test_subdaily_offset_window_metric__plan0.sql | 2 +- .../test_subdaily_offset_to_grain_metric__plan0.sql | 2 +- .../test_subdaily_offset_window_metric__plan0.sql | 2 +- ...ls_time_spine_metric_predicate_pushdown__plan0.sql | 2 +- ...t_offset_metric_with_query_time_filters__plan0.sql | 2 +- ...ls_time_spine_metric_predicate_pushdown__plan0.sql | 2 +- ...t_offset_metric_with_query_time_filters__plan0.sql | 2 +- ...ls_time_spine_metric_predicate_pushdown__plan0.sql | 2 +- ...t_offset_metric_with_query_time_filters__plan0.sql | 2 +- ...ls_time_spine_metric_predicate_pushdown__plan0.sql | 2 +- ...t_offset_metric_with_query_time_filters__plan0.sql | 2 +- ...ls_time_spine_metric_predicate_pushdown__plan0.sql | 2 +- ...t_offset_metric_with_query_time_filters__plan0.sql | 2 +- ...ls_time_spine_metric_predicate_pushdown__plan0.sql | 2 +- ...t_offset_metric_with_query_time_filters__plan0.sql | 2 +- ...ls_time_spine_metric_predicate_pushdown__plan0.sql | 2 +- ...t_offset_metric_with_query_time_filters__plan0.sql | 2 +- 188 files changed, 197 insertions(+), 228 deletions(-) diff --git a/metricflow/dataflow/builder/dataflow_plan_builder.py b/metricflow/dataflow/builder/dataflow_plan_builder.py index d433dd11ed..b44271fa9c 100644 --- a/metricflow/dataflow/builder/dataflow_plan_builder.py +++ b/metricflow/dataflow/builder/dataflow_plan_builder.py @@ -1648,7 +1648,9 @@ def _build_aggregated_measure_from_measure_source_node( join_on_time_dimension_spec = self._determine_time_spine_join_spec( measure_properties=measure_properties, required_time_spine_specs=base_queried_agg_time_dimension_specs ) - required_time_spine_specs = (join_on_time_dimension_spec,) + base_queried_agg_time_dimension_specs + required_time_spine_specs = base_queried_agg_time_dimension_specs + if join_on_time_dimension_spec not in required_time_spine_specs: + required_time_spine_specs = (join_on_time_dimension_spec,) + required_time_spine_specs time_spine_node = self._build_time_spine_node(required_time_spine_specs) unaggregated_measure_node = JoinToTimeSpineNode.create( metric_source_node=unaggregated_measure_node, diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_offset_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_offset_metric_with_custom_granularity__plan0.sql index dd363fffeb..552c5efa4b 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_offset_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_offset_metric_with_custom_granularity__plan0.sql @@ -125,7 +125,7 @@ FROM ( , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 , subq_5.martian_day AS booking__ds__martian_day FROM ( - -- Pass Only Elements: ['booking__ds__day', 'booking__ds__day'] + -- Pass Only Elements: ['booking__ds__day',] SELECT subq_3.booking__ds__day FROM ( diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql index 3af790768f..a46ecff07f 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql @@ -227,7 +227,7 @@ FROM ( , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 , subq_5.martian_day AS metric_time__martian_day FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_offset_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_offset_metric_with_custom_granularity__plan0.sql index 36ad1a6ad1..fd87887011 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_offset_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_offset_metric_with_custom_granularity__plan0.sql @@ -125,7 +125,7 @@ FROM ( , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 , subq_5.martian_day AS booking__ds__martian_day FROM ( - -- Pass Only Elements: ['booking__ds__day', 'booking__ds__day'] + -- Pass Only Elements: ['booking__ds__day',] SELECT subq_3.booking__ds__day FROM ( diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql index dbb7f8f76c..5892c86481 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql @@ -227,7 +227,7 @@ FROM ( , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 , subq_5.martian_day AS metric_time__martian_day FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/DuckDB/test_offset_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/DuckDB/test_offset_metric_with_custom_granularity__plan0.sql index 148415502e..dd4cbe20bc 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/DuckDB/test_offset_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/DuckDB/test_offset_metric_with_custom_granularity__plan0.sql @@ -125,7 +125,7 @@ FROM ( , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 , subq_5.martian_day AS booking__ds__martian_day FROM ( - -- Pass Only Elements: ['booking__ds__day', 'booking__ds__day'] + -- Pass Only Elements: ['booking__ds__day',] SELECT subq_3.booking__ds__day FROM ( diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/DuckDB/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/DuckDB/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql index 20b1277d85..3473cd4326 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/DuckDB/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/DuckDB/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql @@ -227,7 +227,7 @@ FROM ( , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 , subq_5.martian_day AS metric_time__martian_day FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_offset_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_offset_metric_with_custom_granularity__plan0.sql index 834b5c7745..d9cef04a19 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_offset_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_offset_metric_with_custom_granularity__plan0.sql @@ -125,7 +125,7 @@ FROM ( , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 , subq_5.martian_day AS booking__ds__martian_day FROM ( - -- Pass Only Elements: ['booking__ds__day', 'booking__ds__day'] + -- Pass Only Elements: ['booking__ds__day',] SELECT subq_3.booking__ds__day FROM ( diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql index ed4275bd85..b52b9bc338 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql @@ -227,7 +227,7 @@ FROM ( , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 , subq_5.martian_day AS metric_time__martian_day FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_offset_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_offset_metric_with_custom_granularity__plan0.sql index b546105465..c8459b66b3 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_offset_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_offset_metric_with_custom_granularity__plan0.sql @@ -125,7 +125,7 @@ FROM ( , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 , subq_5.martian_day AS booking__ds__martian_day FROM ( - -- Pass Only Elements: ['booking__ds__day', 'booking__ds__day'] + -- Pass Only Elements: ['booking__ds__day',] SELECT subq_3.booking__ds__day FROM ( diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql index 6ec746b0f3..6de48f897b 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql @@ -227,7 +227,7 @@ FROM ( , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 , subq_5.martian_day AS metric_time__martian_day FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_offset_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_offset_metric_with_custom_granularity__plan0.sql index dce8e75e51..d703f639de 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_offset_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_offset_metric_with_custom_granularity__plan0.sql @@ -125,7 +125,7 @@ FROM ( , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 , subq_5.martian_day AS booking__ds__martian_day FROM ( - -- Pass Only Elements: ['booking__ds__day', 'booking__ds__day'] + -- Pass Only Elements: ['booking__ds__day',] SELECT subq_3.booking__ds__day FROM ( diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql index 5ef70929cd..a8ab582bf5 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql @@ -227,7 +227,7 @@ FROM ( , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 , subq_5.martian_day AS metric_time__martian_day FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_offset_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_offset_metric_with_custom_granularity__plan0.sql index 250860a3f6..f9a5269117 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_offset_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_offset_metric_with_custom_granularity__plan0.sql @@ -125,7 +125,7 @@ FROM ( , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 , subq_5.martian_day AS booking__ds__martian_day FROM ( - -- Pass Only Elements: ['booking__ds__day', 'booking__ds__day'] + -- Pass Only Elements: ['booking__ds__day',] SELECT subq_3.booking__ds__day FROM ( diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql index 36594c1aa4..757bdb9b86 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql @@ -227,7 +227,7 @@ FROM ( , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 , subq_5.martian_day AS metric_time__martian_day FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_to_grain__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_to_grain__dfp_0.xml index 2aa21a5915..e26b2f6dc2 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_to_grain__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_to_grain__dfp_0.xml @@ -96,18 +96,13 @@ docstring: - + - - - - - diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_window__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_window__dfp_0.xml index 3205a56667..f7436df3c7 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_window__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_window__dfp_0.xml @@ -62,18 +62,13 @@ docstring: - + - - - - - diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_offset_cumulative_metric__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_offset_cumulative_metric__dfp_0.xml index 2e15cc47f5..d26968121f 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_offset_cumulative_metric__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_offset_cumulative_metric__dfp_0.xml @@ -73,18 +73,13 @@ test_filename: test_dataflow_plan_builder.py - + - - - - - diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_derived_metric__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_derived_metric__dfp_0.xml index 673f4b0e43..50bcb8aec1 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_derived_metric__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_derived_metric__dfp_0.xml @@ -169,8 +169,7 @@ test_filename: test_dataflow_plan_builder.py - - + @@ -180,14 +179,6 @@ test_filename: test_dataflow_plan_builder.py - - - - - - - - diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_nested_derived_metric_with_outer_offset__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_nested_derived_metric_with_outer_offset__dfp_0.xml index a940f96ca4..5bd7132c39 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_nested_derived_metric_with_outer_offset__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_nested_derived_metric_with_outer_offset__dfp_0.xml @@ -85,8 +85,7 @@ test_filename: test_dataflow_plan_builder.py - - + @@ -96,14 +95,6 @@ test_filename: test_dataflow_plan_builder.py - - - - - - - - diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql index c870939a85..392c825e8e 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql @@ -224,7 +224,7 @@ FROM ( , subq_4.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_4.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_6.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql index 6cd456a008..886da3fb21 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql @@ -46,7 +46,7 @@ FROM ( , subq_1.booking_monthly__listing AS booking_monthly__listing , subq_1.bookings_monthly AS bookings_monthly FROM ( - -- Pass Only Elements: ['metric_time__month', 'metric_time__month'] + -- Pass Only Elements: ['metric_time__month',] SELECT subq_3.metric_time__month FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql index 752fc1ea35..5e87039c38 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql @@ -17,7 +17,7 @@ FROM ( FROM ( -- Read From Time Spine 'mf_time_spine' -- Change Column Aliases - -- Pass Only Elements: ['metric_time__month', 'metric_time__month'] + -- Pass Only Elements: ['metric_time__month',] SELECT DATETIME_TRUNC(ds, month) AS metric_time__month FROM ***************************.mf_time_spine time_spine_src_16006 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_metric_with_offset_to_grain__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_metric_with_offset_to_grain__plan0.sql index 932bdb189a..cb02730ec3 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_metric_with_offset_to_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_metric_with_offset_to_grain__plan0.sql @@ -344,7 +344,7 @@ FROM ( , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_8.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_metric_with_offset_window__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_metric_with_offset_window__plan0.sql index 9d47f829b2..4106bee37e 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_metric_with_offset_window__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_metric_with_offset_window__plan0.sql @@ -344,7 +344,7 @@ FROM ( , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_8.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql index 0dd7b5f393..b883834851 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql @@ -129,7 +129,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( @@ -486,7 +486,7 @@ FROM ( , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_12.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_metric_with_offset_window_and_time_filter__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_metric_with_offset_window_and_time_filter__plan0.sql index 1f61be8a86..281aeeb2fb 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_metric_with_offset_window_and_time_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_metric_with_offset_window_and_time_filter__plan0.sql @@ -548,7 +548,7 @@ FROM ( , subq_7.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_7.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_9.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_offset_cumulative_metric__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_offset_cumulative_metric__plan0.sql index ff91d278f4..826fd17caf 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_offset_cumulative_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_offset_cumulative_metric__plan0.sql @@ -123,7 +123,7 @@ FROM ( , subq_4.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_4.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_6.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_offset_metric_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_offset_metric_with_agg_time_dim__plan0.sql index f0b88193cf..bc2b8f1fc1 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_offset_metric_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_offset_metric_with_agg_time_dim__plan0.sql @@ -129,7 +129,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['booking__ds__day', 'booking__ds__day'] + -- Pass Only Elements: ['booking__ds__day',] SELECT subq_3.booking__ds__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_offset_metric_with_one_input_metric__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_offset_metric_with_one_input_metric__plan0.sql index dda2283a04..dfe24ce6c8 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_offset_metric_with_one_input_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_offset_metric_with_one_input_metric__plan0.sql @@ -123,7 +123,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql index 52b10c46e1..740c5e0924 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql @@ -187,7 +187,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_nested_offsets__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_nested_offsets__plan0.sql index 9ba2d1f904..27d43dd31b 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_nested_offsets__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_nested_offsets__plan0.sql @@ -171,7 +171,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_nested_offsets_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_nested_offsets_with_time_constraint__plan0.sql index 7c1d42554a..288e92c3e7 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_nested_offsets_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_nested_offsets_with_time_constraint__plan0.sql @@ -176,7 +176,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_nested_offsets_with_where_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_nested_offsets_with_where_constraint__plan0.sql index 4685f9d783..83f24cc422 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_nested_offsets_with_where_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_nested_offsets_with_where_constraint__plan0.sql @@ -176,7 +176,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_offset_to_grain_metric_multiple_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_offset_to_grain_metric_multiple_granularities__plan0.sql index 52142a1cb9..e8d3345c51 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_offset_to_grain_metric_multiple_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_offset_to_grain_metric_multiple_granularities__plan0.sql @@ -133,7 +133,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day', 'metric_time__month', 'metric_time__year'] + -- Pass Only Elements: ['metric_time__day', 'metric_time__month', 'metric_time__year'] SELECT subq_3.metric_time__day , subq_3.metric_time__month diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_offset_to_grain_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_offset_to_grain_with_agg_time_dim__plan0.sql index 5d2f34ec77..b293f522e8 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_offset_to_grain_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_offset_to_grain_with_agg_time_dim__plan0.sql @@ -344,7 +344,7 @@ FROM ( , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['booking__ds__day', 'booking__ds__day'] + -- Pass Only Elements: ['booking__ds__day',] SELECT subq_8.booking__ds__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_offset_window_metric_multiple_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_offset_window_metric_multiple_granularities__plan0.sql index 49e10bf041..78efe08e85 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_offset_window_metric_multiple_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_offset_window_metric_multiple_granularities__plan0.sql @@ -141,7 +141,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day', 'metric_time__month', 'metric_time__year'] + -- Pass Only Elements: ['metric_time__day', 'metric_time__month', 'metric_time__year'] SELECT subq_3.metric_time__day , subq_3.metric_time__month diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_offset_window_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_offset_window_with_agg_time_dim__plan0.sql index bbcc82dd47..9a73912bdd 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_offset_window_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_offset_window_with_agg_time_dim__plan0.sql @@ -344,7 +344,7 @@ FROM ( , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['booking__ds__day', 'booking__ds__day'] + -- Pass Only Elements: ['booking__ds__day',] SELECT subq_8.booking__ds__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_time_offset_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_time_offset_metric_with_time_constraint__plan0.sql index ce8acd3447..2788f84eaf 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_time_offset_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_time_offset_metric_with_time_constraint__plan0.sql @@ -224,7 +224,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql index b2d1cd36da..bb9aa649a8 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql @@ -224,7 +224,7 @@ FROM ( , subq_4.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_4.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_6.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql index 633620fbbd..53b9e469a9 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql @@ -46,7 +46,7 @@ FROM ( , subq_1.booking_monthly__listing AS booking_monthly__listing , subq_1.bookings_monthly AS bookings_monthly FROM ( - -- Pass Only Elements: ['metric_time__month', 'metric_time__month'] + -- Pass Only Elements: ['metric_time__month',] SELECT subq_3.metric_time__month FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql index 3c56987018..a85c98f33a 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql @@ -17,7 +17,7 @@ FROM ( FROM ( -- Read From Time Spine 'mf_time_spine' -- Change Column Aliases - -- Pass Only Elements: ['metric_time__month', 'metric_time__month'] + -- Pass Only Elements: ['metric_time__month',] SELECT DATE_TRUNC('month', ds) AS metric_time__month FROM ***************************.mf_time_spine time_spine_src_16006 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_metric_with_offset_to_grain__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_metric_with_offset_to_grain__plan0.sql index 62cb64cb4f..ea77959c21 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_metric_with_offset_to_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_metric_with_offset_to_grain__plan0.sql @@ -344,7 +344,7 @@ FROM ( , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_8.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_metric_with_offset_window__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_metric_with_offset_window__plan0.sql index 40d1ffbeab..29fdeacc00 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_metric_with_offset_window__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_metric_with_offset_window__plan0.sql @@ -344,7 +344,7 @@ FROM ( , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_8.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql index d2ca6e6602..82efce9a6e 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql @@ -129,7 +129,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( @@ -486,7 +486,7 @@ FROM ( , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_12.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_metric_with_offset_window_and_time_filter__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_metric_with_offset_window_and_time_filter__plan0.sql index 8657d58874..170d3525b9 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_metric_with_offset_window_and_time_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_metric_with_offset_window_and_time_filter__plan0.sql @@ -548,7 +548,7 @@ FROM ( , subq_7.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_7.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_9.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_offset_cumulative_metric__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_offset_cumulative_metric__plan0.sql index d4096225ae..3a0e5e9cf1 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_offset_cumulative_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_offset_cumulative_metric__plan0.sql @@ -123,7 +123,7 @@ FROM ( , subq_4.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_4.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_6.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_offset_metric_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_offset_metric_with_agg_time_dim__plan0.sql index f51cbe6b47..c9ffdd9e56 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_offset_metric_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_offset_metric_with_agg_time_dim__plan0.sql @@ -129,7 +129,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['booking__ds__day', 'booking__ds__day'] + -- Pass Only Elements: ['booking__ds__day',] SELECT subq_3.booking__ds__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_offset_metric_with_one_input_metric__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_offset_metric_with_one_input_metric__plan0.sql index 67e939c1e7..f32a05793e 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_offset_metric_with_one_input_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_offset_metric_with_one_input_metric__plan0.sql @@ -123,7 +123,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql index 128444fb48..9160851e2e 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql @@ -187,7 +187,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_nested_offsets__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_nested_offsets__plan0.sql index 3e48bc15a5..57354fbbe8 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_nested_offsets__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_nested_offsets__plan0.sql @@ -171,7 +171,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_nested_offsets_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_nested_offsets_with_time_constraint__plan0.sql index 9017891e14..64047eb968 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_nested_offsets_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_nested_offsets_with_time_constraint__plan0.sql @@ -176,7 +176,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_nested_offsets_with_where_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_nested_offsets_with_where_constraint__plan0.sql index b271d5f6d3..ec5c5bfd6a 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_nested_offsets_with_where_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_nested_offsets_with_where_constraint__plan0.sql @@ -176,7 +176,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_offset_to_grain_metric_multiple_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_offset_to_grain_metric_multiple_granularities__plan0.sql index 45777e8389..c460959fa2 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_offset_to_grain_metric_multiple_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_offset_to_grain_metric_multiple_granularities__plan0.sql @@ -133,7 +133,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day', 'metric_time__month', 'metric_time__year'] + -- Pass Only Elements: ['metric_time__day', 'metric_time__month', 'metric_time__year'] SELECT subq_3.metric_time__day , subq_3.metric_time__month diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_offset_to_grain_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_offset_to_grain_with_agg_time_dim__plan0.sql index 24ae48d259..df3e245118 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_offset_to_grain_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_offset_to_grain_with_agg_time_dim__plan0.sql @@ -344,7 +344,7 @@ FROM ( , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['booking__ds__day', 'booking__ds__day'] + -- Pass Only Elements: ['booking__ds__day',] SELECT subq_8.booking__ds__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_offset_window_metric_multiple_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_offset_window_metric_multiple_granularities__plan0.sql index 6134a9a518..9286cff132 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_offset_window_metric_multiple_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_offset_window_metric_multiple_granularities__plan0.sql @@ -141,7 +141,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day', 'metric_time__month', 'metric_time__year'] + -- Pass Only Elements: ['metric_time__day', 'metric_time__month', 'metric_time__year'] SELECT subq_3.metric_time__day , subq_3.metric_time__month diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_offset_window_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_offset_window_with_agg_time_dim__plan0.sql index e6275211b1..84226e3e25 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_offset_window_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_offset_window_with_agg_time_dim__plan0.sql @@ -344,7 +344,7 @@ FROM ( , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['booking__ds__day', 'booking__ds__day'] + -- Pass Only Elements: ['booking__ds__day',] SELECT subq_8.booking__ds__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_time_offset_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_time_offset_metric_with_time_constraint__plan0.sql index c3ac2ca2d4..62c858e649 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_time_offset_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_time_offset_metric_with_time_constraint__plan0.sql @@ -224,7 +224,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql index 9fb1b5357e..cbe0b5170b 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql @@ -224,7 +224,7 @@ FROM ( , subq_4.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_4.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_6.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql index 38fb759489..2aee922b30 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql @@ -46,7 +46,7 @@ FROM ( , subq_1.booking_monthly__listing AS booking_monthly__listing , subq_1.bookings_monthly AS bookings_monthly FROM ( - -- Pass Only Elements: ['metric_time__month', 'metric_time__month'] + -- Pass Only Elements: ['metric_time__month',] SELECT subq_3.metric_time__month FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql index c4e603d75e..53a6abf7e9 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql @@ -17,7 +17,7 @@ FROM ( FROM ( -- Read From Time Spine 'mf_time_spine' -- Change Column Aliases - -- Pass Only Elements: ['metric_time__month', 'metric_time__month'] + -- Pass Only Elements: ['metric_time__month',] SELECT DATE_TRUNC('month', ds) AS metric_time__month FROM ***************************.mf_time_spine time_spine_src_16006 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_offset_to_grain__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_offset_to_grain__plan0.sql index 74b6d0a8aa..cbb9ee4065 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_offset_to_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_offset_to_grain__plan0.sql @@ -344,7 +344,7 @@ FROM ( , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_8.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_offset_window__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_offset_window__plan0.sql index 23b51230bd..46c6801cfb 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_offset_window__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_offset_window__plan0.sql @@ -344,7 +344,7 @@ FROM ( , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_8.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql index 067132e105..6f00c47348 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql @@ -129,7 +129,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( @@ -486,7 +486,7 @@ FROM ( , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_12.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_offset_window_and_time_filter__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_offset_window_and_time_filter__plan0.sql index 68adc9df28..444aa8d6ed 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_offset_window_and_time_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_offset_window_and_time_filter__plan0.sql @@ -548,7 +548,7 @@ FROM ( , subq_7.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_7.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_9.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_offset_cumulative_metric__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_offset_cumulative_metric__plan0.sql index 0b939c32fd..bbcea069fe 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_offset_cumulative_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_offset_cumulative_metric__plan0.sql @@ -123,7 +123,7 @@ FROM ( , subq_4.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_4.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_6.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_offset_metric_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_offset_metric_with_agg_time_dim__plan0.sql index a1be9bcd30..a2cfc20182 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_offset_metric_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_offset_metric_with_agg_time_dim__plan0.sql @@ -129,7 +129,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['booking__ds__day', 'booking__ds__day'] + -- Pass Only Elements: ['booking__ds__day',] SELECT subq_3.booking__ds__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_offset_metric_with_one_input_metric__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_offset_metric_with_one_input_metric__plan0.sql index ae7f93f3a0..f4ad8b174b 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_offset_metric_with_one_input_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_offset_metric_with_one_input_metric__plan0.sql @@ -123,7 +123,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql index 113c469f62..98e30cf757 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql @@ -187,7 +187,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_offsets__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_offsets__plan0.sql index 38289e3485..269c143dd4 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_offsets__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_offsets__plan0.sql @@ -171,7 +171,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_offsets_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_offsets_with_time_constraint__plan0.sql index 039c8b9ec6..1c43bd33e0 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_offsets_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_offsets_with_time_constraint__plan0.sql @@ -176,7 +176,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_offsets_with_where_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_offsets_with_where_constraint__plan0.sql index e792f137ec..7146a8aaf8 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_offsets_with_where_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_offsets_with_where_constraint__plan0.sql @@ -176,7 +176,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_offset_to_grain_metric_multiple_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_offset_to_grain_metric_multiple_granularities__plan0.sql index 6fd81d09c8..7ff287fbf9 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_offset_to_grain_metric_multiple_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_offset_to_grain_metric_multiple_granularities__plan0.sql @@ -133,7 +133,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day', 'metric_time__month', 'metric_time__year'] + -- Pass Only Elements: ['metric_time__day', 'metric_time__month', 'metric_time__year'] SELECT subq_3.metric_time__day , subq_3.metric_time__month diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_offset_to_grain_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_offset_to_grain_with_agg_time_dim__plan0.sql index f1e8089cd5..794c43a76e 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_offset_to_grain_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_offset_to_grain_with_agg_time_dim__plan0.sql @@ -344,7 +344,7 @@ FROM ( , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['booking__ds__day', 'booking__ds__day'] + -- Pass Only Elements: ['booking__ds__day',] SELECT subq_8.booking__ds__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_offset_window_metric_multiple_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_offset_window_metric_multiple_granularities__plan0.sql index 7a8245bafb..9f27bbfd82 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_offset_window_metric_multiple_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_offset_window_metric_multiple_granularities__plan0.sql @@ -141,7 +141,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day', 'metric_time__month', 'metric_time__year'] + -- Pass Only Elements: ['metric_time__day', 'metric_time__month', 'metric_time__year'] SELECT subq_3.metric_time__day , subq_3.metric_time__month diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_offset_window_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_offset_window_with_agg_time_dim__plan0.sql index f8ed01d492..d0a69d1936 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_offset_window_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_offset_window_with_agg_time_dim__plan0.sql @@ -344,7 +344,7 @@ FROM ( , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['booking__ds__day', 'booking__ds__day'] + -- Pass Only Elements: ['booking__ds__day',] SELECT subq_8.booking__ds__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_time_offset_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_time_offset_metric_with_time_constraint__plan0.sql index ea7be636da..e05b1169fd 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_time_offset_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_time_offset_metric_with_time_constraint__plan0.sql @@ -224,7 +224,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql index 27c5a3b0c7..1377e83753 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql @@ -224,7 +224,7 @@ FROM ( , subq_4.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_4.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_6.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql index 52652753fc..823bb85c29 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql @@ -46,7 +46,7 @@ FROM ( , subq_1.booking_monthly__listing AS booking_monthly__listing , subq_1.bookings_monthly AS bookings_monthly FROM ( - -- Pass Only Elements: ['metric_time__month', 'metric_time__month'] + -- Pass Only Elements: ['metric_time__month',] SELECT subq_3.metric_time__month FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql index 6fbfe61c40..bb03e4124e 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql @@ -17,7 +17,7 @@ FROM ( FROM ( -- Read From Time Spine 'mf_time_spine' -- Change Column Aliases - -- Pass Only Elements: ['metric_time__month', 'metric_time__month'] + -- Pass Only Elements: ['metric_time__month',] SELECT DATE_TRUNC('month', ds) AS metric_time__month FROM ***************************.mf_time_spine time_spine_src_16006 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_metric_with_offset_to_grain__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_metric_with_offset_to_grain__plan0.sql index 1772e56254..bdf00c3302 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_metric_with_offset_to_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_metric_with_offset_to_grain__plan0.sql @@ -344,7 +344,7 @@ FROM ( , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_8.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_metric_with_offset_window__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_metric_with_offset_window__plan0.sql index 1218c85662..b0554af3a0 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_metric_with_offset_window__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_metric_with_offset_window__plan0.sql @@ -344,7 +344,7 @@ FROM ( , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_8.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql index 9282c1f8de..dfe04fb1d7 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql @@ -129,7 +129,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( @@ -486,7 +486,7 @@ FROM ( , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_12.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_metric_with_offset_window_and_time_filter__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_metric_with_offset_window_and_time_filter__plan0.sql index 1e94370ec0..66842ab22f 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_metric_with_offset_window_and_time_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_metric_with_offset_window_and_time_filter__plan0.sql @@ -548,7 +548,7 @@ FROM ( , subq_7.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_7.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_9.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_offset_cumulative_metric__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_offset_cumulative_metric__plan0.sql index 81780b704b..b1bf91c5de 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_offset_cumulative_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_offset_cumulative_metric__plan0.sql @@ -123,7 +123,7 @@ FROM ( , subq_4.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_4.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_6.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_offset_metric_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_offset_metric_with_agg_time_dim__plan0.sql index d51c12f2c5..c30d41adc3 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_offset_metric_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_offset_metric_with_agg_time_dim__plan0.sql @@ -129,7 +129,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['booking__ds__day', 'booking__ds__day'] + -- Pass Only Elements: ['booking__ds__day',] SELECT subq_3.booking__ds__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_offset_metric_with_one_input_metric__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_offset_metric_with_one_input_metric__plan0.sql index 68e5b6bd63..95958182e1 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_offset_metric_with_one_input_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_offset_metric_with_one_input_metric__plan0.sql @@ -123,7 +123,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql index a2831e873c..c132d529df 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql @@ -187,7 +187,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_nested_offsets__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_nested_offsets__plan0.sql index dc5bfedf27..35d21b76e4 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_nested_offsets__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_nested_offsets__plan0.sql @@ -171,7 +171,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_nested_offsets_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_nested_offsets_with_time_constraint__plan0.sql index f19462ecb7..e63d875d5f 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_nested_offsets_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_nested_offsets_with_time_constraint__plan0.sql @@ -176,7 +176,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_nested_offsets_with_where_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_nested_offsets_with_where_constraint__plan0.sql index d05ab1a1e6..812aad5a59 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_nested_offsets_with_where_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_nested_offsets_with_where_constraint__plan0.sql @@ -176,7 +176,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_offset_to_grain_metric_multiple_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_offset_to_grain_metric_multiple_granularities__plan0.sql index 5f35ae002c..95fe4e8e8a 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_offset_to_grain_metric_multiple_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_offset_to_grain_metric_multiple_granularities__plan0.sql @@ -133,7 +133,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day', 'metric_time__month', 'metric_time__year'] + -- Pass Only Elements: ['metric_time__day', 'metric_time__month', 'metric_time__year'] SELECT subq_3.metric_time__day , subq_3.metric_time__month diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_offset_to_grain_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_offset_to_grain_with_agg_time_dim__plan0.sql index 5107423103..d593adb99c 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_offset_to_grain_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_offset_to_grain_with_agg_time_dim__plan0.sql @@ -344,7 +344,7 @@ FROM ( , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['booking__ds__day', 'booking__ds__day'] + -- Pass Only Elements: ['booking__ds__day',] SELECT subq_8.booking__ds__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_offset_window_metric_multiple_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_offset_window_metric_multiple_granularities__plan0.sql index 0eccdef2c0..e0a8b5ff0a 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_offset_window_metric_multiple_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_offset_window_metric_multiple_granularities__plan0.sql @@ -141,7 +141,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day', 'metric_time__month', 'metric_time__year'] + -- Pass Only Elements: ['metric_time__day', 'metric_time__month', 'metric_time__year'] SELECT subq_3.metric_time__day , subq_3.metric_time__month diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_offset_window_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_offset_window_with_agg_time_dim__plan0.sql index 6bd0776312..8e4b02cef5 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_offset_window_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_offset_window_with_agg_time_dim__plan0.sql @@ -344,7 +344,7 @@ FROM ( , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['booking__ds__day', 'booking__ds__day'] + -- Pass Only Elements: ['booking__ds__day',] SELECT subq_8.booking__ds__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_time_offset_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_time_offset_metric_with_time_constraint__plan0.sql index 854d7480ed..e1e9159464 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_time_offset_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_time_offset_metric_with_time_constraint__plan0.sql @@ -224,7 +224,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql index 56020f2e92..bc5bcbf4f0 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql @@ -224,7 +224,7 @@ FROM ( , subq_4.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_4.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_6.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql index 57d9183e45..cb9ab0f48d 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql @@ -46,7 +46,7 @@ FROM ( , subq_1.booking_monthly__listing AS booking_monthly__listing , subq_1.bookings_monthly AS bookings_monthly FROM ( - -- Pass Only Elements: ['metric_time__month', 'metric_time__month'] + -- Pass Only Elements: ['metric_time__month',] SELECT subq_3.metric_time__month FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql index 368f8bf285..662ad8f2d4 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql @@ -17,7 +17,7 @@ FROM ( FROM ( -- Read From Time Spine 'mf_time_spine' -- Change Column Aliases - -- Pass Only Elements: ['metric_time__month', 'metric_time__month'] + -- Pass Only Elements: ['metric_time__month',] SELECT DATE_TRUNC('month', ds) AS metric_time__month FROM ***************************.mf_time_spine time_spine_src_16006 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_metric_with_offset_to_grain__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_metric_with_offset_to_grain__plan0.sql index 182d26bf2a..297a143a60 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_metric_with_offset_to_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_metric_with_offset_to_grain__plan0.sql @@ -344,7 +344,7 @@ FROM ( , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_8.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_metric_with_offset_window__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_metric_with_offset_window__plan0.sql index 16189e9b54..85c222cb45 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_metric_with_offset_window__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_metric_with_offset_window__plan0.sql @@ -344,7 +344,7 @@ FROM ( , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_8.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql index a3c9ebfb72..f9eb103cf6 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql @@ -129,7 +129,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( @@ -486,7 +486,7 @@ FROM ( , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_12.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_metric_with_offset_window_and_time_filter__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_metric_with_offset_window_and_time_filter__plan0.sql index 8f2d254868..3b7dc37bb5 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_metric_with_offset_window_and_time_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_metric_with_offset_window_and_time_filter__plan0.sql @@ -548,7 +548,7 @@ FROM ( , subq_7.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_7.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_9.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_offset_cumulative_metric__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_offset_cumulative_metric__plan0.sql index 052ee5b70c..ac83145267 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_offset_cumulative_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_offset_cumulative_metric__plan0.sql @@ -123,7 +123,7 @@ FROM ( , subq_4.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_4.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_6.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_offset_metric_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_offset_metric_with_agg_time_dim__plan0.sql index 970b9208f5..5415829841 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_offset_metric_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_offset_metric_with_agg_time_dim__plan0.sql @@ -129,7 +129,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['booking__ds__day', 'booking__ds__day'] + -- Pass Only Elements: ['booking__ds__day',] SELECT subq_3.booking__ds__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_offset_metric_with_one_input_metric__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_offset_metric_with_one_input_metric__plan0.sql index 27725a5785..faa6b1d9a4 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_offset_metric_with_one_input_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_offset_metric_with_one_input_metric__plan0.sql @@ -123,7 +123,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql index a438b93bd0..8b3d5fa4d0 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql @@ -187,7 +187,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_nested_offsets__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_nested_offsets__plan0.sql index e21a9a6ab8..8cb3ef33af 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_nested_offsets__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_nested_offsets__plan0.sql @@ -171,7 +171,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_nested_offsets_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_nested_offsets_with_time_constraint__plan0.sql index 6e4db61962..887fca1822 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_nested_offsets_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_nested_offsets_with_time_constraint__plan0.sql @@ -176,7 +176,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_nested_offsets_with_where_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_nested_offsets_with_where_constraint__plan0.sql index a8689af3de..16c28ec040 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_nested_offsets_with_where_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_nested_offsets_with_where_constraint__plan0.sql @@ -176,7 +176,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_offset_to_grain_metric_multiple_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_offset_to_grain_metric_multiple_granularities__plan0.sql index 664e828140..0238b9c927 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_offset_to_grain_metric_multiple_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_offset_to_grain_metric_multiple_granularities__plan0.sql @@ -133,7 +133,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day', 'metric_time__month', 'metric_time__year'] + -- Pass Only Elements: ['metric_time__day', 'metric_time__month', 'metric_time__year'] SELECT subq_3.metric_time__day , subq_3.metric_time__month diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_offset_to_grain_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_offset_to_grain_with_agg_time_dim__plan0.sql index fdac00d4f2..2442119c48 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_offset_to_grain_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_offset_to_grain_with_agg_time_dim__plan0.sql @@ -344,7 +344,7 @@ FROM ( , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['booking__ds__day', 'booking__ds__day'] + -- Pass Only Elements: ['booking__ds__day',] SELECT subq_8.booking__ds__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_offset_window_metric_multiple_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_offset_window_metric_multiple_granularities__plan0.sql index b5fc46108d..1cb45a2c01 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_offset_window_metric_multiple_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_offset_window_metric_multiple_granularities__plan0.sql @@ -141,7 +141,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day', 'metric_time__month', 'metric_time__year'] + -- Pass Only Elements: ['metric_time__day', 'metric_time__month', 'metric_time__year'] SELECT subq_3.metric_time__day , subq_3.metric_time__month diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_offset_window_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_offset_window_with_agg_time_dim__plan0.sql index 6d69a19680..f270cccd0a 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_offset_window_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_offset_window_with_agg_time_dim__plan0.sql @@ -344,7 +344,7 @@ FROM ( , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['booking__ds__day', 'booking__ds__day'] + -- Pass Only Elements: ['booking__ds__day',] SELECT subq_8.booking__ds__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_time_offset_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_time_offset_metric_with_time_constraint__plan0.sql index b3dee58d70..bc86c55be9 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_time_offset_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_time_offset_metric_with_time_constraint__plan0.sql @@ -224,7 +224,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql index a93e601109..06451d1f30 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql @@ -224,7 +224,7 @@ FROM ( , subq_4.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_4.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_6.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql index 6b4b0ccc6d..ff52b01f7c 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql @@ -46,7 +46,7 @@ FROM ( , subq_1.booking_monthly__listing AS booking_monthly__listing , subq_1.bookings_monthly AS bookings_monthly FROM ( - -- Pass Only Elements: ['metric_time__month', 'metric_time__month'] + -- Pass Only Elements: ['metric_time__month',] SELECT subq_3.metric_time__month FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql index 37d9acb1c7..43dd566367 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql @@ -17,7 +17,7 @@ FROM ( FROM ( -- Read From Time Spine 'mf_time_spine' -- Change Column Aliases - -- Pass Only Elements: ['metric_time__month', 'metric_time__month'] + -- Pass Only Elements: ['metric_time__month',] SELECT DATE_TRUNC('month', ds) AS metric_time__month FROM ***************************.mf_time_spine time_spine_src_16006 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_metric_with_offset_to_grain__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_metric_with_offset_to_grain__plan0.sql index bb40e9625c..b91c6cd337 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_metric_with_offset_to_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_metric_with_offset_to_grain__plan0.sql @@ -344,7 +344,7 @@ FROM ( , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_8.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_metric_with_offset_window__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_metric_with_offset_window__plan0.sql index 3dcb28a78c..c335d68c13 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_metric_with_offset_window__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_metric_with_offset_window__plan0.sql @@ -344,7 +344,7 @@ FROM ( , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_8.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql index 65b53667ef..dd3fc6cf32 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql @@ -129,7 +129,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( @@ -486,7 +486,7 @@ FROM ( , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_12.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_metric_with_offset_window_and_time_filter__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_metric_with_offset_window_and_time_filter__plan0.sql index 4cd15174cb..bcea5b4f4f 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_metric_with_offset_window_and_time_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_metric_with_offset_window_and_time_filter__plan0.sql @@ -548,7 +548,7 @@ FROM ( , subq_7.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_7.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_9.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_offset_cumulative_metric__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_offset_cumulative_metric__plan0.sql index 6cdc822f78..660e38b393 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_offset_cumulative_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_offset_cumulative_metric__plan0.sql @@ -123,7 +123,7 @@ FROM ( , subq_4.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_4.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_6.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_offset_metric_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_offset_metric_with_agg_time_dim__plan0.sql index 724b912492..39422d8089 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_offset_metric_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_offset_metric_with_agg_time_dim__plan0.sql @@ -129,7 +129,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['booking__ds__day', 'booking__ds__day'] + -- Pass Only Elements: ['booking__ds__day',] SELECT subq_3.booking__ds__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_offset_metric_with_one_input_metric__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_offset_metric_with_one_input_metric__plan0.sql index e83b26a6f3..239b2f4df0 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_offset_metric_with_one_input_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_offset_metric_with_one_input_metric__plan0.sql @@ -123,7 +123,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql index da873f5dea..f1e239298e 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql @@ -187,7 +187,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_nested_offsets__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_nested_offsets__plan0.sql index f63d74d7d3..bd8b30335c 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_nested_offsets__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_nested_offsets__plan0.sql @@ -171,7 +171,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_nested_offsets_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_nested_offsets_with_time_constraint__plan0.sql index 612fdf2ffb..012960a45f 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_nested_offsets_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_nested_offsets_with_time_constraint__plan0.sql @@ -176,7 +176,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_nested_offsets_with_where_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_nested_offsets_with_where_constraint__plan0.sql index 83bae5fd79..025f16c110 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_nested_offsets_with_where_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_nested_offsets_with_where_constraint__plan0.sql @@ -176,7 +176,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_offset_to_grain_metric_multiple_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_offset_to_grain_metric_multiple_granularities__plan0.sql index f842a708d4..3809e8e337 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_offset_to_grain_metric_multiple_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_offset_to_grain_metric_multiple_granularities__plan0.sql @@ -133,7 +133,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day', 'metric_time__month', 'metric_time__year'] + -- Pass Only Elements: ['metric_time__day', 'metric_time__month', 'metric_time__year'] SELECT subq_3.metric_time__day , subq_3.metric_time__month diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_offset_to_grain_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_offset_to_grain_with_agg_time_dim__plan0.sql index 23a58321bd..a6946087fd 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_offset_to_grain_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_offset_to_grain_with_agg_time_dim__plan0.sql @@ -344,7 +344,7 @@ FROM ( , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['booking__ds__day', 'booking__ds__day'] + -- Pass Only Elements: ['booking__ds__day',] SELECT subq_8.booking__ds__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_offset_window_metric_multiple_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_offset_window_metric_multiple_granularities__plan0.sql index 44b1df1c8e..b3e9cc46ef 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_offset_window_metric_multiple_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_offset_window_metric_multiple_granularities__plan0.sql @@ -141,7 +141,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day', 'metric_time__month', 'metric_time__year'] + -- Pass Only Elements: ['metric_time__day', 'metric_time__month', 'metric_time__year'] SELECT subq_3.metric_time__day , subq_3.metric_time__month diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_offset_window_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_offset_window_with_agg_time_dim__plan0.sql index 9f75de0e79..d5dc66dbaf 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_offset_window_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_offset_window_with_agg_time_dim__plan0.sql @@ -344,7 +344,7 @@ FROM ( , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['booking__ds__day', 'booking__ds__day'] + -- Pass Only Elements: ['booking__ds__day',] SELECT subq_8.booking__ds__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_time_offset_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_time_offset_metric_with_time_constraint__plan0.sql index 1685d28609..3a632a068d 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_time_offset_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_time_offset_metric_with_time_constraint__plan0.sql @@ -224,7 +224,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql index ca7e2f5a6d..688fd14879 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql @@ -224,7 +224,7 @@ FROM ( , subq_4.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_4.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_6.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql index baa085b5ac..1ab71d23a6 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql @@ -46,7 +46,7 @@ FROM ( , subq_1.booking_monthly__listing AS booking_monthly__listing , subq_1.bookings_monthly AS bookings_monthly FROM ( - -- Pass Only Elements: ['metric_time__month', 'metric_time__month'] + -- Pass Only Elements: ['metric_time__month',] SELECT subq_3.metric_time__month FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql index e47cd140d8..777de00e77 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql @@ -17,7 +17,7 @@ FROM ( FROM ( -- Read From Time Spine 'mf_time_spine' -- Change Column Aliases - -- Pass Only Elements: ['metric_time__month', 'metric_time__month'] + -- Pass Only Elements: ['metric_time__month',] SELECT DATE_TRUNC('month', ds) AS metric_time__month FROM ***************************.mf_time_spine time_spine_src_16006 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_metric_with_offset_to_grain__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_metric_with_offset_to_grain__plan0.sql index 8e4ff62826..974bcff8cb 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_metric_with_offset_to_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_metric_with_offset_to_grain__plan0.sql @@ -344,7 +344,7 @@ FROM ( , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_8.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_metric_with_offset_window__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_metric_with_offset_window__plan0.sql index b7f3ccf9bb..049068f741 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_metric_with_offset_window__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_metric_with_offset_window__plan0.sql @@ -344,7 +344,7 @@ FROM ( , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_8.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql index 20c6c7373a..a50df5db2a 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql @@ -129,7 +129,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( @@ -486,7 +486,7 @@ FROM ( , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_12.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_metric_with_offset_window_and_time_filter__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_metric_with_offset_window_and_time_filter__plan0.sql index 4d1f913e66..1e0aae0f89 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_metric_with_offset_window_and_time_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_metric_with_offset_window_and_time_filter__plan0.sql @@ -548,7 +548,7 @@ FROM ( , subq_7.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_7.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_9.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_offset_cumulative_metric__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_offset_cumulative_metric__plan0.sql index 5bad02fcf4..c797e4a10e 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_offset_cumulative_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_offset_cumulative_metric__plan0.sql @@ -123,7 +123,7 @@ FROM ( , subq_4.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_4.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_6.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_offset_metric_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_offset_metric_with_agg_time_dim__plan0.sql index 5b66eba121..f5f78e3ec5 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_offset_metric_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_offset_metric_with_agg_time_dim__plan0.sql @@ -129,7 +129,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['booking__ds__day', 'booking__ds__day'] + -- Pass Only Elements: ['booking__ds__day',] SELECT subq_3.booking__ds__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_offset_metric_with_one_input_metric__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_offset_metric_with_one_input_metric__plan0.sql index ccc706a19d..ccbc2db8ec 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_offset_metric_with_one_input_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_offset_metric_with_one_input_metric__plan0.sql @@ -123,7 +123,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql index 78893ab73d..490d34cb74 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql @@ -187,7 +187,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_nested_offsets__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_nested_offsets__plan0.sql index bb5b0037bc..b379d71ffa 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_nested_offsets__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_nested_offsets__plan0.sql @@ -171,7 +171,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_nested_offsets_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_nested_offsets_with_time_constraint__plan0.sql index 3e86d584bc..25fc905cbe 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_nested_offsets_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_nested_offsets_with_time_constraint__plan0.sql @@ -176,7 +176,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_nested_offsets_with_where_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_nested_offsets_with_where_constraint__plan0.sql index 760def82c7..6a2f15f470 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_nested_offsets_with_where_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_nested_offsets_with_where_constraint__plan0.sql @@ -176,7 +176,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_offset_to_grain_metric_multiple_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_offset_to_grain_metric_multiple_granularities__plan0.sql index e535958381..cd7a91cacd 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_offset_to_grain_metric_multiple_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_offset_to_grain_metric_multiple_granularities__plan0.sql @@ -133,7 +133,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day', 'metric_time__month', 'metric_time__year'] + -- Pass Only Elements: ['metric_time__day', 'metric_time__month', 'metric_time__year'] SELECT subq_3.metric_time__day , subq_3.metric_time__month diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_offset_to_grain_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_offset_to_grain_with_agg_time_dim__plan0.sql index 15805d20ef..cfcdbc6a6c 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_offset_to_grain_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_offset_to_grain_with_agg_time_dim__plan0.sql @@ -344,7 +344,7 @@ FROM ( , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['booking__ds__day', 'booking__ds__day'] + -- Pass Only Elements: ['booking__ds__day',] SELECT subq_8.booking__ds__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_offset_window_metric_multiple_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_offset_window_metric_multiple_granularities__plan0.sql index a578445a7f..ef64a79e61 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_offset_window_metric_multiple_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_offset_window_metric_multiple_granularities__plan0.sql @@ -141,7 +141,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day', 'metric_time__month', 'metric_time__year'] + -- Pass Only Elements: ['metric_time__day', 'metric_time__month', 'metric_time__year'] SELECT subq_3.metric_time__day , subq_3.metric_time__month diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_offset_window_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_offset_window_with_agg_time_dim__plan0.sql index 6e306603fa..19c379d11f 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_offset_window_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_offset_window_with_agg_time_dim__plan0.sql @@ -344,7 +344,7 @@ FROM ( , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['booking__ds__day', 'booking__ds__day'] + -- Pass Only Elements: ['booking__ds__day',] SELECT subq_8.booking__ds__day FROM ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_time_offset_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_time_offset_metric_with_time_constraint__plan0.sql index d84a55f5ee..b54bebe125 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_time_offset_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_time_offset_metric_with_time_constraint__plan0.sql @@ -224,7 +224,7 @@ FROM ( , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_3.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/BigQuery/test_derived_fill_nulls_for_one_input_metric__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/BigQuery/test_derived_fill_nulls_for_one_input_metric__plan0.sql index b79074f982..70d88870dd 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/BigQuery/test_derived_fill_nulls_for_one_input_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/BigQuery/test_derived_fill_nulls_for_one_input_metric__plan0.sql @@ -390,7 +390,7 @@ FROM ( , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_12.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Databricks/test_derived_fill_nulls_for_one_input_metric__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Databricks/test_derived_fill_nulls_for_one_input_metric__plan0.sql index d64c651b64..595c84c1bb 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Databricks/test_derived_fill_nulls_for_one_input_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Databricks/test_derived_fill_nulls_for_one_input_metric__plan0.sql @@ -390,7 +390,7 @@ FROM ( , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_12.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_derived_fill_nulls_for_one_input_metric__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_derived_fill_nulls_for_one_input_metric__plan0.sql index 3f40143c3f..0f78182476 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_derived_fill_nulls_for_one_input_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_derived_fill_nulls_for_one_input_metric__plan0.sql @@ -390,7 +390,7 @@ FROM ( , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_12.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Postgres/test_derived_fill_nulls_for_one_input_metric__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Postgres/test_derived_fill_nulls_for_one_input_metric__plan0.sql index effdeeaf46..ec92de6b94 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Postgres/test_derived_fill_nulls_for_one_input_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Postgres/test_derived_fill_nulls_for_one_input_metric__plan0.sql @@ -390,7 +390,7 @@ FROM ( , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_12.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Redshift/test_derived_fill_nulls_for_one_input_metric__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Redshift/test_derived_fill_nulls_for_one_input_metric__plan0.sql index 863fd9c353..70fc6f787c 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Redshift/test_derived_fill_nulls_for_one_input_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Redshift/test_derived_fill_nulls_for_one_input_metric__plan0.sql @@ -390,7 +390,7 @@ FROM ( , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_12.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Snowflake/test_derived_fill_nulls_for_one_input_metric__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Snowflake/test_derived_fill_nulls_for_one_input_metric__plan0.sql index 39a2f3d4a3..ec5ea6ceb3 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Snowflake/test_derived_fill_nulls_for_one_input_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Snowflake/test_derived_fill_nulls_for_one_input_metric__plan0.sql @@ -390,7 +390,7 @@ FROM ( , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_12.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Trino/test_derived_fill_nulls_for_one_input_metric__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Trino/test_derived_fill_nulls_for_one_input_metric__plan0.sql index 759d7b037b..f2f06ccccb 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Trino/test_derived_fill_nulls_for_one_input_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Trino/test_derived_fill_nulls_for_one_input_metric__plan0.sql @@ -390,7 +390,7 @@ FROM ( , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_12.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/BigQuery/test_subdaily_offset_to_grain_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/BigQuery/test_subdaily_offset_to_grain_metric__plan0.sql index cb23da2eca..a19c2ff9cf 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/BigQuery/test_subdaily_offset_to_grain_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/BigQuery/test_subdaily_offset_to_grain_metric__plan0.sql @@ -215,7 +215,7 @@ FROM ( , subq_1.user__home_state AS user__home_state , subq_1.archived_users AS archived_users FROM ( - -- Pass Only Elements: ['metric_time__hour', 'metric_time__hour'] + -- Pass Only Elements: ['metric_time__hour',] SELECT subq_3.metric_time__hour FROM ( diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/BigQuery/test_subdaily_offset_window_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/BigQuery/test_subdaily_offset_window_metric__plan0.sql index 65225b5fb7..d908a1a777 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/BigQuery/test_subdaily_offset_window_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/BigQuery/test_subdaily_offset_window_metric__plan0.sql @@ -215,7 +215,7 @@ FROM ( , subq_1.user__home_state AS user__home_state , subq_1.archived_users AS archived_users FROM ( - -- Pass Only Elements: ['metric_time__hour', 'metric_time__hour'] + -- Pass Only Elements: ['metric_time__hour',] SELECT subq_3.metric_time__hour FROM ( diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Databricks/test_subdaily_offset_to_grain_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Databricks/test_subdaily_offset_to_grain_metric__plan0.sql index 664940b736..2fec86adea 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Databricks/test_subdaily_offset_to_grain_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Databricks/test_subdaily_offset_to_grain_metric__plan0.sql @@ -215,7 +215,7 @@ FROM ( , subq_1.user__home_state AS user__home_state , subq_1.archived_users AS archived_users FROM ( - -- Pass Only Elements: ['metric_time__hour', 'metric_time__hour'] + -- Pass Only Elements: ['metric_time__hour',] SELECT subq_3.metric_time__hour FROM ( diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Databricks/test_subdaily_offset_window_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Databricks/test_subdaily_offset_window_metric__plan0.sql index 0501902b3c..a1272653bf 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Databricks/test_subdaily_offset_window_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Databricks/test_subdaily_offset_window_metric__plan0.sql @@ -215,7 +215,7 @@ FROM ( , subq_1.user__home_state AS user__home_state , subq_1.archived_users AS archived_users FROM ( - -- Pass Only Elements: ['metric_time__hour', 'metric_time__hour'] + -- Pass Only Elements: ['metric_time__hour',] SELECT subq_3.metric_time__hour FROM ( diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/DuckDB/test_subdaily_offset_to_grain_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/DuckDB/test_subdaily_offset_to_grain_metric__plan0.sql index 1b1c236304..f50118713f 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/DuckDB/test_subdaily_offset_to_grain_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/DuckDB/test_subdaily_offset_to_grain_metric__plan0.sql @@ -215,7 +215,7 @@ FROM ( , subq_1.user__home_state AS user__home_state , subq_1.archived_users AS archived_users FROM ( - -- Pass Only Elements: ['metric_time__hour', 'metric_time__hour'] + -- Pass Only Elements: ['metric_time__hour',] SELECT subq_3.metric_time__hour FROM ( diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/DuckDB/test_subdaily_offset_window_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/DuckDB/test_subdaily_offset_window_metric__plan0.sql index 90671a2b07..cb22006294 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/DuckDB/test_subdaily_offset_window_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/DuckDB/test_subdaily_offset_window_metric__plan0.sql @@ -215,7 +215,7 @@ FROM ( , subq_1.user__home_state AS user__home_state , subq_1.archived_users AS archived_users FROM ( - -- Pass Only Elements: ['metric_time__hour', 'metric_time__hour'] + -- Pass Only Elements: ['metric_time__hour',] SELECT subq_3.metric_time__hour FROM ( diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Postgres/test_subdaily_offset_to_grain_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Postgres/test_subdaily_offset_to_grain_metric__plan0.sql index 831d260621..02792f50fe 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Postgres/test_subdaily_offset_to_grain_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Postgres/test_subdaily_offset_to_grain_metric__plan0.sql @@ -215,7 +215,7 @@ FROM ( , subq_1.user__home_state AS user__home_state , subq_1.archived_users AS archived_users FROM ( - -- Pass Only Elements: ['metric_time__hour', 'metric_time__hour'] + -- Pass Only Elements: ['metric_time__hour',] SELECT subq_3.metric_time__hour FROM ( diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Postgres/test_subdaily_offset_window_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Postgres/test_subdaily_offset_window_metric__plan0.sql index fbd844fe21..770620e9a4 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Postgres/test_subdaily_offset_window_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Postgres/test_subdaily_offset_window_metric__plan0.sql @@ -215,7 +215,7 @@ FROM ( , subq_1.user__home_state AS user__home_state , subq_1.archived_users AS archived_users FROM ( - -- Pass Only Elements: ['metric_time__hour', 'metric_time__hour'] + -- Pass Only Elements: ['metric_time__hour',] SELECT subq_3.metric_time__hour FROM ( diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Redshift/test_subdaily_offset_to_grain_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Redshift/test_subdaily_offset_to_grain_metric__plan0.sql index 3920d61fc3..2612f34ca3 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Redshift/test_subdaily_offset_to_grain_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Redshift/test_subdaily_offset_to_grain_metric__plan0.sql @@ -215,7 +215,7 @@ FROM ( , subq_1.user__home_state AS user__home_state , subq_1.archived_users AS archived_users FROM ( - -- Pass Only Elements: ['metric_time__hour', 'metric_time__hour'] + -- Pass Only Elements: ['metric_time__hour',] SELECT subq_3.metric_time__hour FROM ( diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Redshift/test_subdaily_offset_window_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Redshift/test_subdaily_offset_window_metric__plan0.sql index 953f0abb48..bab6c489b4 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Redshift/test_subdaily_offset_window_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Redshift/test_subdaily_offset_window_metric__plan0.sql @@ -215,7 +215,7 @@ FROM ( , subq_1.user__home_state AS user__home_state , subq_1.archived_users AS archived_users FROM ( - -- Pass Only Elements: ['metric_time__hour', 'metric_time__hour'] + -- Pass Only Elements: ['metric_time__hour',] SELECT subq_3.metric_time__hour FROM ( diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Snowflake/test_subdaily_offset_to_grain_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Snowflake/test_subdaily_offset_to_grain_metric__plan0.sql index 45031e3014..e6506d92d2 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Snowflake/test_subdaily_offset_to_grain_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Snowflake/test_subdaily_offset_to_grain_metric__plan0.sql @@ -215,7 +215,7 @@ FROM ( , subq_1.user__home_state AS user__home_state , subq_1.archived_users AS archived_users FROM ( - -- Pass Only Elements: ['metric_time__hour', 'metric_time__hour'] + -- Pass Only Elements: ['metric_time__hour',] SELECT subq_3.metric_time__hour FROM ( diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Snowflake/test_subdaily_offset_window_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Snowflake/test_subdaily_offset_window_metric__plan0.sql index 53d8149be8..be09ec8ba0 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Snowflake/test_subdaily_offset_window_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Snowflake/test_subdaily_offset_window_metric__plan0.sql @@ -215,7 +215,7 @@ FROM ( , subq_1.user__home_state AS user__home_state , subq_1.archived_users AS archived_users FROM ( - -- Pass Only Elements: ['metric_time__hour', 'metric_time__hour'] + -- Pass Only Elements: ['metric_time__hour',] SELECT subq_3.metric_time__hour FROM ( diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Trino/test_subdaily_offset_to_grain_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Trino/test_subdaily_offset_to_grain_metric__plan0.sql index d0df0642e9..16b417cbe1 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Trino/test_subdaily_offset_to_grain_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Trino/test_subdaily_offset_to_grain_metric__plan0.sql @@ -215,7 +215,7 @@ FROM ( , subq_1.user__home_state AS user__home_state , subq_1.archived_users AS archived_users FROM ( - -- Pass Only Elements: ['metric_time__hour', 'metric_time__hour'] + -- Pass Only Elements: ['metric_time__hour',] SELECT subq_3.metric_time__hour FROM ( diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Trino/test_subdaily_offset_window_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Trino/test_subdaily_offset_window_metric__plan0.sql index b8f704c030..98edd3f09a 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Trino/test_subdaily_offset_window_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Trino/test_subdaily_offset_window_metric__plan0.sql @@ -215,7 +215,7 @@ FROM ( , subq_1.user__home_state AS user__home_state , subq_1.archived_users AS archived_users FROM ( - -- Pass Only Elements: ['metric_time__hour', 'metric_time__hour'] + -- Pass Only Elements: ['metric_time__hour',] SELECT subq_3.metric_time__hour FROM ( diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/BigQuery/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/BigQuery/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql index ed53a13d73..6471a66a1b 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/BigQuery/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/BigQuery/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql @@ -999,7 +999,7 @@ FROM ( , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_17.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/BigQuery/test_offset_metric_with_query_time_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/BigQuery/test_offset_metric_with_query_time_filters__plan0.sql index 8844c232f8..3e12f639c0 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/BigQuery/test_offset_metric_with_query_time_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/BigQuery/test_offset_metric_with_query_time_filters__plan0.sql @@ -908,7 +908,7 @@ FROM ( , subq_11.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_11.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_13.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Databricks/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Databricks/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql index 67040fc59d..4c00a40347 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Databricks/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Databricks/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql @@ -999,7 +999,7 @@ FROM ( , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_17.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Databricks/test_offset_metric_with_query_time_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Databricks/test_offset_metric_with_query_time_filters__plan0.sql index 8749ded6e7..cd8c3e181c 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Databricks/test_offset_metric_with_query_time_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Databricks/test_offset_metric_with_query_time_filters__plan0.sql @@ -908,7 +908,7 @@ FROM ( , subq_11.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_11.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_13.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/DuckDB/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/DuckDB/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql index 95a8d99490..c08bef2fa3 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/DuckDB/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/DuckDB/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql @@ -999,7 +999,7 @@ FROM ( , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_17.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/DuckDB/test_offset_metric_with_query_time_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/DuckDB/test_offset_metric_with_query_time_filters__plan0.sql index dff46df643..3fbc062881 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/DuckDB/test_offset_metric_with_query_time_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/DuckDB/test_offset_metric_with_query_time_filters__plan0.sql @@ -908,7 +908,7 @@ FROM ( , subq_11.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_11.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_13.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Postgres/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Postgres/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql index 9d053d3722..2384620812 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Postgres/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Postgres/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql @@ -999,7 +999,7 @@ FROM ( , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_17.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Postgres/test_offset_metric_with_query_time_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Postgres/test_offset_metric_with_query_time_filters__plan0.sql index a85ed08060..eda336d1f6 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Postgres/test_offset_metric_with_query_time_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Postgres/test_offset_metric_with_query_time_filters__plan0.sql @@ -908,7 +908,7 @@ FROM ( , subq_11.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_11.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_13.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Redshift/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Redshift/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql index 63c3b7155f..555891b51b 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Redshift/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Redshift/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql @@ -999,7 +999,7 @@ FROM ( , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_17.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Redshift/test_offset_metric_with_query_time_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Redshift/test_offset_metric_with_query_time_filters__plan0.sql index bd158226bc..a0cb57129f 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Redshift/test_offset_metric_with_query_time_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Redshift/test_offset_metric_with_query_time_filters__plan0.sql @@ -908,7 +908,7 @@ FROM ( , subq_11.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_11.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_13.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Snowflake/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Snowflake/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql index fb491635c8..6768cd9c0e 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Snowflake/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Snowflake/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql @@ -999,7 +999,7 @@ FROM ( , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_17.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Snowflake/test_offset_metric_with_query_time_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Snowflake/test_offset_metric_with_query_time_filters__plan0.sql index 9193aad9da..263f7a142d 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Snowflake/test_offset_metric_with_query_time_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Snowflake/test_offset_metric_with_query_time_filters__plan0.sql @@ -908,7 +908,7 @@ FROM ( , subq_11.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_11.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_13.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Trino/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Trino/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql index bd8f31df9a..3cf671db04 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Trino/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Trino/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql @@ -999,7 +999,7 @@ FROM ( , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_17.metric_time__day FROM ( diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Trino/test_offset_metric_with_query_time_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Trino/test_offset_metric_with_query_time_filters__plan0.sql index e85e67162c..7c215b84db 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Trino/test_offset_metric_with_query_time_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/Trino/test_offset_metric_with_query_time_filters__plan0.sql @@ -908,7 +908,7 @@ FROM ( , subq_11.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 , subq_11.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['metric_time__day', 'metric_time__day'] + -- Pass Only Elements: ['metric_time__day',] SELECT subq_13.metric_time__day FROM ( From 7de2bd30f91d6ae03782026fea77e4e35b97be7b Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Wed, 18 Dec 2024 12:25:58 -0800 Subject: [PATCH 13/13] Add new dataflow plan nodes for custom offset windows --- .../metricflow_semantics/dag/id_prefix.py | 2 + .../dataflow/builder/dataflow_plan_builder.py | 4 +- metricflow/dataflow/dataflow_plan_visitor.py | 22 ++ .../nodes/custom_granularity_bounds.py | 64 ++++ .../nodes/offset_by_custom_granularity.py | 95 ++++++ .../optimizer/predicate_pushdown_optimizer.py | 12 + .../source_scan/cm_branch_combiner.py | 14 + .../source_scan/source_scan_optimizer.py | 14 + metricflow/dataset/sql_dataset.py | 24 +- metricflow/execution/dataflow_to_execution.py | 12 + metricflow/plan_conversion/dataflow_to_sql.py | 306 +++++++++++++++++- metricflow/sql/sql_plan.py | 12 +- .../source_scan/test_source_scan_optimizer.py | 8 + 13 files changed, 581 insertions(+), 8 deletions(-) create mode 100644 metricflow/dataflow/nodes/custom_granularity_bounds.py create mode 100644 metricflow/dataflow/nodes/offset_by_custom_granularity.py diff --git a/metricflow-semantics/metricflow_semantics/dag/id_prefix.py b/metricflow-semantics/metricflow_semantics/dag/id_prefix.py index 61fdcc5f7d..285052d3a8 100644 --- a/metricflow-semantics/metricflow_semantics/dag/id_prefix.py +++ b/metricflow-semantics/metricflow_semantics/dag/id_prefix.py @@ -56,6 +56,8 @@ class StaticIdPrefix(IdPrefix, Enum, metaclass=EnumMetaClassHelper): DATAFLOW_NODE_JOIN_CONVERSION_EVENTS_PREFIX = "jce" DATAFLOW_NODE_WINDOW_REAGGREGATION_ID_PREFIX = "wr" DATAFLOW_NODE_ALIAS_SPECS_ID_PREFIX = "as" + DATAFLOW_NODE_CUSTOM_GRANULARITY_BOUNDS_ID_PREFIX = "cgb" + DATAFLOW_NODE_OFFSET_BY_CUSTOMG_GRANULARITY_ID_PREFIX = "obcg" SQL_EXPR_COLUMN_REFERENCE_ID_PREFIX = "cr" SQL_EXPR_COMPARISON_ID_PREFIX = "cmp" diff --git a/metricflow/dataflow/builder/dataflow_plan_builder.py b/metricflow/dataflow/builder/dataflow_plan_builder.py index b44271fa9c..e7456d7775 100644 --- a/metricflow/dataflow/builder/dataflow_plan_builder.py +++ b/metricflow/dataflow/builder/dataflow_plan_builder.py @@ -1883,7 +1883,9 @@ def _build_time_spine_node( parent_node=read_node, change_specs=tuple( SpecToAlias( - input_spec=time_spine_data_set.instance_from_time_dimension_grain_and_date_part(required_spec).spec, + input_spec=time_spine_data_set.instance_from_time_dimension_grain_and_date_part( + time_granularity_name=required_spec.time_granularity.name, date_part=required_spec.date_part + ).spec, output_spec=required_spec, ) for required_spec in required_time_spine_specs diff --git a/metricflow/dataflow/dataflow_plan_visitor.py b/metricflow/dataflow/dataflow_plan_visitor.py index 412170a53f..1e3a86bfef 100644 --- a/metricflow/dataflow/dataflow_plan_visitor.py +++ b/metricflow/dataflow/dataflow_plan_visitor.py @@ -15,6 +15,7 @@ from metricflow.dataflow.nodes.combine_aggregated_outputs import CombineAggregatedOutputsNode from metricflow.dataflow.nodes.compute_metrics import ComputeMetricsNode from metricflow.dataflow.nodes.constrain_time import ConstrainTimeRangeNode + from metricflow.dataflow.nodes.custom_granularity_bounds import CustomGranularityBoundsNode from metricflow.dataflow.nodes.filter_elements import FilterElementsNode from metricflow.dataflow.nodes.join_conversion_events import JoinConversionEventsNode from metricflow.dataflow.nodes.join_over_time import JoinOverTimeRangeNode @@ -23,6 +24,7 @@ from metricflow.dataflow.nodes.join_to_time_spine import JoinToTimeSpineNode from metricflow.dataflow.nodes.metric_time_transform import MetricTimeDimensionTransformNode from metricflow.dataflow.nodes.min_max import MinMaxNode + from metricflow.dataflow.nodes.offset_by_custom_granularity import OffsetByCustomGranularityNode from metricflow.dataflow.nodes.order_by_limit import OrderByLimitNode from metricflow.dataflow.nodes.read_sql_source import ReadSqlSourceNode from metricflow.dataflow.nodes.semi_additive_join import SemiAdditiveJoinNode @@ -126,6 +128,16 @@ def visit_join_to_custom_granularity_node(self, node: JoinToCustomGranularityNod def visit_alias_specs_node(self, node: AliasSpecsNode) -> VisitorOutputT: # noqa: D102 raise NotImplementedError + @abstractmethod + def visit_custom_granularity_bounds_node(self, node: CustomGranularityBoundsNode) -> VisitorOutputT: # noqa: D102 + raise NotImplementedError + + @abstractmethod + def visit_offset_by_custom_granularity_node( # noqa: D102 + self, node: OffsetByCustomGranularityNode + ) -> VisitorOutputT: + raise NotImplementedError + class DataflowPlanNodeVisitorWithDefaultHandler(DataflowPlanNodeVisitor[VisitorOutputT], Generic[VisitorOutputT]): """Similar to `DataflowPlanNodeVisitor`, but with an abstract default handler that gets called for each node. @@ -222,3 +234,13 @@ def visit_join_to_custom_granularity_node(self, node: JoinToCustomGranularityNod @override def visit_alias_specs_node(self, node: AliasSpecsNode) -> VisitorOutputT: # noqa: D102 return self._default_handler(node) + + @override + def visit_custom_granularity_bounds_node(self, node: CustomGranularityBoundsNode) -> VisitorOutputT: # noqa: D102 + return self._default_handler(node) + + @override + def visit_offset_by_custom_granularity_node( # noqa: D102 + self, node: OffsetByCustomGranularityNode + ) -> VisitorOutputT: + return self._default_handler(node) diff --git a/metricflow/dataflow/nodes/custom_granularity_bounds.py b/metricflow/dataflow/nodes/custom_granularity_bounds.py new file mode 100644 index 0000000000..5dbde2a886 --- /dev/null +++ b/metricflow/dataflow/nodes/custom_granularity_bounds.py @@ -0,0 +1,64 @@ +from __future__ import annotations + +from abc import ABC +from dataclasses import dataclass +from typing import Sequence + +from metricflow_semantics.dag.id_prefix import IdPrefix, StaticIdPrefix +from metricflow_semantics.dag.mf_dag import DisplayedProperty +from metricflow_semantics.visitor import VisitorOutputT + +from metricflow.dataflow.dataflow_plan import DataflowPlanNode +from metricflow.dataflow.dataflow_plan_visitor import DataflowPlanNodeVisitor + + +@dataclass(frozen=True, eq=False) +class CustomGranularityBoundsNode(DataflowPlanNode, ABC): + """Calculate the start and end of a custom granularity period and each row number within that period.""" + + custom_granularity_name: str + + def __post_init__(self) -> None: # noqa: D105 + super().__post_init__() + assert len(self.parent_nodes) == 1 + + @staticmethod + def create( # noqa: D102 + parent_node: DataflowPlanNode, custom_granularity_name: str + ) -> CustomGranularityBoundsNode: + return CustomGranularityBoundsNode(parent_nodes=(parent_node,), custom_granularity_name=custom_granularity_name) + + @classmethod + def id_prefix(cls) -> IdPrefix: # noqa: D102 + return StaticIdPrefix.DATAFLOW_NODE_CUSTOM_GRANULARITY_BOUNDS_ID_PREFIX + + def accept(self, visitor: DataflowPlanNodeVisitor[VisitorOutputT]) -> VisitorOutputT: # noqa: D102 + return visitor.visit_custom_granularity_bounds_node(self) + + @property + def description(self) -> str: # noqa: D102 + return """Calculate Custom Granularity Bounds""" + + @property + def displayed_properties(self) -> Sequence[DisplayedProperty]: # noqa: D102 + return tuple(super().displayed_properties) + ( + DisplayedProperty("custom_granularity_name", self.custom_granularity_name), + ) + + @property + def parent_node(self) -> DataflowPlanNode: # noqa: D102 + return self.parent_nodes[0] + + def functionally_identical(self, other_node: DataflowPlanNode) -> bool: # noqa: D102 + return ( + isinstance(other_node, self.__class__) + and other_node.custom_granularity_name == self.custom_granularity_name + ) + + def with_new_parents( # noqa: D102 + self, new_parent_nodes: Sequence[DataflowPlanNode] + ) -> CustomGranularityBoundsNode: + assert len(new_parent_nodes) == 1 + return CustomGranularityBoundsNode.create( + parent_node=new_parent_nodes[0], custom_granularity_name=self.custom_granularity_name + ) diff --git a/metricflow/dataflow/nodes/offset_by_custom_granularity.py b/metricflow/dataflow/nodes/offset_by_custom_granularity.py new file mode 100644 index 0000000000..8161af3c23 --- /dev/null +++ b/metricflow/dataflow/nodes/offset_by_custom_granularity.py @@ -0,0 +1,95 @@ +from __future__ import annotations + +from abc import ABC +from dataclasses import dataclass +from typing import Optional, Sequence + +from dbt_semantic_interfaces.protocols.metric import MetricTimeWindow +from metricflow_semantics.dag.id_prefix import IdPrefix, StaticIdPrefix +from metricflow_semantics.dag.mf_dag import DisplayedProperty +from metricflow_semantics.specs.time_dimension_spec import TimeDimensionSpec +from metricflow_semantics.visitor import VisitorOutputT + +from metricflow.dataflow.dataflow_plan import DataflowPlanNode +from metricflow.dataflow.dataflow_plan_visitor import DataflowPlanNodeVisitor +from metricflow.dataflow.nodes.custom_granularity_bounds import CustomGranularityBoundsNode +from metricflow.dataflow.nodes.filter_elements import FilterElementsNode + + +@dataclass(frozen=True, eq=False) +class OffsetByCustomGranularityNode(DataflowPlanNode, ABC): + """For a given custom grain, offset its base grain by the requested number of custom grain periods. + + Only accepts CustomGranularityBoundsNode as parent node. + """ + + offset_window: MetricTimeWindow + required_time_spine_specs: Sequence[TimeDimensionSpec] + custom_granularity_bounds_node: CustomGranularityBoundsNode + filter_elements_node: FilterElementsNode + + def __post_init__(self) -> None: # noqa: D105 + super().__post_init__() + + @staticmethod + def create( # noqa: D102 + custom_granularity_bounds_node: CustomGranularityBoundsNode, + filter_elements_node: FilterElementsNode, + offset_window: MetricTimeWindow, + required_time_spine_specs: Sequence[TimeDimensionSpec], + ) -> OffsetByCustomGranularityNode: + return OffsetByCustomGranularityNode( + parent_nodes=(custom_granularity_bounds_node, filter_elements_node), + custom_granularity_bounds_node=custom_granularity_bounds_node, + filter_elements_node=filter_elements_node, + offset_window=offset_window, + required_time_spine_specs=required_time_spine_specs, + ) + + @classmethod + def id_prefix(cls) -> IdPrefix: # noqa: D102 + return StaticIdPrefix.DATAFLOW_NODE_OFFSET_BY_CUSTOMG_GRANULARITY_ID_PREFIX + + def accept(self, visitor: DataflowPlanNodeVisitor[VisitorOutputT]) -> VisitorOutputT: # noqa: D102 + return visitor.visit_offset_by_custom_granularity_node(self) + + @property + def description(self) -> str: # noqa: D102 + return """Offset Base Granularity By Custom Granularity Period(s)""" + + @property + def displayed_properties(self) -> Sequence[DisplayedProperty]: # noqa: D102 + return tuple(super().displayed_properties) + ( + DisplayedProperty("offset_window", self.offset_window), + DisplayedProperty("required_time_spine_specs", self.required_time_spine_specs), + ) + + def functionally_identical(self, other_node: DataflowPlanNode) -> bool: # noqa: D102 + return ( + isinstance(other_node, self.__class__) + and other_node.offset_window == self.offset_window + and other_node.required_time_spine_specs == self.required_time_spine_specs + ) + + def with_new_parents( # noqa: D102 + self, new_parent_nodes: Sequence[DataflowPlanNode] + ) -> OffsetByCustomGranularityNode: + custom_granularity_bounds_node: Optional[CustomGranularityBoundsNode] = None + filter_elements_node: Optional[FilterElementsNode] = None + for parent_node in new_parent_nodes: + if isinstance(parent_node, CustomGranularityBoundsNode): + custom_granularity_bounds_node = parent_node + elif isinstance(parent_node, FilterElementsNode): + filter_elements_node = parent_node + assert custom_granularity_bounds_node and filter_elements_node, ( + "Can't rewrite OffsetByCustomGranularityNode because the node requires a CustomGranularityBoundsNode and a " + f"FilterElementsNode as parents. Instead, got: {new_parent_nodes}" + ) + + return OffsetByCustomGranularityNode( + parent_nodes=tuple(new_parent_nodes), + custom_granularity_bounds_node=custom_granularity_bounds_node, + filter_elements_node=filter_elements_node, + offset_window=self.offset_window, + required_time_spine_specs=self.required_time_spine_specs, + ) diff --git a/metricflow/dataflow/optimizer/predicate_pushdown_optimizer.py b/metricflow/dataflow/optimizer/predicate_pushdown_optimizer.py index 223964af40..97a9eae41c 100644 --- a/metricflow/dataflow/optimizer/predicate_pushdown_optimizer.py +++ b/metricflow/dataflow/optimizer/predicate_pushdown_optimizer.py @@ -23,6 +23,7 @@ from metricflow.dataflow.nodes.combine_aggregated_outputs import CombineAggregatedOutputsNode from metricflow.dataflow.nodes.compute_metrics import ComputeMetricsNode from metricflow.dataflow.nodes.constrain_time import ConstrainTimeRangeNode +from metricflow.dataflow.nodes.custom_granularity_bounds import CustomGranularityBoundsNode from metricflow.dataflow.nodes.filter_elements import FilterElementsNode from metricflow.dataflow.nodes.join_conversion_events import JoinConversionEventsNode from metricflow.dataflow.nodes.join_over_time import JoinOverTimeRangeNode @@ -31,6 +32,7 @@ from metricflow.dataflow.nodes.join_to_time_spine import JoinToTimeSpineNode from metricflow.dataflow.nodes.metric_time_transform import MetricTimeDimensionTransformNode from metricflow.dataflow.nodes.min_max import MinMaxNode +from metricflow.dataflow.nodes.offset_by_custom_granularity import OffsetByCustomGranularityNode from metricflow.dataflow.nodes.order_by_limit import OrderByLimitNode from metricflow.dataflow.nodes.read_sql_source import ReadSqlSourceNode from metricflow.dataflow.nodes.semi_additive_join import SemiAdditiveJoinNode @@ -472,6 +474,16 @@ def visit_join_to_custom_granularity_node( # noqa: D102 def visit_alias_specs_node(self, node: AliasSpecsNode) -> OptimizeBranchResult: # noqa: D102 raise NotImplementedError + def visit_custom_granularity_bounds_node( # noqa: D102 + self, node: CustomGranularityBoundsNode + ) -> OptimizeBranchResult: + raise NotImplementedError + + def visit_offset_by_custom_granularity_node( # noqa: D102 + self, node: OffsetByCustomGranularityNode + ) -> OptimizeBranchResult: + raise NotImplementedError + def visit_join_on_entities_node(self, node: JoinOnEntitiesNode) -> OptimizeBranchResult: """Handles pushdown state propagation for the standard join node type. diff --git a/metricflow/dataflow/optimizer/source_scan/cm_branch_combiner.py b/metricflow/dataflow/optimizer/source_scan/cm_branch_combiner.py index 3209e34b8b..d153899d95 100644 --- a/metricflow/dataflow/optimizer/source_scan/cm_branch_combiner.py +++ b/metricflow/dataflow/optimizer/source_scan/cm_branch_combiner.py @@ -17,6 +17,7 @@ from metricflow.dataflow.nodes.combine_aggregated_outputs import CombineAggregatedOutputsNode from metricflow.dataflow.nodes.compute_metrics import ComputeMetricsNode from metricflow.dataflow.nodes.constrain_time import ConstrainTimeRangeNode +from metricflow.dataflow.nodes.custom_granularity_bounds import CustomGranularityBoundsNode from metricflow.dataflow.nodes.filter_elements import FilterElementsNode from metricflow.dataflow.nodes.join_conversion_events import JoinConversionEventsNode from metricflow.dataflow.nodes.join_over_time import JoinOverTimeRangeNode @@ -25,6 +26,7 @@ from metricflow.dataflow.nodes.join_to_time_spine import JoinToTimeSpineNode from metricflow.dataflow.nodes.metric_time_transform import MetricTimeDimensionTransformNode from metricflow.dataflow.nodes.min_max import MinMaxNode +from metricflow.dataflow.nodes.offset_by_custom_granularity import OffsetByCustomGranularityNode from metricflow.dataflow.nodes.order_by_limit import OrderByLimitNode from metricflow.dataflow.nodes.read_sql_source import ReadSqlSourceNode from metricflow.dataflow.nodes.semi_additive_join import SemiAdditiveJoinNode @@ -472,3 +474,15 @@ def visit_min_max_node(self, node: MinMaxNode) -> ComputeMetricsBranchCombinerRe def visit_alias_specs_node(self, node: AliasSpecsNode) -> ComputeMetricsBranchCombinerResult: # noqa: D102 self._log_visit_node_type(node) return self._default_handler(node) + + def visit_custom_granularity_bounds_node( # noqa: D102 + self, node: CustomGranularityBoundsNode + ) -> ComputeMetricsBranchCombinerResult: + self._log_visit_node_type(node) + return self._default_handler(node) + + def visit_offset_by_custom_granularity_node( # noqa: D102 + self, node: OffsetByCustomGranularityNode + ) -> ComputeMetricsBranchCombinerResult: + self._log_visit_node_type(node) + return self._default_handler(node) diff --git a/metricflow/dataflow/optimizer/source_scan/source_scan_optimizer.py b/metricflow/dataflow/optimizer/source_scan/source_scan_optimizer.py index 95c0aeec32..4fea885d5f 100644 --- a/metricflow/dataflow/optimizer/source_scan/source_scan_optimizer.py +++ b/metricflow/dataflow/optimizer/source_scan/source_scan_optimizer.py @@ -19,6 +19,7 @@ from metricflow.dataflow.nodes.combine_aggregated_outputs import CombineAggregatedOutputsNode from metricflow.dataflow.nodes.compute_metrics import ComputeMetricsNode from metricflow.dataflow.nodes.constrain_time import ConstrainTimeRangeNode +from metricflow.dataflow.nodes.custom_granularity_bounds import CustomGranularityBoundsNode from metricflow.dataflow.nodes.filter_elements import FilterElementsNode from metricflow.dataflow.nodes.join_conversion_events import JoinConversionEventsNode from metricflow.dataflow.nodes.join_over_time import JoinOverTimeRangeNode @@ -27,6 +28,7 @@ from metricflow.dataflow.nodes.join_to_time_spine import JoinToTimeSpineNode from metricflow.dataflow.nodes.metric_time_transform import MetricTimeDimensionTransformNode from metricflow.dataflow.nodes.min_max import MinMaxNode +from metricflow.dataflow.nodes.offset_by_custom_granularity import OffsetByCustomGranularityNode from metricflow.dataflow.nodes.order_by_limit import OrderByLimitNode from metricflow.dataflow.nodes.read_sql_source import ReadSqlSourceNode from metricflow.dataflow.nodes.semi_additive_join import SemiAdditiveJoinNode @@ -363,3 +365,15 @@ def visit_min_max_node(self, node: MinMaxNode) -> OptimizeBranchResult: # noqa: def visit_alias_specs_node(self, node: AliasSpecsNode) -> OptimizeBranchResult: # noqa: D102 self._log_visit_node_type(node) return self._default_base_output_handler(node) + + def visit_custom_granularity_bounds_node( # noqa: D102 + self, node: CustomGranularityBoundsNode + ) -> OptimizeBranchResult: + self._log_visit_node_type(node) + return self._default_base_output_handler(node) + + def visit_offset_by_custom_granularity_node( # noqa: D102 + self, node: OffsetByCustomGranularityNode + ) -> OptimizeBranchResult: + self._log_visit_node_type(node) + return self._default_base_output_handler(node) diff --git a/metricflow/dataset/sql_dataset.py b/metricflow/dataset/sql_dataset.py index afa5593879..c7f4803b85 100644 --- a/metricflow/dataset/sql_dataset.py +++ b/metricflow/dataset/sql_dataset.py @@ -4,6 +4,7 @@ from typing import List, Optional, Sequence, Tuple from dbt_semantic_interfaces.references import SemanticModelReference +from dbt_semantic_interfaces.type_enums import DatePart from metricflow_semantics.assert_one_arg import assert_exactly_one_arg_set from metricflow_semantics.instances import EntityInstance, InstanceSet, MdoInstance, TimeDimensionInstance from metricflow_semantics.mf_logging.lazy_formattable import LazyFormat @@ -12,6 +13,7 @@ from metricflow_semantics.specs.entity_spec import EntitySpec from metricflow_semantics.specs.instance_spec import InstanceSpec from metricflow_semantics.specs.time_dimension_spec import TimeDimensionSpec +from metricflow_semantics.sql.sql_exprs import SqlWindowFunction from typing_extensions import override from metricflow.dataset.dataset_classes import DataSet @@ -165,18 +167,30 @@ def instance_for_spec(self, spec: InstanceSpec) -> MdoInstance: ) def instance_from_time_dimension_grain_and_date_part( - self, time_dimension_spec: TimeDimensionSpec + self, time_granularity_name: str, date_part: Optional[DatePart] ) -> TimeDimensionInstance: - """Find instance in dataset that matches the grain and date part of the given time dimension spec.""" + """Find instance in dataset that matches the given grain and date part.""" for time_dimension_instance in self.instance_set.time_dimension_instances: if ( - time_dimension_instance.spec.time_granularity == time_dimension_spec.time_granularity - and time_dimension_instance.spec.date_part == time_dimension_spec.date_part + time_dimension_instance.spec.time_granularity.name == time_granularity_name + and time_dimension_instance.spec.date_part == date_part + and time_dimension_instance.spec.window_function is None ): return time_dimension_instance raise RuntimeError( - f"Did not find a time dimension instance with matching grain and date part for spec: {time_dimension_spec}\n" + f"Did not find a time dimension instance with grain '{time_granularity_name}' and date part {date_part}\n" + f"Instances available: {self.instance_set.time_dimension_instances}" + ) + + def instance_from_window_function(self, window_function: SqlWindowFunction) -> TimeDimensionInstance: + """Find instance in dataset that matches the given window function.""" + for time_dimension_instance in self.instance_set.time_dimension_instances: + if time_dimension_instance.spec.window_function is window_function: + return time_dimension_instance + + raise RuntimeError( + f"Did not find a time dimension instance with window function {window_function}.\n" f"Instances available: {self.instance_set.time_dimension_instances}" ) diff --git a/metricflow/execution/dataflow_to_execution.py b/metricflow/execution/dataflow_to_execution.py index 1c2aa2fd95..8d1f5cfb3b 100644 --- a/metricflow/execution/dataflow_to_execution.py +++ b/metricflow/execution/dataflow_to_execution.py @@ -16,6 +16,7 @@ from metricflow.dataflow.nodes.combine_aggregated_outputs import CombineAggregatedOutputsNode from metricflow.dataflow.nodes.compute_metrics import ComputeMetricsNode from metricflow.dataflow.nodes.constrain_time import ConstrainTimeRangeNode +from metricflow.dataflow.nodes.custom_granularity_bounds import CustomGranularityBoundsNode from metricflow.dataflow.nodes.filter_elements import FilterElementsNode from metricflow.dataflow.nodes.join_conversion_events import JoinConversionEventsNode from metricflow.dataflow.nodes.join_over_time import JoinOverTimeRangeNode @@ -24,6 +25,7 @@ from metricflow.dataflow.nodes.join_to_time_spine import JoinToTimeSpineNode from metricflow.dataflow.nodes.metric_time_transform import MetricTimeDimensionTransformNode from metricflow.dataflow.nodes.min_max import MinMaxNode +from metricflow.dataflow.nodes.offset_by_custom_granularity import OffsetByCustomGranularityNode from metricflow.dataflow.nodes.order_by_limit import OrderByLimitNode from metricflow.dataflow.nodes.read_sql_source import ReadSqlSourceNode from metricflow.dataflow.nodes.semi_additive_join import SemiAdditiveJoinNode @@ -205,3 +207,13 @@ def visit_join_to_custom_granularity_node(self, node: JoinToCustomGranularityNod @override def visit_alias_specs_node(self, node: AliasSpecsNode) -> ConvertToExecutionPlanResult: raise NotImplementedError + + @override + def visit_custom_granularity_bounds_node(self, node: CustomGranularityBoundsNode) -> ConvertToExecutionPlanResult: + raise NotImplementedError + + @override + def visit_offset_by_custom_granularity_node( + self, node: OffsetByCustomGranularityNode + ) -> ConvertToExecutionPlanResult: + raise NotImplementedError diff --git a/metricflow/plan_conversion/dataflow_to_sql.py b/metricflow/plan_conversion/dataflow_to_sql.py index cd6b92a2b0..b03d76e4d1 100644 --- a/metricflow/plan_conversion/dataflow_to_sql.py +++ b/metricflow/plan_conversion/dataflow_to_sql.py @@ -6,6 +6,7 @@ from typing import Callable, Dict, FrozenSet, List, Optional, Sequence, Set, Tuple, TypeVar from dbt_semantic_interfaces.enum_extension import assert_values_exhausted +from dbt_semantic_interfaces.naming.keywords import DUNDER from dbt_semantic_interfaces.protocols.metric import MetricInputMeasure, MetricType from dbt_semantic_interfaces.references import MetricModelReference, SemanticModelElementReference from dbt_semantic_interfaces.type_enums.aggregation_type import AggregationType @@ -38,8 +39,12 @@ from metricflow_semantics.specs.spec_set import InstanceSpecSet from metricflow_semantics.specs.where_filter.where_filter_spec import WhereFilterSpec from metricflow_semantics.sql.sql_exprs import ( + SqlAddTimeExpression, SqlAggregateFunctionExpression, + SqlArithmeticExpression, + SqlArithmeticOperator, SqlBetweenExpression, + SqlCaseExpression, SqlColumnReference, SqlColumnReferenceExpression, SqlComparison, @@ -50,6 +55,7 @@ SqlFunction, SqlFunctionExpression, SqlGenerateUuidExpression, + SqlIntegerExpression, SqlLogicalExpression, SqlLogicalOperator, SqlRatioComputationExpression, @@ -77,6 +83,7 @@ from metricflow.dataflow.nodes.combine_aggregated_outputs import CombineAggregatedOutputsNode from metricflow.dataflow.nodes.compute_metrics import ComputeMetricsNode from metricflow.dataflow.nodes.constrain_time import ConstrainTimeRangeNode +from metricflow.dataflow.nodes.custom_granularity_bounds import CustomGranularityBoundsNode from metricflow.dataflow.nodes.filter_elements import FilterElementsNode from metricflow.dataflow.nodes.join_conversion_events import JoinConversionEventsNode from metricflow.dataflow.nodes.join_over_time import JoinOverTimeRangeNode @@ -85,6 +92,7 @@ from metricflow.dataflow.nodes.join_to_time_spine import JoinToTimeSpineNode from metricflow.dataflow.nodes.metric_time_transform import MetricTimeDimensionTransformNode from metricflow.dataflow.nodes.min_max import MinMaxNode +from metricflow.dataflow.nodes.offset_by_custom_granularity import OffsetByCustomGranularityNode from metricflow.dataflow.nodes.order_by_limit import OrderByLimitNode from metricflow.dataflow.nodes.read_sql_source import ReadSqlSourceNode from metricflow.dataflow.nodes.semi_additive_join import SemiAdditiveJoinNode @@ -1888,7 +1896,7 @@ def visit_join_conversion_events_node(self, node: JoinConversionEventsNode) -> S def visit_window_reaggregation_node(self, node: WindowReaggregationNode) -> SqlDataSet: # noqa: D102 from_data_set = node.parent_node.accept(self) - parent_instance_set = from_data_set.instance_set # remove order by col + parent_instance_set = from_data_set.instance_set parent_data_set_alias = self._next_unique_table_alias() metric_instance = None @@ -2015,6 +2023,290 @@ def strip_time_from_dt(ts: dt.datetime) -> dt.datetime: ), ) + def visit_custom_granularity_bounds_node(self, node: CustomGranularityBoundsNode) -> SqlDataSet: + """Build columns that will be needed for custom offset windows. + + This includes columns that represent the start and end of a custom grain period, as well as the row number of the base + grain within each period. For example, the columns might look like: + + SELECT + {{ existing columns }}, + FIRST_VALUE(ds) OVER (PARTITION BY fiscal_quarter ORDER BY ds) AS ds__fiscal_quarter__first_value, + LAST_VALUE(ds) OVER (PARTITION BY fiscal_quarter ORDER BY ds) AS ds__fiscal_quarter__last_value, + ROW_NUMBER() OVER (PARTITION BY fiscal_quarter ORDER BY ds) AS ds__day__row_number + FROM time_spine_read_node + """ + parent_data_set = node.parent_node.accept(self) + parent_instance_set = parent_data_set.instance_set + parent_data_set_alias = self._next_unique_table_alias() + + custom_granularity_name = node.custom_granularity_name + time_spine = self._get_time_spine_for_custom_granularity(custom_granularity_name) + custom_grain_instance_from_parent = parent_data_set.instance_from_time_dimension_grain_and_date_part( + time_granularity_name=custom_granularity_name, date_part=None + ) + base_grain_instance_from_parent = parent_data_set.instance_from_time_dimension_grain_and_date_part( + time_granularity_name=time_spine.base_granularity.value, date_part=None + ) + custom_column_expr = SqlColumnReferenceExpression.from_table_and_column_names( + table_alias=parent_data_set_alias, + column_name=custom_grain_instance_from_parent.associated_column.column_name, + ) + base_column_expr = SqlColumnReferenceExpression.from_table_and_column_names( + table_alias=parent_data_set_alias, column_name=base_grain_instance_from_parent.associated_column.column_name + ) + + new_instances: Tuple[TimeDimensionInstance, ...] = tuple() + new_select_columns: Tuple[SqlSelectColumn, ...] = tuple() + + # Build columns that get start and end of the custom grain period. + # Ex: "FIRST_VALUE(ds) OVER (PARTITION BY martian_day ORDER BY ds) AS ds__fiscal_quarter__first_value" + for window_func in (SqlWindowFunction.FIRST_VALUE, SqlWindowFunction.LAST_VALUE): + new_instance = custom_grain_instance_from_parent.with_new_spec( + new_spec=custom_grain_instance_from_parent.spec.with_window_function(window_func), + column_association_resolver=self._column_association_resolver, + ) + select_column = SqlSelectColumn( + expr=SqlWindowFunctionExpression.create( + sql_function=window_func, + sql_function_args=(base_column_expr,), + partition_by_args=(custom_column_expr,), + order_by_args=(SqlWindowOrderByArgument(base_column_expr),), + ), + column_alias=new_instance.associated_column.column_name, + ) + new_instances += (new_instance,) + new_select_columns += (select_column,) + + # Build a column that tracks the row number for the base grain column within the custom grain period. + # This will be offset by 1 to represent the number of base grain periods since the start of the custom grain period. + # Ex: "ROW_NUMBER() OVER (PARTITION BY martian_day ORDER BY ds) AS ds__day__row_number" + new_instance = base_grain_instance_from_parent.with_new_spec( + new_spec=base_grain_instance_from_parent.spec.with_window_function(SqlWindowFunction.ROW_NUMBER), + column_association_resolver=self._column_association_resolver, + ) + window_func_expr = SqlWindowFunctionExpression.create( + sql_function=SqlWindowFunction.ROW_NUMBER, + partition_by_args=(custom_column_expr,), + order_by_args=(SqlWindowOrderByArgument(base_column_expr),), + ) + new_select_column = SqlSelectColumn( + expr=window_func_expr, + column_alias=new_instance.associated_column.column_name, + ) + new_instances += (new_instance,) + new_select_columns += (new_select_column,) + + return SqlDataSet( + instance_set=InstanceSet.merge([InstanceSet(time_dimension_instances=new_instances), parent_instance_set]), + sql_select_node=SqlSelectStatementNode.create( + description=node.description, + select_columns=parent_data_set.checked_sql_select_node.select_columns + new_select_columns, + from_source=parent_data_set.checked_sql_select_node, + from_source_alias=parent_data_set_alias, + ), + ) + + def visit_offset_by_custom_granularity_node(self, node: OffsetByCustomGranularityNode) -> SqlDataSet: + """For a given custom grain, offset its base grain by the requested number of custom grain periods. + + Example: if the custom grain is `fiscal_quarter` with a base grain of DAY and we're offsetting by 1 period, the + output SQL should look something like this: + + SELECT + CASE + WHEN DATEADD(day, ds__day__row_number - 1, ds__fiscal_quarter__first_value__offset) <= ds__fiscal_quarter__last_value__offset + THEN DATEADD(day, ds__day__row_number - 1, ds__fiscal_quarter__first_value__offset) + ELSE ds__fiscal_quarter__last_value__offset + END AS date_day + FROM custom_granularity_bounds_node + INNER JOIN filter_elements_node ON filter_elements_node.fiscal_quarter = custom_granularity_bounds_node.fiscal_quarter + """ + bounds_data_set = node.custom_granularity_bounds_node.accept(self) + bounds_instance_set = bounds_data_set.instance_set + bounds_data_set_alias = self._next_unique_table_alias() + filter_elements_data_set = node.filter_elements_node.accept(self) + filter_elements_instance_set = filter_elements_data_set.instance_set + filter_elements_data_set_alias = self._next_unique_table_alias() + offset_window = node.offset_window + custom_grain_name = offset_window.granularity + base_grain = ExpandedTimeGranularity.from_time_granularity( + self._get_time_spine_for_custom_granularity(custom_grain_name).base_granularity + ) + + # Find the required instances in the parent data sets. + first_value_instance: Optional[TimeDimensionInstance] = None + last_value_instance: Optional[TimeDimensionInstance] = None + row_number_instance: Optional[TimeDimensionInstance] = None + custom_grain_instance: Optional[TimeDimensionInstance] = None + base_grain_instance: Optional[TimeDimensionInstance] = None + for instance in filter_elements_instance_set.time_dimension_instances: + if instance.spec.window_function is SqlWindowFunction.FIRST_VALUE: + first_value_instance = instance + elif instance.spec.window_function is SqlWindowFunction.LAST_VALUE: + last_value_instance = instance + elif instance.spec.time_granularity.name == custom_grain_name: + custom_grain_instance = instance + if custom_grain_instance and first_value_instance and last_value_instance: + break + for instance in bounds_instance_set.time_dimension_instances: + if instance.spec.window_function is SqlWindowFunction.ROW_NUMBER: + row_number_instance = instance + elif instance.spec.time_granularity == base_grain and instance.spec.date_part is None: + base_grain_instance = instance + if base_grain_instance and row_number_instance: + break + assert ( + custom_grain_instance + and base_grain_instance + and first_value_instance + and last_value_instance + and row_number_instance + ), ( + "Did not find all required time dimension instances in parent data sets for OffsetByCustomGranularityNode. " + f"This indicates internal misconfiguration. Got custom grain instance: {custom_grain_instance}; base grain " + f"instance: {base_grain_instance}; first value instance: {first_value_instance}; last value instance: " + f"{last_value_instance}; row number instance: {row_number_instance}\n" + f"Available instances:{bounds_instance_set.time_dimension_instances}." + ) + + # First, build a subquery that offsets the first and last value columns. + custom_grain_column_name = custom_grain_instance.associated_column.column_name + custom_grain_column = SqlSelectColumn.from_table_and_column_names( + column_name=custom_grain_column_name, table_alias=filter_elements_data_set_alias + ) + first_value_offset_column, last_value_offset_column = tuple( + SqlSelectColumn( + expr=SqlWindowFunctionExpression.create( + sql_function=SqlWindowFunction.LEAD, + sql_function_args=( + SqlColumnReferenceExpression.from_table_and_column_names( + column_name=instance.associated_column.column_name, + table_alias=filter_elements_data_set_alias, + ), + SqlIntegerExpression.create(node.offset_window.count), + ), + order_by_args=(SqlWindowOrderByArgument(custom_grain_column.expr),), + ), + column_alias=f"{instance.associated_column.column_name}{DUNDER}offset", + ) + for instance in (first_value_instance, last_value_instance) + ) + offset_bounds_subquery_alias = self._next_unique_table_alias() + offset_bounds_subquery = SqlSelectStatementNode.create( + description="Offset Custom Granularity Bounds", + select_columns=(custom_grain_column, first_value_offset_column, last_value_offset_column), + from_source=filter_elements_data_set.checked_sql_select_node, + from_source_alias=filter_elements_data_set_alias, + ) + offset_bounds_subquery_alias = self._next_unique_table_alias() + + # Offset the base column by the requested window. If the offset date is not within the offset custom grain period, + # default to the last value in that period. + first_value_offset_expr, last_value_offset_expr = [ + SqlColumnReferenceExpression.from_table_and_column_names( + column_name=offset_column.column_alias, table_alias=offset_bounds_subquery_alias + ) + for offset_column in (first_value_offset_column, last_value_offset_column) + ] + offset_base_grain_expr = SqlAddTimeExpression.create( + arg=first_value_offset_expr, + count_expr=SqlArithmeticExpression.create( + left_expr=SqlColumnReferenceExpression.from_table_and_column_names( + table_alias=bounds_data_set_alias, column_name=row_number_instance.associated_column.column_name + ), + operator=SqlArithmeticOperator.SUBTRACT, + right_expr=SqlIntegerExpression.create(1), + ), + granularity=base_grain.base_granularity, + ) + is_below_last_value_expr = SqlComparisonExpression.create( + left_expr=offset_base_grain_expr, + comparison=SqlComparison.LESS_THAN_OR_EQUALS, + right_expr=last_value_offset_expr, + ) + offset_base_instance = base_grain_instance.with_new_spec( + # LEAD isn't quite accurate here, but this will differentiate the offset instance (and column) from the original one. + new_spec=base_grain_instance.spec.with_window_function(SqlWindowFunction.LEAD), + column_association_resolver=self._column_association_resolver, + ) + offset_base_column = SqlSelectColumn( + expr=SqlCaseExpression.create( + when_to_then_exprs={is_below_last_value_expr: offset_base_grain_expr}, + else_expr=last_value_offset_expr, + ), + column_alias=offset_base_instance.associated_column.column_name, + ) + original_base_grain_column = SqlSelectColumn.from_table_and_column_names( + column_name=base_grain_instance.associated_column.column_name, table_alias=bounds_data_set_alias + ) + join_desc = SqlJoinDescription( + right_source=offset_bounds_subquery, + right_source_alias=offset_bounds_subquery_alias, + join_type=SqlJoinType.INNER, + on_condition=SqlComparisonExpression.create( + left_expr=SqlColumnReferenceExpression.from_table_and_column_names( + table_alias=bounds_data_set_alias, column_name=custom_grain_column_name + ), + comparison=SqlComparison.EQUALS, + right_expr=SqlColumnReferenceExpression.from_table_and_column_names( + table_alias=offset_bounds_subquery_alias, column_name=custom_grain_column_name + ), + ), + ) + offset_base_grain_subquery = SqlSelectStatementNode.create( + description=node.description, + select_columns=(original_base_grain_column, offset_base_column), + from_source=bounds_data_set.checked_sql_select_node, + from_source_alias=bounds_data_set_alias, + join_descs=(join_desc,), + ) + offset_base_grain_subquery_alias = self._next_unique_table_alias() + + # Apply standard grains & date parts requested in the query. Use base grain for any custom grains. + standard_grain_instances: Tuple[TimeDimensionInstance, ...] = () + standard_grain_columns: Tuple[SqlSelectColumn, ...] = () + offset_base_column_ref = SqlSelectColumn( + expr=SqlColumnReferenceExpression.from_table_and_column_names( + column_name=offset_base_instance.associated_column.column_name, + table_alias=offset_base_grain_subquery_alias, + ), + column_alias=base_grain_instance.associated_column.column_name, + ) + for spec in node.required_time_spine_specs: + new_instance = base_grain_instance.with_new_spec( + new_spec=spec, column_association_resolver=self._column_association_resolver + ) + standard_grain_instances += (new_instance,) + if spec.date_part: + expr: SqlExpressionNode = SqlExtractExpression.create( + date_part=spec.date_part, arg=offset_base_column_ref.expr + ) + elif spec.time_granularity.base_granularity == base_grain.base_granularity: + expr = offset_base_column_ref.expr + else: + expr = SqlDateTruncExpression.create( + time_granularity=spec.time_granularity.base_granularity, arg=offset_base_column_ref.expr + ) + standard_grain_columns += ( + SqlSelectColumn(expr=expr, column_alias=new_instance.associated_column.column_name), + ) + + # Need to keep the non-offset base grain column in the output. This will be used to join to the source data set. + non_offset_base_grain_column = SqlSelectColumn.from_table_and_column_names( + column_name=base_grain_instance.associated_column.column_name, table_alias=offset_base_grain_subquery_alias + ) + + return SqlDataSet( + instance_set=InstanceSet(time_dimension_instances=(base_grain_instance,) + standard_grain_instances), + sql_select_node=SqlSelectStatementNode.create( + description="Apply Requested Granularities", + select_columns=(non_offset_base_grain_column,) + standard_grain_columns, + from_source=offset_base_grain_subquery, + from_source_alias=offset_base_grain_subquery_alias, + ), + ) + class DataflowNodeToSqlCteVisitor(DataflowNodeToSqlSubqueryVisitor): """Similar to `DataflowNodeToSqlSubqueryVisitor`, except that this converts specific nodes to CTEs. @@ -2210,5 +2502,17 @@ def visit_join_to_custom_granularity_node(self, node: JoinToCustomGranularityNod def visit_alias_specs_node(self, node: AliasSpecsNode) -> SqlDataSet: # noqa: D102 return self._default_handler(node=node, node_to_select_subquery_function=super().visit_alias_specs_node) + @override + def visit_custom_granularity_bounds_node(self, node: CustomGranularityBoundsNode) -> SqlDataSet: # noqa: D102 + return self._default_handler( + node=node, node_to_select_subquery_function=super().visit_custom_granularity_bounds_node + ) + + @override + def visit_offset_by_custom_granularity_node(self, node: OffsetByCustomGranularityNode) -> SqlDataSet: # noqa: D102 + return self._default_handler( + node=node, node_to_select_subquery_function=super().visit_offset_by_custom_granularity_node + ) + DataflowNodeT = TypeVar("DataflowNodeT", bound=DataflowPlanNode) diff --git a/metricflow/sql/sql_plan.py b/metricflow/sql/sql_plan.py index ff0b34c650..85e79b1440 100644 --- a/metricflow/sql/sql_plan.py +++ b/metricflow/sql/sql_plan.py @@ -9,7 +9,7 @@ from metricflow_semantics.dag.id_prefix import IdPrefix, StaticIdPrefix from metricflow_semantics.dag.mf_dag import DagId, DagNode, DisplayedProperty, MetricFlowDag -from metricflow_semantics.sql.sql_exprs import SqlExpressionNode +from metricflow_semantics.sql.sql_exprs import SqlColumnReferenceExpression, SqlExpressionNode from metricflow_semantics.sql.sql_join_type import SqlJoinType from metricflow_semantics.sql.sql_table import SqlTable from metricflow_semantics.visitor import VisitorOutputT @@ -102,6 +102,16 @@ class SqlSelectColumn: # Always require a column alias for simplicity. column_alias: str + @staticmethod + def from_table_and_column_names(table_alias: str, column_name: str) -> SqlSelectColumn: + """Create a column that selects a column from a table by name.""" + return SqlSelectColumn( + expr=SqlColumnReferenceExpression.from_table_and_column_names( + column_name=column_name, table_alias=table_alias + ), + column_alias=column_name, + ) + @dataclass(frozen=True) class SqlJoinDescription: diff --git a/tests_metricflow/dataflow/optimizer/source_scan/test_source_scan_optimizer.py b/tests_metricflow/dataflow/optimizer/source_scan/test_source_scan_optimizer.py index 05770806a0..a66e5a9e51 100644 --- a/tests_metricflow/dataflow/optimizer/source_scan/test_source_scan_optimizer.py +++ b/tests_metricflow/dataflow/optimizer/source_scan/test_source_scan_optimizer.py @@ -24,6 +24,7 @@ from metricflow.dataflow.nodes.combine_aggregated_outputs import CombineAggregatedOutputsNode from metricflow.dataflow.nodes.compute_metrics import ComputeMetricsNode from metricflow.dataflow.nodes.constrain_time import ConstrainTimeRangeNode +from metricflow.dataflow.nodes.custom_granularity_bounds import CustomGranularityBoundsNode from metricflow.dataflow.nodes.filter_elements import FilterElementsNode from metricflow.dataflow.nodes.join_conversion_events import JoinConversionEventsNode from metricflow.dataflow.nodes.join_over_time import JoinOverTimeRangeNode @@ -32,6 +33,7 @@ from metricflow.dataflow.nodes.join_to_time_spine import JoinToTimeSpineNode from metricflow.dataflow.nodes.metric_time_transform import MetricTimeDimensionTransformNode from metricflow.dataflow.nodes.min_max import MinMaxNode +from metricflow.dataflow.nodes.offset_by_custom_granularity import OffsetByCustomGranularityNode from metricflow.dataflow.nodes.order_by_limit import OrderByLimitNode from metricflow.dataflow.nodes.read_sql_source import ReadSqlSourceNode from metricflow.dataflow.nodes.semi_additive_join import SemiAdditiveJoinNode @@ -114,6 +116,12 @@ def visit_join_to_custom_granularity_node(self, node: JoinToCustomGranularityNod def visit_alias_specs_node(self, node: AliasSpecsNode) -> int: # noqa: D102 return self._sum_parents(node) + def visit_custom_granularity_bounds_node(self, node: CustomGranularityBoundsNode) -> int: # noqa: D102 + return self._sum_parents(node) + + def visit_offset_by_custom_granularity_node(self, node: OffsetByCustomGranularityNode) -> int: # noqa: D102 + return self._sum_parents(node) + def count_source_nodes(self, dataflow_plan: DataflowPlan) -> int: # noqa: D102 return dataflow_plan.sink_node.accept(self)