From a4cc831c8d4db3b19fb297863e529eefc79cd9a7 Mon Sep 17 00:00:00 2001 From: Lucas Valente Date: Fri, 10 Jan 2025 22:48:45 +0100 Subject: [PATCH] Add support for querying with metric alias (#1573) ## Summary This PR introduces support for querying with aliased metrics. This is done by adding an `AliasSpecsNode` after the order by step in `DataflowPlanBuilder`. To make the alias information reach that point, I also had to modify some of the query interface classes to allow aliases in metrics. You can review commit by commit. --------- Co-authored-by: Courtney Holcomb Co-authored-by: Will Deng --- .../unreleased/Features-20241213-110407.yaml | 6 + .../naming/dunder_scheme.py | 10 +- .../naming/metric_scheme.py | 8 +- .../naming/object_builder_scheme.py | 10 +- .../protocols/query_parameter.py | 5 + .../issues/parsing/duplicate_metric_alias.py | 49 ++ .../query/query_resolver.py | 40 +- .../specs/instance_spec.py | 4 + .../metricflow_semantics/specs/metric_spec.py | 18 + .../specs/patterns/entity_link_pattern.py | 16 +- .../specs/patterns/metric_pattern.py | 21 +- .../specs/patterns/typed_patterns.py | 10 +- .../specs/query_param_implementations.py | 17 +- .../semantics/test_linkable_element_set.py | 4 +- .../query/test_query_parser.py | 31 +- ...h_defined_metric_time_filter__result_0.txt | 2 +- ..._time_filter_on_input_metric__result_0.txt | 4 +- ...h_defined_metric_time_filter__result_0.txt | 2 +- ...validate_where_constraint_dims__result.txt | 2 +- ...cs_with_common_filtered_metric__result.txt | 4 +- ...tion_for_invalid_metric_filter__result.txt | 2 +- ...or_invalid_metric_input_filter__result.txt | 2 +- ...lution_for_valid_metric_filter__result.txt | 2 +- ..._for_valid_metric_input_filter__result.txt | 2 +- ...ccumulate_last_2_months_metric__result.txt | 2 +- ...h_different_parent_time_grains__result.txt | 2 +- ...c_with_same_parent_time_grains__result.txt | 2 +- ...ics_with_different_time_grains__result.txt | 2 +- ..._metrics_with_same_time_grains__result.txt | 2 +- ...spec_resolution__simple_metric__result.txt | 2 +- .../patterns/test_entity_link_pattern.py | 20 +- .../dataflow/builder/dataflow_plan_builder.py | 21 +- metricflow/dataset/sql_dataset.py | 16 + metricflow/plan_conversion/dataflow_to_sql.py | 80 +-- .../query_output/test_query_output.py | 95 +++ .../query_rendering/test_query_rendering.py | 64 ++ ..._metric_with_non_default_grains__plan0.sql | 32 +- ...th_non_default_grains__plan0_optimized.sql | 20 +- ..._metric_with_non_default_grains__plan0.sql | 32 +- ...th_non_default_grains__plan0_optimized.sql | 20 +- ..._metric_with_non_default_grains__plan0.sql | 32 +- ...th_non_default_grains__plan0_optimized.sql | 20 +- ..._metric_with_non_default_grains__plan0.sql | 32 +- ...th_non_default_grains__plan0_optimized.sql | 20 +- ..._metric_with_non_default_grains__plan0.sql | 32 +- ...th_non_default_grains__plan0_optimized.sql | 20 +- ..._metric_with_non_default_grains__plan0.sql | 32 +- ...th_non_default_grains__plan0_optimized.sql | 20 +- ..._metric_with_non_default_grains__plan0.sql | 32 +- ...th_non_default_grains__plan0_optimized.sql | 20 +- ..._metric_grouped_by_custom_grain__plan0.sql | 4 +- ..._with_custom_granularity_filter__plan0.sql | 8 +- ...nularity_filter_not_in_group_by__plan0.sql | 6 +- ..._metric_grouped_by_custom_grain__plan0.sql | 4 +- ..._with_custom_granularity_filter__plan0.sql | 8 +- ...nularity_filter_not_in_group_by__plan0.sql | 6 +- ..._metric_grouped_by_custom_grain__plan0.sql | 4 +- ..._with_custom_granularity_filter__plan0.sql | 8 +- ...nularity_filter_not_in_group_by__plan0.sql | 6 +- ..._metric_grouped_by_custom_grain__plan0.sql | 4 +- ..._with_custom_granularity_filter__plan0.sql | 8 +- ...nularity_filter_not_in_group_by__plan0.sql | 6 +- ..._metric_grouped_by_custom_grain__plan0.sql | 4 +- ..._with_custom_granularity_filter__plan0.sql | 8 +- ...nularity_filter_not_in_group_by__plan0.sql | 6 +- ..._metric_grouped_by_custom_grain__plan0.sql | 4 +- ..._with_custom_granularity_filter__plan0.sql | 8 +- ...nularity_filter_not_in_group_by__plan0.sql | 6 +- ..._metric_grouped_by_custom_grain__plan0.sql | 4 +- ..._with_custom_granularity_filter__plan0.sql | 8 +- ...nularity_filter_not_in_group_by__plan0.sql | 6 +- ...nth_dimension_and_offset_window__plan0.sql | 4 +- ...h_offset_window_and_granularity__plan0.sql | 2 +- ...offset_to_grain_and_granularity__plan0.sql | 4 +- ...ry_have_different_granularities__plan0.sql | 2 +- ...n_metric_multiple_granularities__plan0.sql | 4 +- ...ry_have_different_granularities__plan0.sql | 2 +- ...w_metric_multiple_granularities__plan0.sql | 4 +- ...nth_dimension_and_offset_window__plan0.sql | 4 +- ...h_offset_window_and_granularity__plan0.sql | 2 +- ...offset_to_grain_and_granularity__plan0.sql | 4 +- ...ry_have_different_granularities__plan0.sql | 2 +- ...n_metric_multiple_granularities__plan0.sql | 4 +- ...ry_have_different_granularities__plan0.sql | 2 +- ...w_metric_multiple_granularities__plan0.sql | 4 +- ...nth_dimension_and_offset_window__plan0.sql | 4 +- ...h_offset_window_and_granularity__plan0.sql | 2 +- ...offset_to_grain_and_granularity__plan0.sql | 4 +- ...ry_have_different_granularities__plan0.sql | 2 +- ...n_metric_multiple_granularities__plan0.sql | 4 +- ...ry_have_different_granularities__plan0.sql | 2 +- ...w_metric_multiple_granularities__plan0.sql | 4 +- ...nth_dimension_and_offset_window__plan0.sql | 4 +- ...h_offset_window_and_granularity__plan0.sql | 2 +- ...offset_to_grain_and_granularity__plan0.sql | 4 +- ...ry_have_different_granularities__plan0.sql | 2 +- ...n_metric_multiple_granularities__plan0.sql | 4 +- ...ry_have_different_granularities__plan0.sql | 2 +- ...w_metric_multiple_granularities__plan0.sql | 4 +- ...nth_dimension_and_offset_window__plan0.sql | 4 +- ...h_offset_window_and_granularity__plan0.sql | 2 +- ...offset_to_grain_and_granularity__plan0.sql | 4 +- ...ry_have_different_granularities__plan0.sql | 2 +- ...n_metric_multiple_granularities__plan0.sql | 4 +- ...ry_have_different_granularities__plan0.sql | 2 +- ...w_metric_multiple_granularities__plan0.sql | 4 +- ...nth_dimension_and_offset_window__plan0.sql | 4 +- ...h_offset_window_and_granularity__plan0.sql | 2 +- ...offset_to_grain_and_granularity__plan0.sql | 4 +- ...ry_have_different_granularities__plan0.sql | 2 +- ...n_metric_multiple_granularities__plan0.sql | 4 +- ...ry_have_different_granularities__plan0.sql | 2 +- ...w_metric_multiple_granularities__plan0.sql | 4 +- ...nth_dimension_and_offset_window__plan0.sql | 4 +- ...h_offset_window_and_granularity__plan0.sql | 2 +- ...offset_to_grain_and_granularity__plan0.sql | 4 +- ...ry_have_different_granularities__plan0.sql | 2 +- ...n_metric_multiple_granularities__plan0.sql | 4 +- ...ry_have_different_granularities__plan0.sql | 2 +- ...w_metric_multiple_granularities__plan0.sql | 4 +- ...ine_with_filter_not_in_group_by__plan0.sql | 8 +- ..._not_in_group_by_using_agg_time__plan0.sql | 10 +- ..._using_agg_time_and_metric_time__plan0.sql | 8 +- ...th_filter_smaller_than_group_by__plan0.sql | 10 +- ...smaller_than_group_by__plan0_optimized.sql | 4 +- ...join_to_time_spine_with_filters__plan0.sql | 12 +- ..._simple_fill_nulls_with_0_month__plan0.sql | 4 +- ...ine_with_filter_not_in_group_by__plan0.sql | 8 +- ..._not_in_group_by_using_agg_time__plan0.sql | 10 +- ..._using_agg_time_and_metric_time__plan0.sql | 8 +- ...th_filter_smaller_than_group_by__plan0.sql | 10 +- ...smaller_than_group_by__plan0_optimized.sql | 4 +- ...join_to_time_spine_with_filters__plan0.sql | 12 +- ..._simple_fill_nulls_with_0_month__plan0.sql | 4 +- ...ine_with_filter_not_in_group_by__plan0.sql | 8 +- ..._not_in_group_by_using_agg_time__plan0.sql | 10 +- ..._using_agg_time_and_metric_time__plan0.sql | 8 +- ...th_filter_smaller_than_group_by__plan0.sql | 10 +- ...smaller_than_group_by__plan0_optimized.sql | 4 +- ...join_to_time_spine_with_filters__plan0.sql | 12 +- ..._simple_fill_nulls_with_0_month__plan0.sql | 4 +- ...ine_with_filter_not_in_group_by__plan0.sql | 8 +- ..._not_in_group_by_using_agg_time__plan0.sql | 10 +- ..._using_agg_time_and_metric_time__plan0.sql | 8 +- ...th_filter_smaller_than_group_by__plan0.sql | 10 +- ...smaller_than_group_by__plan0_optimized.sql | 4 +- ...join_to_time_spine_with_filters__plan0.sql | 12 +- ..._simple_fill_nulls_with_0_month__plan0.sql | 4 +- ...ine_with_filter_not_in_group_by__plan0.sql | 8 +- ..._not_in_group_by_using_agg_time__plan0.sql | 10 +- ..._using_agg_time_and_metric_time__plan0.sql | 8 +- ...th_filter_smaller_than_group_by__plan0.sql | 10 +- ...smaller_than_group_by__plan0_optimized.sql | 4 +- ...join_to_time_spine_with_filters__plan0.sql | 12 +- ..._simple_fill_nulls_with_0_month__plan0.sql | 4 +- ...ine_with_filter_not_in_group_by__plan0.sql | 8 +- ..._not_in_group_by_using_agg_time__plan0.sql | 10 +- ..._using_agg_time_and_metric_time__plan0.sql | 8 +- ...th_filter_smaller_than_group_by__plan0.sql | 10 +- ...smaller_than_group_by__plan0_optimized.sql | 4 +- ...join_to_time_spine_with_filters__plan0.sql | 12 +- ..._simple_fill_nulls_with_0_month__plan0.sql | 4 +- ...ine_with_filter_not_in_group_by__plan0.sql | 8 +- ..._not_in_group_by_using_agg_time__plan0.sql | 10 +- ..._using_agg_time_and_metric_time__plan0.sql | 8 +- ...th_filter_smaller_than_group_by__plan0.sql | 10 +- ...smaller_than_group_by__plan0_optimized.sql | 4 +- ...join_to_time_spine_with_filters__plan0.sql | 12 +- ..._simple_fill_nulls_with_0_month__plan0.sql | 4 +- ...st_offset_window_with_date_part__plan0.sql | 2 +- ...ily_time_constraint_with_metric__plan0.sql | 4 +- ...st_offset_window_with_date_part__plan0.sql | 2 +- ...ily_time_constraint_with_metric__plan0.sql | 4 +- ...st_offset_window_with_date_part__plan0.sql | 2 +- ...ily_time_constraint_with_metric__plan0.sql | 4 +- ...st_offset_window_with_date_part__plan0.sql | 2 +- ...ily_time_constraint_with_metric__plan0.sql | 4 +- ...st_offset_window_with_date_part__plan0.sql | 2 +- ...ily_time_constraint_with_metric__plan0.sql | 4 +- ...st_offset_window_with_date_part__plan0.sql | 2 +- ...ily_time_constraint_with_metric__plan0.sql | 4 +- ...st_offset_window_with_date_part__plan0.sql | 2 +- ...ily_time_constraint_with_metric__plan0.sql | 4 +- ...est_derived_metric_alias__query_output.txt | 12 + .../test_metric_alias__query_output.txt | 12 + ...tiple_metrics_with_alias__query_output.txt | 12 + .../test_derived_metric_alias__plan0.sql | 674 ++++++++++++++++++ ..._derived_metric_alias__plan0_optimized.sql | 68 ++ .../DuckDB/test_metric_alias__plan0.sql | 662 +++++++++++++++++ .../test_metric_alias__plan0_optimized.sql | 63 ++ ...e_with_input_measure_constraint__plan0.sql | 4 +- ...ne_with_queried_time_constraint__plan0.sql | 4 +- ...e_with_input_measure_constraint__plan0.sql | 4 +- ...ne_with_queried_time_constraint__plan0.sql | 4 +- ...e_with_input_measure_constraint__plan0.sql | 4 +- ...ne_with_queried_time_constraint__plan0.sql | 4 +- ...e_with_input_measure_constraint__plan0.sql | 4 +- ...ne_with_queried_time_constraint__plan0.sql | 4 +- ...e_with_input_measure_constraint__plan0.sql | 4 +- ...ne_with_queried_time_constraint__plan0.sql | 4 +- ...e_with_input_measure_constraint__plan0.sql | 4 +- ...ne_with_queried_time_constraint__plan0.sql | 4 +- ...e_with_input_measure_constraint__plan0.sql | 4 +- ...ne_with_queried_time_constraint__plan0.sql | 4 +- 204 files changed, 2535 insertions(+), 681 deletions(-) create mode 100644 .changes/unreleased/Features-20241213-110407.yaml create mode 100644 metricflow-semantics/metricflow_semantics/query/issues/parsing/duplicate_metric_alias.py create mode 100644 tests_metricflow/integration/query_output/test_query_output.py create mode 100644 tests_metricflow/snapshots/test_query_output.py/str/DuckDB/test_derived_metric_alias__query_output.txt create mode 100644 tests_metricflow/snapshots/test_query_output.py/str/DuckDB/test_metric_alias__query_output.txt create mode 100644 tests_metricflow/snapshots/test_query_output.py/str/DuckDB/test_multiple_metrics_with_alias__query_output.txt create mode 100644 tests_metricflow/snapshots/test_query_rendering.py/SqlPlan/DuckDB/test_derived_metric_alias__plan0.sql create mode 100644 tests_metricflow/snapshots/test_query_rendering.py/SqlPlan/DuckDB/test_derived_metric_alias__plan0_optimized.sql create mode 100644 tests_metricflow/snapshots/test_query_rendering.py/SqlPlan/DuckDB/test_metric_alias__plan0.sql create mode 100644 tests_metricflow/snapshots/test_query_rendering.py/SqlPlan/DuckDB/test_metric_alias__plan0_optimized.sql diff --git a/.changes/unreleased/Features-20241213-110407.yaml b/.changes/unreleased/Features-20241213-110407.yaml new file mode 100644 index 0000000000..c75106ada7 --- /dev/null +++ b/.changes/unreleased/Features-20241213-110407.yaml @@ -0,0 +1,6 @@ +kind: Features +body: Allow setting aliases for queried metrics +time: 2024-12-13T11:04:07.020346+01:00 +custom: + Author: serramatutu + Issue: "1573" diff --git a/metricflow-semantics/metricflow_semantics/naming/dunder_scheme.py b/metricflow-semantics/metricflow_semantics/naming/dunder_scheme.py index ebef953fdd..dc475e815a 100644 --- a/metricflow-semantics/metricflow_semantics/naming/dunder_scheme.py +++ b/metricflow-semantics/metricflow_semantics/naming/dunder_scheme.py @@ -14,8 +14,8 @@ from metricflow_semantics.specs.instance_spec import InstanceSpec from metricflow_semantics.specs.patterns.entity_link_pattern import ( EntityLinkPattern, - EntityLinkPatternParameterSet, ParameterSetField, + SpecPatternParameterSet, ) from metricflow_semantics.specs.spec_set import InstanceSpecSet, InstanceSpecSetTransform, group_spec_by_type @@ -67,7 +67,7 @@ def spec_pattern(self, input_str: str, semantic_manifest_lookup: SemanticManifes # No dunder, e.g. "ds" if len(input_str_parts) == 1: return EntityLinkPattern( - parameter_set=EntityLinkPatternParameterSet.from_parameters( + parameter_set=SpecPatternParameterSet.from_parameters( element_name=input_str_parts[0], entity_links=(), time_granularity_name=None, @@ -88,7 +88,7 @@ def spec_pattern(self, input_str: str, semantic_manifest_lookup: SemanticManifes # e.g. "ds__month" if len(input_str_parts) == 2: return EntityLinkPattern( - parameter_set=EntityLinkPatternParameterSet.from_parameters( + parameter_set=SpecPatternParameterSet.from_parameters( element_name=input_str_parts[0], entity_links=(), time_granularity_name=time_granularity_name, @@ -98,7 +98,7 @@ def spec_pattern(self, input_str: str, semantic_manifest_lookup: SemanticManifes ) # e.g. "messages__ds__month" return EntityLinkPattern( - parameter_set=EntityLinkPatternParameterSet.from_parameters( + parameter_set=SpecPatternParameterSet.from_parameters( element_name=input_str_parts[-2], entity_links=tuple(EntityReference(entity_name) for entity_name in input_str_parts[:-2]), time_granularity_name=time_granularity_name, @@ -109,7 +109,7 @@ def spec_pattern(self, input_str: str, semantic_manifest_lookup: SemanticManifes # e.g. "messages__ds" return EntityLinkPattern( - parameter_set=EntityLinkPatternParameterSet.from_parameters( + parameter_set=SpecPatternParameterSet.from_parameters( element_name=suffix, entity_links=tuple(EntityReference(entity_name) for entity_name in input_str_parts[:-1]), time_granularity_name=None, diff --git a/metricflow-semantics/metricflow_semantics/naming/metric_scheme.py b/metricflow-semantics/metricflow_semantics/naming/metric_scheme.py index a19407f5d6..e9df698e40 100644 --- a/metricflow-semantics/metricflow_semantics/naming/metric_scheme.py +++ b/metricflow-semantics/metricflow_semantics/naming/metric_scheme.py @@ -2,12 +2,12 @@ from typing import Optional -from dbt_semantic_interfaces.references import MetricReference from typing_extensions import override from metricflow_semantics.model.semantic_manifest_lookup import SemanticManifestLookup from metricflow_semantics.naming.naming_scheme import QueryItemNamingScheme from metricflow_semantics.specs.instance_spec import InstanceSpec +from metricflow_semantics.specs.patterns.entity_link_pattern import ParameterSetField, SpecPatternParameterSet from metricflow_semantics.specs.patterns.metric_pattern import MetricSpecPattern from metricflow_semantics.specs.spec_set import group_spec_by_type @@ -30,7 +30,11 @@ def spec_pattern(self, input_str: str, semantic_manifest_lookup: SemanticManifes input_str = input_str.lower() if not self.input_str_follows_scheme(input_str, semantic_manifest_lookup=semantic_manifest_lookup): raise RuntimeError(f"{repr(input_str)} does not follow this scheme.") - return MetricSpecPattern(metric_reference=MetricReference(element_name=input_str)) + return MetricSpecPattern( + parameter_set=SpecPatternParameterSet.from_parameters( + fields_to_compare=(ParameterSetField.ELEMENT_NAME,), element_name=input_str + ) + ) @override def input_str_follows_scheme(self, input_str: str, semantic_manifest_lookup: SemanticManifestLookup) -> bool: diff --git a/metricflow-semantics/metricflow_semantics/naming/object_builder_scheme.py b/metricflow-semantics/metricflow_semantics/naming/object_builder_scheme.py index 55a3dd51ad..93df6b24af 100644 --- a/metricflow-semantics/metricflow_semantics/naming/object_builder_scheme.py +++ b/metricflow-semantics/metricflow_semantics/naming/object_builder_scheme.py @@ -18,8 +18,8 @@ from metricflow_semantics.specs.instance_spec import InstanceSpec from metricflow_semantics.specs.patterns.entity_link_pattern import ( EntityLinkPattern, - EntityLinkPatternParameterSet, ParameterSetField, + SpecPatternParameterSet, ) from metricflow_semantics.specs.patterns.spec_pattern import SpecPattern from metricflow_semantics.specs.patterns.typed_patterns import DimensionPattern, TimeDimensionPattern @@ -62,7 +62,7 @@ def spec_pattern(self, input_str: str, semantic_manifest_lookup: SemanticManifes for dimension_call_parameter_set in call_parameter_sets.dimension_call_parameter_sets: return DimensionPattern( - EntityLinkPatternParameterSet.from_parameters( + SpecPatternParameterSet.from_parameters( element_name=dimension_call_parameter_set.dimension_reference.element_name, entity_links=dimension_call_parameter_set.entity_path, fields_to_compare=( @@ -84,7 +84,7 @@ def spec_pattern(self, input_str: str, semantic_manifest_lookup: SemanticManifes fields_to_compare.append(ParameterSetField.TIME_GRANULARITY) return TimeDimensionPattern( - EntityLinkPatternParameterSet.from_parameters( + SpecPatternParameterSet.from_parameters( element_name=time_dimension_call_parameter_set.time_dimension_reference.element_name, entity_links=time_dimension_call_parameter_set.entity_path, time_granularity_name=time_dimension_call_parameter_set.time_granularity_name, @@ -95,7 +95,7 @@ def spec_pattern(self, input_str: str, semantic_manifest_lookup: SemanticManifes for entity_call_parameter_set in call_parameter_sets.entity_call_parameter_sets: return EntityLinkPattern( - EntityLinkPatternParameterSet.from_parameters( + SpecPatternParameterSet.from_parameters( element_name=entity_call_parameter_set.entity_reference.element_name, entity_links=entity_call_parameter_set.entity_path, fields_to_compare=( @@ -107,7 +107,7 @@ def spec_pattern(self, input_str: str, semantic_manifest_lookup: SemanticManifes for metric_call_parameter_set in call_parameter_sets.metric_call_parameter_sets: return EntityLinkPattern( - EntityLinkPatternParameterSet.from_parameters( + SpecPatternParameterSet.from_parameters( element_name=metric_call_parameter_set.metric_reference.element_name, entity_links=tuple( EntityReference(element_name=group_by_ref.element_name) diff --git a/metricflow-semantics/metricflow_semantics/protocols/query_parameter.py b/metricflow-semantics/metricflow_semantics/protocols/query_parameter.py index e223966618..2407ba8ac9 100644 --- a/metricflow-semantics/metricflow_semantics/protocols/query_parameter.py +++ b/metricflow-semantics/metricflow_semantics/protocols/query_parameter.py @@ -22,6 +22,11 @@ def name(self) -> str: """The name of the metric.""" raise NotImplementedError + @property + def alias(self) -> Optional[str]: + """The alias of the metric.""" + raise NotImplementedError + def query_resolver_input( # noqa: D102 self, semantic_manifest_lookup: SemanticManifestLookup ) -> ResolverInputForMetric: diff --git a/metricflow-semantics/metricflow_semantics/query/issues/parsing/duplicate_metric_alias.py b/metricflow-semantics/metricflow_semantics/query/issues/parsing/duplicate_metric_alias.py new file mode 100644 index 0000000000..e0121d4bbb --- /dev/null +++ b/metricflow-semantics/metricflow_semantics/query/issues/parsing/duplicate_metric_alias.py @@ -0,0 +1,49 @@ +from __future__ import annotations + +from dataclasses import dataclass +from typing import Sequence, Tuple + +from dbt_semantic_interfaces.references import MetricReference +from typing_extensions import override + +from metricflow_semantics.query.group_by_item.resolution_path import MetricFlowQueryResolutionPath +from metricflow_semantics.query.issues.issues_base import ( + MetricFlowQueryIssueType, + MetricFlowQueryResolutionIssue, +) +from metricflow_semantics.query.resolver_inputs.base_resolver_inputs import MetricFlowQueryResolverInput + + +@dataclass(frozen=True) +class DuplicateMetricAliasIssue(MetricFlowQueryResolutionIssue): + """Describes when there are duplicate metric aliases in a query.""" + + duplicate_metric_references: Tuple[MetricReference, ...] + + @staticmethod + def from_parameters( # noqa: D102 + duplicate_metric_references: Sequence[MetricReference], + query_resolution_path: MetricFlowQueryResolutionPath, + ) -> DuplicateMetricAliasIssue: + return DuplicateMetricAliasIssue( + issue_type=MetricFlowQueryIssueType.ERROR, + parent_issues=(), + duplicate_metric_references=tuple(duplicate_metric_references), + query_resolution_path=query_resolution_path, + ) + + @override + def ui_description(self, associated_input: MetricFlowQueryResolverInput) -> str: + return ( + f"Query contains duplicate metric aliases: " + f"{[metric_reference.element_name for metric_reference in self.duplicate_metric_references]}" + ) + + @override + def with_path_prefix(self, path_prefix: MetricFlowQueryResolutionPath) -> DuplicateMetricAliasIssue: + return DuplicateMetricAliasIssue( + issue_type=self.issue_type, + parent_issues=tuple(issue.with_path_prefix(path_prefix) for issue in self.parent_issues), + query_resolution_path=self.query_resolution_path.with_path_prefix(path_prefix), + duplicate_metric_references=self.duplicate_metric_references, + ) diff --git a/metricflow-semantics/metricflow_semantics/query/query_resolver.py b/metricflow-semantics/metricflow_semantics/query/query_resolver.py index 76eb0a57e0..56a9ad58b6 100644 --- a/metricflow-semantics/metricflow_semantics/query/query_resolver.py +++ b/metricflow-semantics/metricflow_semantics/query/query_resolver.py @@ -2,8 +2,9 @@ import itertools import logging +from collections import defaultdict from dataclasses import dataclass -from typing import List, Optional, Sequence, Set, Tuple +from typing import Dict, List, Optional, Sequence, Set, Tuple from dbt_semantic_interfaces.references import MeasureReference, MetricReference, SemanticModelReference @@ -33,6 +34,7 @@ from metricflow_semantics.query.issues.issues_base import ( MetricFlowQueryResolutionIssueSet, ) +from metricflow_semantics.query.issues.parsing.duplicate_metric_alias import DuplicateMetricAliasIssue from metricflow_semantics.query.issues.parsing.invalid_limit import InvalidLimitIssue from metricflow_semantics.query.issues.parsing.invalid_metric import InvalidMetricIssue from metricflow_semantics.query.issues.parsing.invalid_min_max_only import InvalidMinMaxOnlyIssue @@ -173,11 +175,20 @@ def _resolve_metric_inputs( ) metric_specs: List[MetricSpec] = [] input_to_issue_set_mapping_items: List[InputToIssueSetMappingItem] = [] + alias_to_metrics: Dict[str, List[Tuple[ResolverInputForMetric, MetricReference]]] = defaultdict(list) # Find the metric that matches the metric pattern from the input. for metric_input in metric_inputs: matching_specs = metric_input.spec_pattern.match(available_metric_specs) - if len(matching_specs) != 1: + if len(matching_specs) == 1: + matching_spec = matching_specs[0] + alias = metric_input.spec_pattern.parameter_set.alias + if alias: + matching_spec = matching_spec.with_alias(alias) + metric_specs.append(matching_spec) + resolved_name = matching_spec.alias or matching_spec.qualified_name + alias_to_metrics[resolved_name].append((metric_input, matching_spec.reference)) + else: suggestion_generator = QueryItemSuggestionGenerator( input_naming_scheme=MetricNamingScheme(), input_str=str(metric_input.input_obj), @@ -195,8 +206,23 @@ def _resolve_metric_inputs( ), ) ) - else: - metric_specs.extend(matching_specs) + + # Find any duplicate aliases + for alias, metrics in alias_to_metrics.items(): + if len(metrics) > 1: + metric_inputs = [m[0] for m in metrics] + metric_references = [m[1] for m in metrics] + input_to_issue_set_mapping_items.append( + InputToIssueSetMappingItem( + resolver_input=metric_inputs[0], + issue_set=MetricFlowQueryResolutionIssueSet.from_issue( + DuplicateMetricAliasIssue.from_parameters( + duplicate_metric_references=metric_references, + query_resolution_path=query_resolution_path, + ) + ), + ) + ) return ResolveMetricsResult( metric_specs=tuple(metric_specs), @@ -371,7 +397,11 @@ def _resolve_query(self, resolver_input_for_query: ResolverInputForQuery) -> Met query_resolution_path = MetricFlowQueryResolutionPath.from_path_item( QueryGroupByItemResolutionNode.create( parent_nodes=(), - metrics_in_query=tuple(metric_input.spec_pattern.metric_reference for metric_input in metric_inputs), + metrics_in_query=tuple( + MetricReference(metric_input.spec_pattern.parameter_set.element_name) + for metric_input in metric_inputs + if metric_input.spec_pattern.parameter_set.element_name # for type checker + ), where_filter_intersection=query_level_filter_input.where_filter_intersection, ) ) diff --git a/metricflow-semantics/metricflow_semantics/specs/instance_spec.py b/metricflow-semantics/metricflow_semantics/specs/instance_spec.py index 9cb04b3e8f..a504bd463e 100644 --- a/metricflow-semantics/metricflow_semantics/specs/instance_spec.py +++ b/metricflow-semantics/metricflow_semantics/specs/instance_spec.py @@ -52,6 +52,10 @@ def accept(self, visitor: InstanceSpecVisitor[VisitorOutputT]) -> VisitorOutputT """See Visitable.""" raise NotImplementedError() + def without_filter_specs(self) -> InstanceSpec: + """Return the instance spec without any filtering (for comparison purposes).""" + return self + class InstanceSpecVisitor(Generic[VisitorOutputT], ABC): """Visitor for the InstanceSpec classes.""" diff --git a/metricflow-semantics/metricflow_semantics/specs/metric_spec.py b/metricflow-semantics/metricflow_semantics/specs/metric_spec.py index 3e0d21a35d..73b81e6b9d 100644 --- a/metricflow-semantics/metricflow_semantics/specs/metric_spec.py +++ b/metricflow-semantics/metricflow_semantics/specs/metric_spec.py @@ -49,3 +49,21 @@ def has_time_offset(self) -> bool: # noqa: D102 def without_offset(self) -> MetricSpec: """Represents the metric spec with any time offsets removed.""" return MetricSpec(element_name=self.element_name, filter_spec_set=self.filter_spec_set, alias=self.alias) + + def with_alias(self, alias: Optional[str]) -> MetricSpec: + """Add the alias to the metric spec.""" + return MetricSpec( + element_name=self.element_name, + filter_spec_set=self.filter_spec_set, + alias=alias, + offset_window=self.offset_window, + offset_to_grain=self.offset_to_grain, + ) + + def without_filter_specs(self) -> MetricSpec: # noqa: D102 + return MetricSpec( + element_name=self.element_name, + alias=self.alias, + offset_window=self.offset_window, + offset_to_grain=self.offset_to_grain, + ) diff --git a/metricflow-semantics/metricflow_semantics/specs/patterns/entity_link_pattern.py b/metricflow-semantics/metricflow_semantics/specs/patterns/entity_link_pattern.py index ed1c596ef2..fb8076c049 100644 --- a/metricflow-semantics/metricflow_semantics/specs/patterns/entity_link_pattern.py +++ b/metricflow-semantics/metricflow_semantics/specs/patterns/entity_link_pattern.py @@ -20,7 +20,7 @@ class ParameterSetField(Enum): - """The fields of the EntityLinkPatternParameterSet class used for matching in the EntityLinkPattern. + """The fields of the SpecPatternParameterSet class used for matching in the EntityLinkPattern. Considering moving this to be a part of the specs module / classes. """ @@ -30,6 +30,7 @@ class ParameterSetField(Enum): TIME_GRANULARITY = "time_granularity_name" DATE_PART = "date_part" METRIC_SUBQUERY_ENTITY_LINKS = "metric_subquery_entity_links" + ALIAS = "alias" def __lt__(self, other: Any) -> bool: # type: ignore[misc] """Allow for ordering so that a sequence of these can be consistently represented for test snapshots.""" @@ -39,7 +40,7 @@ def __lt__(self, other: Any) -> bool: # type: ignore[misc] @dataclass(frozen=True) -class EntityLinkPatternParameterSet: +class SpecPatternParameterSet: """See EntityPathPattern for more details.""" # Specify the field values to compare. None can't be used to signal "don't compare" because sometimes a pattern @@ -54,6 +55,7 @@ class EntityLinkPatternParameterSet: time_granularity_name: Optional[str] = None date_part: Optional[DatePart] = None metric_subquery_entity_links: Optional[Tuple[EntityReference, ...]] = None + alias: Optional[str] = None @staticmethod def from_parameters( # noqa: D102 @@ -63,14 +65,16 @@ def from_parameters( # noqa: D102 time_granularity_name: Optional[str] = None, date_part: Optional[DatePart] = None, metric_subquery_entity_links: Optional[Tuple[EntityReference, ...]] = None, - ) -> EntityLinkPatternParameterSet: - return EntityLinkPatternParameterSet( + alias: Optional[str] = None, + ) -> SpecPatternParameterSet: + return SpecPatternParameterSet( fields_to_compare=tuple(sorted(fields_to_compare)), element_name=element_name, entity_links=tuple(entity_links) if entity_links is not None else None, time_granularity_name=time_granularity_name, date_part=date_part, metric_subquery_entity_links=metric_subquery_entity_links, + alias=alias, ) def __post_init__(self) -> None: @@ -91,7 +95,7 @@ class EntityLinkPattern(SpecPattern): The entity links that are specified is used as a suffix match. """ - parameter_set: EntityLinkPatternParameterSet + parameter_set: SpecPatternParameterSet def _match_entity_links(self, candidate_specs: Sequence[LinkableInstanceSpec]) -> Sequence[LinkableInstanceSpec]: assert self.parameter_set.entity_links is not None @@ -129,7 +133,7 @@ def _match_time_granularities( @override def match(self, candidate_specs: Sequence[InstanceSpec]) -> Sequence[LinkableInstanceSpec]: filtered_candidate_specs = group_specs_by_type(candidate_specs).linkable_specs - # Checks that EntityLinkPatternParameterSetField is valid wrt to the parameter set. + # Checks that SpecPatternParameterSetField is valid wrt to the parameter set. # Entity links could be a partial match, so it's handled separately. if ParameterSetField.ENTITY_LINKS in self.parameter_set.fields_to_compare: diff --git a/metricflow-semantics/metricflow_semantics/specs/patterns/metric_pattern.py b/metricflow-semantics/metricflow_semantics/specs/patterns/metric_pattern.py index ef598890ea..86840ac9f6 100644 --- a/metricflow-semantics/metricflow_semantics/specs/patterns/metric_pattern.py +++ b/metricflow-semantics/metricflow_semantics/specs/patterns/metric_pattern.py @@ -1,13 +1,13 @@ from __future__ import annotations from dataclasses import dataclass -from typing import Sequence +from typing import List, Sequence -from dbt_semantic_interfaces.references import MetricReference from typing_extensions import override from metricflow_semantics.specs.instance_spec import InstanceSpec from metricflow_semantics.specs.metric_spec import MetricSpec +from metricflow_semantics.specs.patterns.entity_link_pattern import SpecPatternParameterSet from metricflow_semantics.specs.patterns.spec_pattern import SpecPattern from metricflow_semantics.specs.spec_set import group_specs_by_type @@ -16,11 +16,18 @@ class MetricSpecPattern(SpecPattern): """Matches MetricSpecs that have the given metric_reference.""" - metric_reference: MetricReference + parameter_set: SpecPatternParameterSet @override def match(self, candidate_specs: Sequence[InstanceSpec]) -> Sequence[MetricSpec]: - spec_set = group_specs_by_type(candidate_specs) - return tuple( - metric_name for metric_name in spec_set.metric_specs if metric_name.reference == self.metric_reference - ) + filtered_candidate_specs = group_specs_by_type(candidate_specs).metric_specs + keys_to_check = set(field_to_compare.value for field_to_compare in self.parameter_set.fields_to_compare) + + matching_specs: List[MetricSpec] = [] + parameter_set_values = tuple(getattr(self.parameter_set, key_to_check) for key_to_check in keys_to_check) + for spec in filtered_candidate_specs: + spec_values = tuple(getattr(spec, key_to_check, None) for key_to_check in keys_to_check) + if spec_values == parameter_set_values: + matching_specs.append(spec) + + return matching_specs diff --git a/metricflow-semantics/metricflow_semantics/specs/patterns/typed_patterns.py b/metricflow-semantics/metricflow_semantics/specs/patterns/typed_patterns.py index a5664f9f9e..248d5b94ab 100644 --- a/metricflow-semantics/metricflow_semantics/specs/patterns/typed_patterns.py +++ b/metricflow-semantics/metricflow_semantics/specs/patterns/typed_patterns.py @@ -18,8 +18,8 @@ from metricflow_semantics.specs.instance_spec import InstanceSpec, LinkableInstanceSpec from metricflow_semantics.specs.patterns.entity_link_pattern import ( EntityLinkPattern, - EntityLinkPatternParameterSet, ParameterSetField, + SpecPatternParameterSet, ) from metricflow_semantics.specs.spec_set import group_specs_by_type @@ -42,7 +42,7 @@ def from_call_parameter_set( # noqa: D102 dimension_call_parameter_set: DimensionCallParameterSet, ) -> DimensionPattern: return DimensionPattern( - parameter_set=EntityLinkPatternParameterSet.from_parameters( + parameter_set=SpecPatternParameterSet.from_parameters( fields_to_compare=( ParameterSetField.ELEMENT_NAME, ParameterSetField.ENTITY_LINKS, @@ -91,7 +91,7 @@ def from_call_parameter_set( fields_to_compare.append(ParameterSetField.TIME_GRANULARITY) return TimeDimensionPattern( - parameter_set=EntityLinkPatternParameterSet.from_parameters( + parameter_set=SpecPatternParameterSet.from_parameters( fields_to_compare=tuple(fields_to_compare), element_name=time_dimension_call_parameter_set.time_dimension_reference.element_name, entity_links=time_dimension_call_parameter_set.entity_path, @@ -123,7 +123,7 @@ def match(self, candidate_specs: Sequence[InstanceSpec]) -> Sequence[LinkableIns @staticmethod def from_call_parameter_set(entity_call_parameter_set: EntityCallParameterSet) -> EntityPattern: # noqa: D102 return EntityPattern( - parameter_set=EntityLinkPatternParameterSet.from_parameters( + parameter_set=SpecPatternParameterSet.from_parameters( fields_to_compare=( ParameterSetField.ELEMENT_NAME, ParameterSetField.ENTITY_LINKS, @@ -172,7 +172,7 @@ def from_call_parameter_set( # noqa: D102 # so just use the last entity. Will need to add another param for that later. entity_links = metric_subquery_entity_links[-1:] return GroupByMetricPattern( - parameter_set=EntityLinkPatternParameterSet.from_parameters( + parameter_set=SpecPatternParameterSet.from_parameters( fields_to_compare=( ParameterSetField.ELEMENT_NAME, ParameterSetField.ENTITY_LINKS, diff --git a/metricflow-semantics/metricflow_semantics/specs/query_param_implementations.py b/metricflow-semantics/metricflow_semantics/specs/query_param_implementations.py index 9715ddbf00..b215016392 100644 --- a/metricflow-semantics/metricflow_semantics/specs/query_param_implementations.py +++ b/metricflow-semantics/metricflow_semantics/specs/query_param_implementations.py @@ -27,9 +27,10 @@ ) from metricflow_semantics.specs.patterns.entity_link_pattern import ( EntityLinkPattern, - EntityLinkPatternParameterSet, ParameterSetField, + SpecPatternParameterSet, ) +from metricflow_semantics.specs.patterns.metric_pattern import MetricSpecPattern @dataclass(frozen=True) @@ -47,7 +48,6 @@ def query_resolver_input( # noqa: D102 self, semantic_manifest_lookup: SemanticManifestLookup, ) -> ResolverInputForGroupByItem: - # TODO: [custom granularity] use manifest lookup to handle custom granularities fields_to_compare = [ ParameterSetField.ELEMENT_NAME, ParameterSetField.ENTITY_LINKS, @@ -65,7 +65,7 @@ def query_resolver_input( # noqa: D102 input_obj=self, input_obj_naming_scheme=ObjectBuilderNamingScheme(), spec_pattern=EntityLinkPattern( - EntityLinkPatternParameterSet.from_parameters( + SpecPatternParameterSet.from_parameters( fields_to_compare=tuple(fields_to_compare), element_name=name_structure.element_name, entity_links=tuple(EntityReference(link_name) for link_name in name_structure.entity_link_names), @@ -108,7 +108,7 @@ def query_resolver_input(self, semantic_manifest_lookup: SemanticManifestLookup) input_obj=self, input_obj_naming_scheme=ObjectBuilderNamingScheme(), spec_pattern=EntityLinkPattern( - EntityLinkPatternParameterSet.from_parameters( + SpecPatternParameterSet.from_parameters( fields_to_compare=( ParameterSetField.ELEMENT_NAME, ParameterSetField.ENTITY_LINKS, @@ -128,6 +128,7 @@ class MetricParameter(ProtocolHint[MetricQueryParameter]): """Metric requested in a query.""" name: str + alias: Optional[str] = None @override def _implements_protocol(self) -> MetricQueryParameter: @@ -140,7 +141,13 @@ def query_resolver_input( # noqa: D102 return ResolverInputForMetric( input_obj=self, naming_scheme=naming_scheme, - spec_pattern=naming_scheme.spec_pattern(self.name, semantic_manifest_lookup=semantic_manifest_lookup), + spec_pattern=MetricSpecPattern( + SpecPatternParameterSet.from_parameters( + fields_to_compare=(ParameterSetField.ELEMENT_NAME,), + element_name=self.name.lower(), + alias=self.alias, + ) + ), ) diff --git a/metricflow-semantics/tests_metricflow_semantics/model/semantics/test_linkable_element_set.py b/metricflow-semantics/tests_metricflow_semantics/model/semantics/test_linkable_element_set.py index 1c9a08acc8..e1dd301cd3 100644 --- a/metricflow-semantics/tests_metricflow_semantics/model/semantics/test_linkable_element_set.py +++ b/metricflow-semantics/tests_metricflow_semantics/model/semantics/test_linkable_element_set.py @@ -37,8 +37,8 @@ from metricflow_semantics.model.semantics.linkable_element_set import LinkableElementSet from metricflow_semantics.specs.patterns.entity_link_pattern import ( EntityLinkPattern, - EntityLinkPatternParameterSet, ParameterSetField, + SpecPatternParameterSet, ) from metricflow_semantics.specs.time_dimension_spec import TimeDimensionSpec from metricflow_semantics.time.granularity import ExpandedTimeGranularity @@ -707,7 +707,7 @@ def test_derived_semantic_models(linkable_set: LinkableElementSet) -> None: def test_filter_by_pattern(linkable_set: LinkableElementSet) -> None: """Tests that the specs produced by the set are properly filtered by spec patterns.""" spec_pattern = EntityLinkPattern( - EntityLinkPatternParameterSet( + SpecPatternParameterSet( fields_to_compare=(ParameterSetField.ENTITY_LINKS,), element_name=None, entity_links=(EntityReference("entity_1"),), diff --git a/metricflow-semantics/tests_metricflow_semantics/query/test_query_parser.py b/metricflow-semantics/tests_metricflow_semantics/query/test_query_parser.py index c1b62ed1b2..2cf7b76425 100644 --- a/metricflow-semantics/tests_metricflow_semantics/query/test_query_parser.py +++ b/metricflow-semantics/tests_metricflow_semantics/query/test_query_parser.py @@ -629,7 +629,7 @@ def test_duplicate_metric_query( # noqa: D103 mf_test_configuration: MetricFlowTestConfiguration, bookings_query_parser: MetricFlowQueryParser, ) -> None: - with pytest.raises(InvalidQueryException, match="duplicate metrics"): + with pytest.raises(InvalidQueryException, match="duplicate metric"): bookings_query_parser.parse_and_validate_query( metric_names=["bookings", "bookings"], group_by_names=[MTD], @@ -676,3 +676,32 @@ def test_invalid_group_by_metric(bookings_query_parser: MetricFlowQueryParser) - bookings_query_parser.parse_and_validate_query( metric_names=("bookings",), where_constraint_strs=["{{ Metric('listings', ['garbage']) }} > 1"] ) + + +def test_parse_and_validate_metric_with_duplicate_metric_alias( + request: FixtureRequest, + mf_test_configuration: MetricFlowTestConfiguration, +) -> None: + """Test that a query with duplicate alias fails parsing.""" + bookings_yaml_file = YamlConfigFile(filepath="inline_for_test_1", contents=BOOKINGS_YAML) + metrics_yaml_file = YamlConfigFile(filepath="inline_for_test_1", contents=METRICS_YAML) + revenue_yaml_file = YamlConfigFile(filepath="inline_for_test_1", contents=REVENUE_YAML) + query_parser = query_parser_from_yaml( + [EXAMPLE_PROJECT_CONFIGURATION_YAML_CONFIG_FILE, bookings_yaml_file, revenue_yaml_file, metrics_yaml_file] + ) + + with pytest.raises(InvalidQueryException, match="Query contains duplicate metric aliases"): + query_parser.parse_and_validate_query( + metrics=( + MetricParameter(name="revenue_cumulative", alias="revenue_alias"), + MetricParameter(name="revenue_sub_10", alias="revenue_alias"), + ), + ) + + with pytest.raises(InvalidQueryException, match="Query contains duplicate metric aliases"): + query_parser.parse_and_validate_query( + metrics=( + MetricParameter(name="revenue_cumulative"), + MetricParameter(name="revenue_sub_10", alias="revenue_cumulative"), + ), + ) diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_metric_time_granularity.py/MetricFlowQuerySpec/test_derived_metric_with_defined_metric_time_filter__result_0.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_metric_time_granularity.py/MetricFlowQuerySpec/test_derived_metric_with_defined_metric_time_filter__result_0.txt index 9dc9a1a5d3..2699a4df31 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_metric_time_granularity.py/MetricFlowQuerySpec/test_derived_metric_with_defined_metric_time_filter__result_0.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_metric_time_granularity.py/MetricFlowQuerySpec/test_derived_metric_with_defined_metric_time_filter__result_0.txt @@ -70,7 +70,7 @@ MetricFlowQuerySpec( }, ), spec_pattern=TimeDimensionPattern( - parameter_set=EntityLinkPatternParameterSet( + parameter_set=SpecPatternParameterSet( fields_to_compare=( DATE_PART, ELEMENT_NAME, diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_metric_time_granularity.py/MetricFlowQuerySpec/test_derived_metric_with_defined_metric_time_filter_on_input_metric__result_0.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_metric_time_granularity.py/MetricFlowQuerySpec/test_derived_metric_with_defined_metric_time_filter_on_input_metric__result_0.txt index 9f723ba69f..ce16a2ee8f 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_metric_time_granularity.py/MetricFlowQuerySpec/test_derived_metric_with_defined_metric_time_filter_on_input_metric__result_0.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_metric_time_granularity.py/MetricFlowQuerySpec/test_derived_metric_with_defined_metric_time_filter_on_input_metric__result_0.txt @@ -73,7 +73,7 @@ MetricFlowQuerySpec( }, ), spec_pattern=TimeDimensionPattern( - parameter_set=EntityLinkPatternParameterSet( + parameter_set=SpecPatternParameterSet( fields_to_compare=( DATE_PART, ELEMENT_NAME, @@ -148,7 +148,7 @@ MetricFlowQuerySpec( }, ), spec_pattern=TimeDimensionPattern( - parameter_set=EntityLinkPatternParameterSet( + parameter_set=SpecPatternParameterSet( fields_to_compare=( DATE_PART, ELEMENT_NAME, diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_metric_time_granularity.py/MetricFlowQuerySpec/test_simple_metric_with_defined_metric_time_filter__result_0.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_metric_time_granularity.py/MetricFlowQuerySpec/test_simple_metric_with_defined_metric_time_filter__result_0.txt index 797e834bb5..127b238f74 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_metric_time_granularity.py/MetricFlowQuerySpec/test_simple_metric_with_defined_metric_time_filter__result_0.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_metric_time_granularity.py/MetricFlowQuerySpec/test_simple_metric_with_defined_metric_time_filter__result_0.txt @@ -70,7 +70,7 @@ MetricFlowQuerySpec( }, ), spec_pattern=TimeDimensionPattern( - parameter_set=EntityLinkPatternParameterSet( + parameter_set=SpecPatternParameterSet( fields_to_compare=( DATE_PART, ELEMENT_NAME, diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_parse_and_validate_where_constraint_dims__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_parse_and_validate_where_constraint_dims__result.txt index 001db2de65..99eeb967f5 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_parse_and_validate_where_constraint_dims__result.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_parse_and_validate_where_constraint_dims__result.txt @@ -88,7 +88,7 @@ ParseQueryResult( }, ), spec_pattern=DimensionPattern( - parameter_set=EntityLinkPatternParameterSet( + parameter_set=SpecPatternParameterSet( fields_to_compare=( ELEMENT_NAME, ENTITY_LINKS, diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_derived_metrics_with_common_filtered_metric__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_derived_metrics_with_common_filtered_metric__result.txt index 839676e336..e19a79db83 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_derived_metrics_with_common_filtered_metric__result.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_derived_metrics_with_common_filtered_metric__result.txt @@ -63,7 +63,7 @@ FilterSpecResolutionLookUp( }, ), spec_pattern=TimeDimensionPattern( - parameter_set=EntityLinkPatternParameterSet( + parameter_set=SpecPatternParameterSet( fields_to_compare=(DATE_PART, ELEMENT_NAME, ENTITY_LINKS), element_name='metric_time', ), @@ -133,7 +133,7 @@ FilterSpecResolutionLookUp( }, ), spec_pattern=TimeDimensionPattern( - parameter_set=EntityLinkPatternParameterSet( + parameter_set=SpecPatternParameterSet( fields_to_compare=(DATE_PART, ELEMENT_NAME, ENTITY_LINKS), element_name='metric_time', ), diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_invalid_metric_filter__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_invalid_metric_filter__result.txt index 46a9fa1f16..0763bbfe97 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_invalid_metric_filter__result.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_invalid_metric_filter__result.txt @@ -79,7 +79,7 @@ FilterSpecResolutionLookUp( }, ), spec_pattern=TimeDimensionPattern( - parameter_set=EntityLinkPatternParameterSet( + parameter_set=SpecPatternParameterSet( fields_to_compare=(DATE_PART, ELEMENT_NAME, ENTITY_LINKS), element_name='metric_time', ), diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_invalid_metric_input_filter__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_invalid_metric_input_filter__result.txt index 1a5bd39c60..dfd61452fc 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_invalid_metric_input_filter__result.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_invalid_metric_input_filter__result.txt @@ -79,7 +79,7 @@ FilterSpecResolutionLookUp( }, ), spec_pattern=TimeDimensionPattern( - parameter_set=EntityLinkPatternParameterSet( + parameter_set=SpecPatternParameterSet( fields_to_compare=(DATE_PART, ELEMENT_NAME, ENTITY_LINKS), element_name='metric_time', ), diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_valid_metric_filter__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_valid_metric_filter__result.txt index 3454083665..4e58e4af87 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_valid_metric_filter__result.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_valid_metric_filter__result.txt @@ -59,7 +59,7 @@ FilterSpecResolutionLookUp( }, ), spec_pattern=TimeDimensionPattern( - parameter_set=EntityLinkPatternParameterSet( + parameter_set=SpecPatternParameterSet( fields_to_compare=(DATE_PART, ELEMENT_NAME, ENTITY_LINKS), element_name='metric_time', ), diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_valid_metric_input_filter__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_valid_metric_input_filter__result.txt index 308995b06e..9cd44c5df8 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_valid_metric_input_filter__result.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_resolution_for_valid_metric_input_filter__result.txt @@ -59,7 +59,7 @@ FilterSpecResolutionLookUp( }, ), spec_pattern=TimeDimensionPattern( - parameter_set=EntityLinkPatternParameterSet( + parameter_set=SpecPatternParameterSet( fields_to_compare=(DATE_PART, ELEMENT_NAME, ENTITY_LINKS), element_name='metric_time', ), diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__accumulate_last_2_months_metric__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__accumulate_last_2_months_metric__result.txt index 31d4c89e6a..95e158a3fc 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__accumulate_last_2_months_metric__result.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__accumulate_last_2_months_metric__result.txt @@ -59,7 +59,7 @@ FilterSpecResolutionLookUp( }, ), spec_pattern=TimeDimensionPattern( - parameter_set=EntityLinkPatternParameterSet( + parameter_set=SpecPatternParameterSet( fields_to_compare=(DATE_PART, ELEMENT_NAME, ENTITY_LINKS), element_name='metric_time', ), diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__derived_metric_with_different_parent_time_grains__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__derived_metric_with_different_parent_time_grains__result.txt index 217d51ca7b..e376a271b6 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__derived_metric_with_different_parent_time_grains__result.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__derived_metric_with_different_parent_time_grains__result.txt @@ -79,7 +79,7 @@ FilterSpecResolutionLookUp( }, ), spec_pattern=TimeDimensionPattern( - parameter_set=EntityLinkPatternParameterSet( + parameter_set=SpecPatternParameterSet( fields_to_compare=(DATE_PART, ELEMENT_NAME, ENTITY_LINKS), element_name='metric_time', ), diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__derived_metric_with_same_parent_time_grains__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__derived_metric_with_same_parent_time_grains__result.txt index c76f6bfced..31b879aff3 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__derived_metric_with_same_parent_time_grains__result.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__derived_metric_with_same_parent_time_grains__result.txt @@ -59,7 +59,7 @@ FilterSpecResolutionLookUp( }, ), spec_pattern=TimeDimensionPattern( - parameter_set=EntityLinkPatternParameterSet( + parameter_set=SpecPatternParameterSet( fields_to_compare=(DATE_PART, ELEMENT_NAME, ENTITY_LINKS), element_name='metric_time', ), diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__metrics_with_different_time_grains__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__metrics_with_different_time_grains__result.txt index 6428a20047..681ba2c31f 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__metrics_with_different_time_grains__result.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__metrics_with_different_time_grains__result.txt @@ -82,7 +82,7 @@ FilterSpecResolutionLookUp( }, ), spec_pattern=TimeDimensionPattern( - parameter_set=EntityLinkPatternParameterSet( + parameter_set=SpecPatternParameterSet( fields_to_compare=(DATE_PART, ELEMENT_NAME, ENTITY_LINKS), element_name='metric_time', ), diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__metrics_with_same_time_grains__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__metrics_with_same_time_grains__result.txt index 6ab013fa68..be9e27c70d 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__metrics_with_same_time_grains__result.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__metrics_with_same_time_grains__result.txt @@ -62,7 +62,7 @@ FilterSpecResolutionLookUp( }, ), spec_pattern=TimeDimensionPattern( - parameter_set=EntityLinkPatternParameterSet( + parameter_set=SpecPatternParameterSet( fields_to_compare=(DATE_PART, ELEMENT_NAME, ENTITY_LINKS), element_name='metric_time', ), diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__simple_metric__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__simple_metric__result.txt index 4fc159012b..d816efffd9 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__simple_metric__result.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__simple_metric__result.txt @@ -59,7 +59,7 @@ FilterSpecResolutionLookUp( }, ), spec_pattern=TimeDimensionPattern( - parameter_set=EntityLinkPatternParameterSet( + parameter_set=SpecPatternParameterSet( fields_to_compare=(DATE_PART, ELEMENT_NAME, ENTITY_LINKS), element_name='metric_time', ), diff --git a/metricflow-semantics/tests_metricflow_semantics/specs/patterns/test_entity_link_pattern.py b/metricflow-semantics/tests_metricflow_semantics/specs/patterns/test_entity_link_pattern.py index 3d29fb4996..b2907b2357 100644 --- a/metricflow-semantics/tests_metricflow_semantics/specs/patterns/test_entity_link_pattern.py +++ b/metricflow-semantics/tests_metricflow_semantics/specs/patterns/test_entity_link_pattern.py @@ -15,8 +15,8 @@ from metricflow_semantics.specs.instance_spec import LinkableInstanceSpec from metricflow_semantics.specs.patterns.entity_link_pattern import ( EntityLinkPattern, - EntityLinkPatternParameterSet, ParameterSetField, + SpecPatternParameterSet, ) from metricflow_semantics.specs.time_dimension_spec import TimeDimensionSpec from metricflow_semantics.test_helpers.metric_time_dimension import MTD_SPEC_MONTH, MTD_SPEC_WEEK, MTD_SPEC_YEAR @@ -66,8 +66,8 @@ def specs() -> Sequence[LinkableInstanceSpec]: # noqa: D103 def test_valid_parameter_fields() -> None: - """Tests that ParameterSetField.value maps to a valid field in EntityLinkPatternParameterSet.""" - parameter_set = EntityLinkPatternParameterSet.from_parameters(fields_to_compare=()) + """Tests that ParameterSetField.value maps to a valid field in SpecPatternParameterSet.""" + parameter_set = SpecPatternParameterSet.from_parameters(fields_to_compare=()) parameter_set_dict = set(asdict(parameter_set).keys()) for spec_field in ParameterSetField: assert spec_field.value in parameter_set_dict, f"{spec_field} is not a valid field for {parameter_set}" @@ -75,7 +75,7 @@ def test_valid_parameter_fields() -> None: def test_dimension_match(specs: Sequence[LinkableInstanceSpec]) -> None: # noqa: D103 pattern = EntityLinkPattern( - EntityLinkPatternParameterSet.from_parameters( + SpecPatternParameterSet.from_parameters( element_name="is_instant", entity_links=(EntityReference(element_name="booking"),), fields_to_compare=( @@ -92,7 +92,7 @@ def test_dimension_match(specs: Sequence[LinkableInstanceSpec]) -> None: # noqa def test_entity_match(specs: Sequence[LinkableInstanceSpec]) -> None: # noqa: D103 pattern = EntityLinkPattern( - EntityLinkPatternParameterSet.from_parameters( + SpecPatternParameterSet.from_parameters( element_name="listing", entity_links=(EntityReference(element_name="booking"),), fields_to_compare=( @@ -109,7 +109,7 @@ def test_entity_match(specs: Sequence[LinkableInstanceSpec]) -> None: # noqa: D def test_group_by_metric_match(specs: Sequence[LinkableInstanceSpec]) -> None: # noqa: D103 pattern = EntityLinkPattern( - EntityLinkPatternParameterSet.from_parameters( + SpecPatternParameterSet.from_parameters( element_name="bookings", entity_links=(EntityReference(element_name="listing"),), fields_to_compare=( @@ -130,7 +130,7 @@ def test_group_by_metric_match(specs: Sequence[LinkableInstanceSpec]) -> None: def test_time_dimension_match(specs: Sequence[LinkableInstanceSpec]) -> None: # noqa: D103 pattern = EntityLinkPattern( - EntityLinkPatternParameterSet.from_parameters( + SpecPatternParameterSet.from_parameters( element_name=METRIC_TIME_ELEMENT_NAME, entity_links=(), time_granularity_name=TimeGranularity.WEEK.value, @@ -147,7 +147,7 @@ def test_time_dimension_match(specs: Sequence[LinkableInstanceSpec]) -> None: # def test_time_dimension_match_without_grain_specified(specs: Sequence[LinkableInstanceSpec]) -> None: # noqa: D103 pattern = EntityLinkPattern( - EntityLinkPatternParameterSet.from_parameters( + SpecPatternParameterSet.from_parameters( element_name=METRIC_TIME_ELEMENT_NAME, entity_links=(), fields_to_compare=( @@ -167,7 +167,7 @@ def test_time_dimension_match_without_grain_specified(specs: Sequence[LinkableIn def test_time_dimension_date_part_mismatch(specs: Sequence[LinkableInstanceSpec]) -> None: """Checks that a None for the date_part field does not match to a non-None value.""" pattern = EntityLinkPattern( - EntityLinkPatternParameterSet.from_parameters( + SpecPatternParameterSet.from_parameters( element_name="creation_time", fields_to_compare=( ParameterSetField.ELEMENT_NAME, @@ -182,7 +182,7 @@ def test_time_dimension_date_part_mismatch(specs: Sequence[LinkableInstanceSpec] def test_time_dimension_date_part_match(specs: Sequence[LinkableInstanceSpec]) -> None: """Checks that a correct date_part field produces a match.""" pattern = EntityLinkPattern( - EntityLinkPatternParameterSet.from_parameters( + SpecPatternParameterSet.from_parameters( element_name="creation_time", date_part=DatePart.YEAR, fields_to_compare=( diff --git a/metricflow/dataflow/builder/dataflow_plan_builder.py b/metricflow/dataflow/builder/dataflow_plan_builder.py index b44271fa9c..528733a3f0 100644 --- a/metricflow/dataflow/builder/dataflow_plan_builder.py +++ b/metricflow/dataflow/builder/dataflow_plan_builder.py @@ -156,13 +156,15 @@ def _build_query_output_node( self, query_spec: MetricFlowQuerySpec, for_group_by_source_node: bool = False ) -> DataflowPlanNode: """Build SQL output node from query inputs. May be used to build query DFP or source node.""" + metric_specs: Tuple[MetricSpec, ...] = () for metric_spec in query_spec.metric_specs: if ( len(metric_spec.filter_spec_set.all_filter_specs) > 0 or metric_spec.offset_to_grain is not None or metric_spec.offset_window is not None - or metric_spec.alias is not None ): + # Remove aliases here. They will be added back at the very end of the query. + metric_specs += (metric_spec.with_alias(None),) if metric_spec.alias else (metric_spec,) raise ValueError( f"The metric specs in the query spec should not contain any metric modifiers. Got: {metric_spec}" ) @@ -213,6 +215,7 @@ def _build_plan( sink_node = DataflowPlanBuilder.build_sink_node( parent_node=metrics_output_node, + metric_specs=query_spec.metric_specs, order_by_specs=query_spec.order_by_specs, output_sql_table=output_sql_table, limit=query_spec.limit, @@ -866,7 +869,10 @@ def _build_plan_for_distinct_values( output_node = MinMaxNode.create(parent_node=output_node) sink_node = self.build_sink_node( - parent_node=output_node, order_by_specs=query_spec.order_by_specs, limit=query_spec.limit + parent_node=output_node, + metric_specs=query_spec.metric_specs, + order_by_specs=query_spec.order_by_specs, + limit=query_spec.limit, ) plan = DataflowPlan(sink_nodes=[sink_node]) @@ -875,6 +881,7 @@ def _build_plan_for_distinct_values( @staticmethod def build_sink_node( parent_node: DataflowPlanNode, + metric_specs: Sequence[MetricSpec], order_by_specs: Sequence[OrderBySpec], output_sql_table: Optional[SqlTable] = None, limit: Optional[int] = None, @@ -893,6 +900,16 @@ def build_sink_node( parent_node=pre_result_node or parent_node, include_specs=output_selection_specs ) + alias_specs = tuple( + SpecToAlias(MetricSpec(metric.element_name), MetricSpec(metric.element_name, alias=metric.alias)) + for metric in metric_specs + if metric.alias is not None + ) + if len(alias_specs) > 0: + pre_result_node = AliasSpecsNode.create( + parent_node=pre_result_node or parent_node, change_specs=alias_specs + ) + write_result_node: DataflowPlanNode if not output_sql_table: write_result_node = WriteToResultDataTableNode.create(parent_node=pre_result_node or parent_node) diff --git a/metricflow/dataset/sql_dataset.py b/metricflow/dataset/sql_dataset.py index afa5593879..a1ce708850 100644 --- a/metricflow/dataset/sql_dataset.py +++ b/metricflow/dataset/sql_dataset.py @@ -164,6 +164,22 @@ def instance_for_spec(self, spec: InstanceSpec) -> MdoInstance: str(LazyFormat("Did not find instance matching spec in dataset.", spec=spec, instances=instances)) ) + def instance_for_column_name(self, column_name: str) -> MdoInstance: + """Given a spec, return the instance associated with it in the data set.""" + instances = self.instance_set.as_tuple + for instance in instances: + if instance.associated_column.column_name == column_name: + return instance + raise RuntimeError( + str( + LazyFormat( + "Did not find instance matching column name in dataset.", + column_name=column_name, + instances=instances, + ) + ) + ) + def instance_from_time_dimension_grain_and_date_part( self, time_dimension_spec: TimeDimensionSpec ) -> TimeDimensionInstance: diff --git a/metricflow/plan_conversion/dataflow_to_sql.py b/metricflow/plan_conversion/dataflow_to_sql.py index cd6b92a2b0..59634dbf9d 100644 --- a/metricflow/plan_conversion/dataflow_to_sql.py +++ b/metricflow/plan_conversion/dataflow_to_sql.py @@ -2,7 +2,7 @@ import datetime as dt import logging -from collections import OrderedDict +from collections import OrderedDict, defaultdict from typing import Callable, Dict, FrozenSet, List, Optional, Sequence, Set, Tuple, TypeVar from dbt_semantic_interfaces.enum_extension import assert_values_exhausted @@ -1529,51 +1529,47 @@ def visit_alias_specs_node(self, node: AliasSpecsNode) -> SqlDataSet: # noqa: D parent_data_set = node.parent_node.accept(self) parent_alias = self._next_unique_table_alias() - new_instances: Tuple[MdoInstance, ...] = () - new_select_columns: Tuple[SqlSelectColumn, ...] = () - instances_to_remove_from_parent: Set[MdoInstance] = set() - for spec_to_alias in node.change_specs: - old_spec = spec_to_alias.input_spec - new_spec = spec_to_alias.output_spec - - # Find the instance in the parent data set with matching grain & date part. - old_instance = parent_data_set.instance_for_spec(old_spec) - - # Build new instance & select column to match requested spec. - new_instance = old_instance.with_new_spec( - new_spec=new_spec, column_association_resolver=self._column_association_resolver - ) - new_expr = SqlColumnReferenceExpression.from_table_and_column_names( - table_alias=parent_alias, column_name=old_instance.associated_column.column_name - ) - new_select_column = SqlSelectColumn(expr=new_expr, column_alias=new_instance.associated_column.column_name) - instances_to_remove_from_parent.add(old_instance) - new_instances += (new_instance,) - new_select_columns += (new_select_column,) - - # Build full output instance set. - filtered_parent_instance_set = group_instances_by_type( - tuple( - instance - for instance in parent_data_set.instance_set.as_tuple - if instance not in instances_to_remove_from_parent - ) - ) - new_instance_set = group_instances_by_type(new_instances) - transformed_instance_set = InstanceSet.merge([filtered_parent_instance_set, new_instance_set]) - - # Build final select columns. - filtered_parent_select_columns = create_simple_select_columns_for_instance_sets( - column_resolver=self._column_association_resolver, - table_alias_to_instance_set=OrderedDict({parent_alias: filtered_parent_instance_set}), - ) - transformed_select_columns = new_select_columns + filtered_parent_select_columns + input_specs_to_output_specs: Dict[InstanceSpec, List[InstanceSpec]] = defaultdict(list) + for change_spec in node.change_specs: + input_specs_to_output_specs[change_spec.input_spec].append(change_spec.output_spec) + + # Build output instances & select columns. + output_instances: Tuple[MdoInstance, ...] = () + output_select_columns: Tuple[SqlSelectColumn, ...] = () + for parent_instance in parent_data_set.instance_set.as_tuple: + if parent_instance.spec.without_filter_specs() in input_specs_to_output_specs: + # If an alias was requested, build new instance & select column to match requested spec. + new_specs = input_specs_to_output_specs[parent_instance.spec.without_filter_specs()] + for new_spec in new_specs: + new_instance = parent_instance.with_new_spec( + new_spec=new_spec, column_association_resolver=self._column_association_resolver + ) + new_select_column = SqlSelectColumn( + expr=SqlColumnReferenceExpression.from_table_and_column_names( + table_alias=parent_alias, column_name=parent_instance.associated_column.column_name + ), + column_alias=new_instance.associated_column.column_name, + ) + output_instances += (new_instance,) + output_select_columns += (new_select_column,) + else: + # Keep the instance the same and build a column that just references the parent column. + output_instances += (parent_instance,) + column_name = parent_instance.associated_column.column_name + output_select_columns += ( + SqlSelectColumn( + expr=SqlColumnReferenceExpression.from_table_and_column_names( + table_alias=parent_alias, column_name=column_name + ), + column_alias=column_name, + ), + ) return SqlDataSet( - instance_set=transformed_instance_set, + instance_set=group_instances_by_type(output_instances), sql_select_node=SqlSelectStatementNode.create( description=node.description, - select_columns=transformed_select_columns, + select_columns=output_select_columns, from_source=parent_data_set.checked_sql_select_node, from_source_alias=parent_alias, ), diff --git a/tests_metricflow/integration/query_output/test_query_output.py b/tests_metricflow/integration/query_output/test_query_output.py new file mode 100644 index 0000000000..1e3b420a92 --- /dev/null +++ b/tests_metricflow/integration/query_output/test_query_output.py @@ -0,0 +1,95 @@ +from __future__ import annotations + +import pytest +from _pytest.fixtures import FixtureRequest +from metricflow_semantics.specs.query_param_implementations import MetricParameter +from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration + +from metricflow.engine.metricflow_engine import MetricFlowQueryRequest +from metricflow.protocols.sql_client import SqlClient +from tests_metricflow.integration.conftest import IntegrationTestHelpers +from tests_metricflow.snapshot_utils import assert_str_snapshot_equal + + +@pytest.mark.sql_engine_snapshot +@pytest.mark.duckdb_only +def test_metric_alias( # noqa: D103 + request: FixtureRequest, + mf_test_configuration: MetricFlowTestConfiguration, + sql_client: SqlClient, + it_helpers: IntegrationTestHelpers, +) -> None: + query_result = it_helpers.mf_engine.query( + MetricFlowQueryRequest.create_with_random_request_id( + metrics=(MetricParameter(name="bookings", alias="bookings_alias"),), + group_by_names=["metric_time__day"], + order_by_names=["metric_time__day"], + where_constraints=("{{ Metric('bookings', ['listing']) }} > 2",), + ) + ) + assert query_result.result_df is not None, "Unexpected empty result." + + assert_str_snapshot_equal( + request=request, + mf_test_configuration=mf_test_configuration, + snapshot_id="query_output", + snapshot_str=query_result.result_df.text_format(), + sql_engine=sql_client.sql_engine_type, + ) + + +@pytest.mark.sql_engine_snapshot +@pytest.mark.duckdb_only +def test_multiple_metrics_with_alias( # noqa: D103 + request: FixtureRequest, + mf_test_configuration: MetricFlowTestConfiguration, + sql_client: SqlClient, + it_helpers: IntegrationTestHelpers, +) -> None: + query_result = it_helpers.mf_engine.query( + MetricFlowQueryRequest.create_with_random_request_id( + metrics=( + MetricParameter(name="bookings", alias="bookings_alias"), + MetricParameter(name="booking_fees", alias="bookings_fees_alias"), + ), + group_by_names=["metric_time__day"], + order_by_names=["metric_time__day"], + where_constraints=("{{ Metric('bookings', ['listing']) }} > 2",), + ) + ) + assert query_result.result_df is not None, "Unexpected empty result." + + assert_str_snapshot_equal( + request=request, + mf_test_configuration=mf_test_configuration, + snapshot_id="query_output", + snapshot_str=query_result.result_df.text_format(), + sql_engine=sql_client.sql_engine_type, + ) + + +@pytest.mark.sql_engine_snapshot +@pytest.mark.duckdb_only +def test_derived_metric_alias( # noqa: D103 + request: FixtureRequest, + mf_test_configuration: MetricFlowTestConfiguration, + sql_client: SqlClient, + it_helpers: IntegrationTestHelpers, +) -> None: + query_result = it_helpers.mf_engine.query( + MetricFlowQueryRequest.create_with_random_request_id( + metrics=(MetricParameter(name="booking_fees", alias="booking_fees_alias"),), + group_by_names=["metric_time__day"], + order_by_names=["metric_time__day"], + where_constraints=("{{ Metric('bookings', ['listing']) }} > 2",), + ) + ) + assert query_result.result_df is not None, "Unexpected empty result." + + assert_str_snapshot_equal( + request=request, + mf_test_configuration=mf_test_configuration, + snapshot_id="query_output", + snapshot_str=query_result.result_df.text_format(), + sql_engine=sql_client.sql_engine_type, + ) diff --git a/tests_metricflow/query_rendering/test_query_rendering.py b/tests_metricflow/query_rendering/test_query_rendering.py index 8bc4096426..1ed196f974 100644 --- a/tests_metricflow/query_rendering/test_query_rendering.py +++ b/tests_metricflow/query_rendering/test_query_rendering.py @@ -20,6 +20,10 @@ from metricflow_semantics.specs.column_assoc import ColumnAssociationResolver from metricflow_semantics.specs.dimension_spec import DimensionSpec from metricflow_semantics.specs.metric_spec import MetricSpec +from metricflow_semantics.specs.query_param_implementations import ( + MetricParameter, + OrderByParameter, +) from metricflow_semantics.specs.query_spec import MetricFlowQuerySpec from metricflow_semantics.specs.time_dimension_spec import TimeDimensionSpec from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration @@ -603,3 +607,63 @@ def test_non_additive_dimension_with_non_default_grain( dataflow_plan_builder=dataflow_plan_builder, query_spec=query_spec, ) + + +@pytest.mark.sql_engine_snapshot +@pytest.mark.duckdb_only +def test_metric_alias( + request: FixtureRequest, + mf_test_configuration: MetricFlowTestConfiguration, + dataflow_plan_builder: DataflowPlanBuilder, + sql_client: SqlClient, + query_parser: MetricFlowQueryParser, + dataflow_to_sql_converter: DataflowToSqlQueryPlanConverter, +) -> None: + """Tests a plan with an aliased metric.""" + metric = MetricParameter(name="bookings", alias="bookings_alias") + + query_spec = query_parser.parse_and_validate_query( + metrics=(metric,), + group_by_names=("metric_time__month",), + order_by=(OrderByParameter(metric),), + where_constraint_strs=("{{ Metric('bookings', ['listing']) }} > 2",), + ).query_spec + + render_and_check( + request=request, + mf_test_configuration=mf_test_configuration, + dataflow_to_sql_converter=dataflow_to_sql_converter, + sql_client=sql_client, + dataflow_plan_builder=dataflow_plan_builder, + query_spec=query_spec, + ) + + +@pytest.mark.sql_engine_snapshot +@pytest.mark.duckdb_only +def test_derived_metric_alias( + request: FixtureRequest, + mf_test_configuration: MetricFlowTestConfiguration, + dataflow_plan_builder: DataflowPlanBuilder, + sql_client: SqlClient, + query_parser: MetricFlowQueryParser, + dataflow_to_sql_converter: DataflowToSqlQueryPlanConverter, +) -> None: + """Tests a plan with an aliased metric.""" + metric = MetricParameter(name="booking_fees", alias="bookings_alias") + + query_spec = query_parser.parse_and_validate_query( + metrics=(metric,), + group_by_names=("metric_time__day",), + order_by=(OrderByParameter(metric),), + where_constraint_strs=("{{ Metric('booking_fees', ['listing']) }} > 2",), + ).query_spec + + render_and_check( + request=request, + mf_test_configuration=mf_test_configuration, + dataflow_to_sql_converter=dataflow_to_sql_converter, + sql_client=sql_client, + dataflow_plan_builder=dataflow_plan_builder, + query_spec=query_spec, + ) diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/BigQuery/test_window_metric_with_non_default_grains__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/BigQuery/test_window_metric_with_non_default_grains__plan0.sql index d34c8f316d..b80296ef87 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/BigQuery/test_window_metric_with_non_default_grains__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/BigQuery/test_window_metric_with_non_default_grains__plan0.sql @@ -8,47 +8,47 @@ sql_engine: BigQuery --- -- Re-aggregate Metric via Group By SELECT - subq_12.booking__ds__month - , subq_12.metric_time__week + subq_12.metric_time__week + , subq_12.booking__ds__month , subq_12.every_two_days_bookers_fill_nulls_with_0 FROM ( -- Window Function for Metric Re-aggregation SELECT - subq_11.booking__ds__month - , subq_11.metric_time__week + subq_11.metric_time__week + , subq_11.booking__ds__month , FIRST_VALUE(subq_11.every_two_days_bookers_fill_nulls_with_0) OVER ( PARTITION BY - subq_11.booking__ds__month - , subq_11.metric_time__week + subq_11.metric_time__week + , subq_11.booking__ds__month ORDER BY subq_11.metric_time__day ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS every_two_days_bookers_fill_nulls_with_0 FROM ( -- Compute Metrics via Expressions SELECT - subq_10.booking__ds__month + subq_10.metric_time__day , subq_10.metric_time__week - , subq_10.metric_time__day + , subq_10.booking__ds__month , COALESCE(subq_10.bookers, 0) AS every_two_days_bookers_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_9.booking__ds__month AS booking__ds__month + subq_9.metric_time__day AS metric_time__day , subq_9.metric_time__week AS metric_time__week - , subq_9.metric_time__day AS metric_time__day + , subq_9.booking__ds__month AS booking__ds__month , subq_6.bookers AS bookers FROM ( -- Pass Only Elements: ['booking__ds__month', 'metric_time__week', 'metric_time__day'] SELECT - subq_8.booking__ds__month + subq_8.metric_time__day , subq_8.metric_time__week - , subq_8.metric_time__day + , subq_8.booking__ds__month FROM ( -- Change Column Aliases SELECT - subq_7.ds__month AS booking__ds__month + subq_7.ds__day AS metric_time__day , subq_7.ds__week AS metric_time__week - , subq_7.ds__day AS metric_time__day + , subq_7.ds__month AS booking__ds__month , subq_7.ds__quarter , subq_7.ds__year , subq_7.ds__extract_year @@ -414,6 +414,6 @@ FROM ( ) subq_11 ) subq_12 GROUP BY - booking__ds__month - , metric_time__week + metric_time__week + , booking__ds__month , every_two_days_bookers_fill_nulls_with_0 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/BigQuery/test_window_metric_with_non_default_grains__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/BigQuery/test_window_metric_with_non_default_grains__plan0_optimized.sql index 2773539027..829c5b9c7f 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/BigQuery/test_window_metric_with_non_default_grains__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/BigQuery/test_window_metric_with_non_default_grains__plan0_optimized.sql @@ -8,28 +8,28 @@ sql_engine: BigQuery --- -- Re-aggregate Metric via Group By SELECT - booking__ds__month - , metric_time__week + metric_time__week + , booking__ds__month , every_two_days_bookers_fill_nulls_with_0 FROM ( -- Compute Metrics via Expressions -- Window Function for Metric Re-aggregation SELECT - booking__ds__month - , metric_time__week + metric_time__week + , booking__ds__month , FIRST_VALUE(COALESCE(bookers, 0)) OVER ( PARTITION BY - booking__ds__month - , metric_time__week + metric_time__week + , booking__ds__month ORDER BY metric_time__day ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS every_two_days_bookers_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - DATETIME_TRUNC(time_spine_src_28006.ds, month) AS booking__ds__month + time_spine_src_28006.ds AS metric_time__day , DATETIME_TRUNC(time_spine_src_28006.ds, isoweek) AS metric_time__week - , time_spine_src_28006.ds AS metric_time__day + , DATETIME_TRUNC(time_spine_src_28006.ds, month) AS booking__ds__month , subq_19.bookers AS bookers FROM ***************************.mf_time_spine time_spine_src_28006 LEFT OUTER JOIN ( @@ -60,6 +60,6 @@ FROM ( ) subq_23 ) subq_25 GROUP BY - booking__ds__month - , metric_time__week + metric_time__week + , booking__ds__month , every_two_days_bookers_fill_nulls_with_0 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Databricks/test_window_metric_with_non_default_grains__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Databricks/test_window_metric_with_non_default_grains__plan0.sql index 460a9a1f96..14e7619fbc 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Databricks/test_window_metric_with_non_default_grains__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Databricks/test_window_metric_with_non_default_grains__plan0.sql @@ -8,47 +8,47 @@ sql_engine: Databricks --- -- Re-aggregate Metric via Group By SELECT - subq_12.booking__ds__month - , subq_12.metric_time__week + subq_12.metric_time__week + , subq_12.booking__ds__month , subq_12.every_two_days_bookers_fill_nulls_with_0 FROM ( -- Window Function for Metric Re-aggregation SELECT - subq_11.booking__ds__month - , subq_11.metric_time__week + subq_11.metric_time__week + , subq_11.booking__ds__month , FIRST_VALUE(subq_11.every_two_days_bookers_fill_nulls_with_0) OVER ( PARTITION BY - subq_11.booking__ds__month - , subq_11.metric_time__week + subq_11.metric_time__week + , subq_11.booking__ds__month ORDER BY subq_11.metric_time__day ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS every_two_days_bookers_fill_nulls_with_0 FROM ( -- Compute Metrics via Expressions SELECT - subq_10.booking__ds__month + subq_10.metric_time__day , subq_10.metric_time__week - , subq_10.metric_time__day + , subq_10.booking__ds__month , COALESCE(subq_10.bookers, 0) AS every_two_days_bookers_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_9.booking__ds__month AS booking__ds__month + subq_9.metric_time__day AS metric_time__day , subq_9.metric_time__week AS metric_time__week - , subq_9.metric_time__day AS metric_time__day + , subq_9.booking__ds__month AS booking__ds__month , subq_6.bookers AS bookers FROM ( -- Pass Only Elements: ['booking__ds__month', 'metric_time__week', 'metric_time__day'] SELECT - subq_8.booking__ds__month + subq_8.metric_time__day , subq_8.metric_time__week - , subq_8.metric_time__day + , subq_8.booking__ds__month FROM ( -- Change Column Aliases SELECT - subq_7.ds__month AS booking__ds__month + subq_7.ds__day AS metric_time__day , subq_7.ds__week AS metric_time__week - , subq_7.ds__day AS metric_time__day + , subq_7.ds__month AS booking__ds__month , subq_7.ds__quarter , subq_7.ds__year , subq_7.ds__extract_year @@ -414,6 +414,6 @@ FROM ( ) subq_11 ) subq_12 GROUP BY - subq_12.booking__ds__month - , subq_12.metric_time__week + subq_12.metric_time__week + , subq_12.booking__ds__month , subq_12.every_two_days_bookers_fill_nulls_with_0 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Databricks/test_window_metric_with_non_default_grains__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Databricks/test_window_metric_with_non_default_grains__plan0_optimized.sql index 9a4804c24e..8727e7d31c 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Databricks/test_window_metric_with_non_default_grains__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Databricks/test_window_metric_with_non_default_grains__plan0_optimized.sql @@ -8,28 +8,28 @@ sql_engine: Databricks --- -- Re-aggregate Metric via Group By SELECT - booking__ds__month - , metric_time__week + metric_time__week + , booking__ds__month , every_two_days_bookers_fill_nulls_with_0 FROM ( -- Compute Metrics via Expressions -- Window Function for Metric Re-aggregation SELECT - booking__ds__month - , metric_time__week + metric_time__week + , booking__ds__month , FIRST_VALUE(COALESCE(bookers, 0)) OVER ( PARTITION BY - booking__ds__month - , metric_time__week + metric_time__week + , booking__ds__month ORDER BY metric_time__day ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS every_two_days_bookers_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('month', time_spine_src_28006.ds) AS booking__ds__month + time_spine_src_28006.ds AS metric_time__day , DATE_TRUNC('week', time_spine_src_28006.ds) AS metric_time__week - , time_spine_src_28006.ds AS metric_time__day + , DATE_TRUNC('month', time_spine_src_28006.ds) AS booking__ds__month , subq_19.bookers AS bookers FROM ***************************.mf_time_spine time_spine_src_28006 LEFT OUTER JOIN ( @@ -60,6 +60,6 @@ FROM ( ) subq_23 ) subq_25 GROUP BY - booking__ds__month - , metric_time__week + metric_time__week + , booking__ds__month , every_two_days_bookers_fill_nulls_with_0 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/DuckDB/test_window_metric_with_non_default_grains__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/DuckDB/test_window_metric_with_non_default_grains__plan0.sql index b8dee179a7..9d55e9c268 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/DuckDB/test_window_metric_with_non_default_grains__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/DuckDB/test_window_metric_with_non_default_grains__plan0.sql @@ -8,47 +8,47 @@ sql_engine: DuckDB --- -- Re-aggregate Metric via Group By SELECT - subq_12.booking__ds__month - , subq_12.metric_time__week + subq_12.metric_time__week + , subq_12.booking__ds__month , subq_12.every_two_days_bookers_fill_nulls_with_0 FROM ( -- Window Function for Metric Re-aggregation SELECT - subq_11.booking__ds__month - , subq_11.metric_time__week + subq_11.metric_time__week + , subq_11.booking__ds__month , FIRST_VALUE(subq_11.every_two_days_bookers_fill_nulls_with_0) OVER ( PARTITION BY - subq_11.booking__ds__month - , subq_11.metric_time__week + subq_11.metric_time__week + , subq_11.booking__ds__month ORDER BY subq_11.metric_time__day ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS every_two_days_bookers_fill_nulls_with_0 FROM ( -- Compute Metrics via Expressions SELECT - subq_10.booking__ds__month + subq_10.metric_time__day , subq_10.metric_time__week - , subq_10.metric_time__day + , subq_10.booking__ds__month , COALESCE(subq_10.bookers, 0) AS every_two_days_bookers_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_9.booking__ds__month AS booking__ds__month + subq_9.metric_time__day AS metric_time__day , subq_9.metric_time__week AS metric_time__week - , subq_9.metric_time__day AS metric_time__day + , subq_9.booking__ds__month AS booking__ds__month , subq_6.bookers AS bookers FROM ( -- Pass Only Elements: ['booking__ds__month', 'metric_time__week', 'metric_time__day'] SELECT - subq_8.booking__ds__month + subq_8.metric_time__day , subq_8.metric_time__week - , subq_8.metric_time__day + , subq_8.booking__ds__month FROM ( -- Change Column Aliases SELECT - subq_7.ds__month AS booking__ds__month + subq_7.ds__day AS metric_time__day , subq_7.ds__week AS metric_time__week - , subq_7.ds__day AS metric_time__day + , subq_7.ds__month AS booking__ds__month , subq_7.ds__quarter , subq_7.ds__year , subq_7.ds__extract_year @@ -414,6 +414,6 @@ FROM ( ) subq_11 ) subq_12 GROUP BY - subq_12.booking__ds__month - , subq_12.metric_time__week + subq_12.metric_time__week + , subq_12.booking__ds__month , subq_12.every_two_days_bookers_fill_nulls_with_0 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/DuckDB/test_window_metric_with_non_default_grains__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/DuckDB/test_window_metric_with_non_default_grains__plan0_optimized.sql index e22a6a6837..813a5c4272 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/DuckDB/test_window_metric_with_non_default_grains__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/DuckDB/test_window_metric_with_non_default_grains__plan0_optimized.sql @@ -8,28 +8,28 @@ sql_engine: DuckDB --- -- Re-aggregate Metric via Group By SELECT - booking__ds__month - , metric_time__week + metric_time__week + , booking__ds__month , every_two_days_bookers_fill_nulls_with_0 FROM ( -- Compute Metrics via Expressions -- Window Function for Metric Re-aggregation SELECT - booking__ds__month - , metric_time__week + metric_time__week + , booking__ds__month , FIRST_VALUE(COALESCE(bookers, 0)) OVER ( PARTITION BY - booking__ds__month - , metric_time__week + metric_time__week + , booking__ds__month ORDER BY metric_time__day ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS every_two_days_bookers_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('month', time_spine_src_28006.ds) AS booking__ds__month + time_spine_src_28006.ds AS metric_time__day , DATE_TRUNC('week', time_spine_src_28006.ds) AS metric_time__week - , time_spine_src_28006.ds AS metric_time__day + , DATE_TRUNC('month', time_spine_src_28006.ds) AS booking__ds__month , subq_19.bookers AS bookers FROM ***************************.mf_time_spine time_spine_src_28006 LEFT OUTER JOIN ( @@ -60,6 +60,6 @@ FROM ( ) subq_23 ) subq_25 GROUP BY - booking__ds__month - , metric_time__week + metric_time__week + , booking__ds__month , every_two_days_bookers_fill_nulls_with_0 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Postgres/test_window_metric_with_non_default_grains__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Postgres/test_window_metric_with_non_default_grains__plan0.sql index 148fc930cb..37bd232b10 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Postgres/test_window_metric_with_non_default_grains__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Postgres/test_window_metric_with_non_default_grains__plan0.sql @@ -8,47 +8,47 @@ sql_engine: Postgres --- -- Re-aggregate Metric via Group By SELECT - subq_12.booking__ds__month - , subq_12.metric_time__week + subq_12.metric_time__week + , subq_12.booking__ds__month , subq_12.every_two_days_bookers_fill_nulls_with_0 FROM ( -- Window Function for Metric Re-aggregation SELECT - subq_11.booking__ds__month - , subq_11.metric_time__week + subq_11.metric_time__week + , subq_11.booking__ds__month , FIRST_VALUE(subq_11.every_two_days_bookers_fill_nulls_with_0) OVER ( PARTITION BY - subq_11.booking__ds__month - , subq_11.metric_time__week + subq_11.metric_time__week + , subq_11.booking__ds__month ORDER BY subq_11.metric_time__day ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS every_two_days_bookers_fill_nulls_with_0 FROM ( -- Compute Metrics via Expressions SELECT - subq_10.booking__ds__month + subq_10.metric_time__day , subq_10.metric_time__week - , subq_10.metric_time__day + , subq_10.booking__ds__month , COALESCE(subq_10.bookers, 0) AS every_two_days_bookers_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_9.booking__ds__month AS booking__ds__month + subq_9.metric_time__day AS metric_time__day , subq_9.metric_time__week AS metric_time__week - , subq_9.metric_time__day AS metric_time__day + , subq_9.booking__ds__month AS booking__ds__month , subq_6.bookers AS bookers FROM ( -- Pass Only Elements: ['booking__ds__month', 'metric_time__week', 'metric_time__day'] SELECT - subq_8.booking__ds__month + subq_8.metric_time__day , subq_8.metric_time__week - , subq_8.metric_time__day + , subq_8.booking__ds__month FROM ( -- Change Column Aliases SELECT - subq_7.ds__month AS booking__ds__month + subq_7.ds__day AS metric_time__day , subq_7.ds__week AS metric_time__week - , subq_7.ds__day AS metric_time__day + , subq_7.ds__month AS booking__ds__month , subq_7.ds__quarter , subq_7.ds__year , subq_7.ds__extract_year @@ -414,6 +414,6 @@ FROM ( ) subq_11 ) subq_12 GROUP BY - subq_12.booking__ds__month - , subq_12.metric_time__week + subq_12.metric_time__week + , subq_12.booking__ds__month , subq_12.every_two_days_bookers_fill_nulls_with_0 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Postgres/test_window_metric_with_non_default_grains__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Postgres/test_window_metric_with_non_default_grains__plan0_optimized.sql index 983a2828ca..cc60bb9014 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Postgres/test_window_metric_with_non_default_grains__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Postgres/test_window_metric_with_non_default_grains__plan0_optimized.sql @@ -8,28 +8,28 @@ sql_engine: Postgres --- -- Re-aggregate Metric via Group By SELECT - booking__ds__month - , metric_time__week + metric_time__week + , booking__ds__month , every_two_days_bookers_fill_nulls_with_0 FROM ( -- Compute Metrics via Expressions -- Window Function for Metric Re-aggregation SELECT - booking__ds__month - , metric_time__week + metric_time__week + , booking__ds__month , FIRST_VALUE(COALESCE(bookers, 0)) OVER ( PARTITION BY - booking__ds__month - , metric_time__week + metric_time__week + , booking__ds__month ORDER BY metric_time__day ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS every_two_days_bookers_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('month', time_spine_src_28006.ds) AS booking__ds__month + time_spine_src_28006.ds AS metric_time__day , DATE_TRUNC('week', time_spine_src_28006.ds) AS metric_time__week - , time_spine_src_28006.ds AS metric_time__day + , DATE_TRUNC('month', time_spine_src_28006.ds) AS booking__ds__month , subq_19.bookers AS bookers FROM ***************************.mf_time_spine time_spine_src_28006 LEFT OUTER JOIN ( @@ -60,6 +60,6 @@ FROM ( ) subq_23 ) subq_25 GROUP BY - booking__ds__month - , metric_time__week + metric_time__week + , booking__ds__month , every_two_days_bookers_fill_nulls_with_0 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Redshift/test_window_metric_with_non_default_grains__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Redshift/test_window_metric_with_non_default_grains__plan0.sql index b8b61ce77d..c55d61cf46 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Redshift/test_window_metric_with_non_default_grains__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Redshift/test_window_metric_with_non_default_grains__plan0.sql @@ -8,47 +8,47 @@ sql_engine: Redshift --- -- Re-aggregate Metric via Group By SELECT - subq_12.booking__ds__month - , subq_12.metric_time__week + subq_12.metric_time__week + , subq_12.booking__ds__month , subq_12.every_two_days_bookers_fill_nulls_with_0 FROM ( -- Window Function for Metric Re-aggregation SELECT - subq_11.booking__ds__month - , subq_11.metric_time__week + subq_11.metric_time__week + , subq_11.booking__ds__month , FIRST_VALUE(subq_11.every_two_days_bookers_fill_nulls_with_0) OVER ( PARTITION BY - subq_11.booking__ds__month - , subq_11.metric_time__week + subq_11.metric_time__week + , subq_11.booking__ds__month ORDER BY subq_11.metric_time__day ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS every_two_days_bookers_fill_nulls_with_0 FROM ( -- Compute Metrics via Expressions SELECT - subq_10.booking__ds__month + subq_10.metric_time__day , subq_10.metric_time__week - , subq_10.metric_time__day + , subq_10.booking__ds__month , COALESCE(subq_10.bookers, 0) AS every_two_days_bookers_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_9.booking__ds__month AS booking__ds__month + subq_9.metric_time__day AS metric_time__day , subq_9.metric_time__week AS metric_time__week - , subq_9.metric_time__day AS metric_time__day + , subq_9.booking__ds__month AS booking__ds__month , subq_6.bookers AS bookers FROM ( -- Pass Only Elements: ['booking__ds__month', 'metric_time__week', 'metric_time__day'] SELECT - subq_8.booking__ds__month + subq_8.metric_time__day , subq_8.metric_time__week - , subq_8.metric_time__day + , subq_8.booking__ds__month FROM ( -- Change Column Aliases SELECT - subq_7.ds__month AS booking__ds__month + subq_7.ds__day AS metric_time__day , subq_7.ds__week AS metric_time__week - , subq_7.ds__day AS metric_time__day + , subq_7.ds__month AS booking__ds__month , subq_7.ds__quarter , subq_7.ds__year , subq_7.ds__extract_year @@ -414,6 +414,6 @@ FROM ( ) subq_11 ) subq_12 GROUP BY - subq_12.booking__ds__month - , subq_12.metric_time__week + subq_12.metric_time__week + , subq_12.booking__ds__month , subq_12.every_two_days_bookers_fill_nulls_with_0 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Redshift/test_window_metric_with_non_default_grains__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Redshift/test_window_metric_with_non_default_grains__plan0_optimized.sql index 48882b6b0c..9ea0b17537 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Redshift/test_window_metric_with_non_default_grains__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Redshift/test_window_metric_with_non_default_grains__plan0_optimized.sql @@ -8,28 +8,28 @@ sql_engine: Redshift --- -- Re-aggregate Metric via Group By SELECT - booking__ds__month - , metric_time__week + metric_time__week + , booking__ds__month , every_two_days_bookers_fill_nulls_with_0 FROM ( -- Compute Metrics via Expressions -- Window Function for Metric Re-aggregation SELECT - booking__ds__month - , metric_time__week + metric_time__week + , booking__ds__month , FIRST_VALUE(COALESCE(bookers, 0)) OVER ( PARTITION BY - booking__ds__month - , metric_time__week + metric_time__week + , booking__ds__month ORDER BY metric_time__day ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS every_two_days_bookers_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('month', time_spine_src_28006.ds) AS booking__ds__month + time_spine_src_28006.ds AS metric_time__day , DATE_TRUNC('week', time_spine_src_28006.ds) AS metric_time__week - , time_spine_src_28006.ds AS metric_time__day + , DATE_TRUNC('month', time_spine_src_28006.ds) AS booking__ds__month , subq_19.bookers AS bookers FROM ***************************.mf_time_spine time_spine_src_28006 LEFT OUTER JOIN ( @@ -60,6 +60,6 @@ FROM ( ) subq_23 ) subq_25 GROUP BY - booking__ds__month - , metric_time__week + metric_time__week + , booking__ds__month , every_two_days_bookers_fill_nulls_with_0 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Snowflake/test_window_metric_with_non_default_grains__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Snowflake/test_window_metric_with_non_default_grains__plan0.sql index 9b5d199cb0..2160300141 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Snowflake/test_window_metric_with_non_default_grains__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Snowflake/test_window_metric_with_non_default_grains__plan0.sql @@ -8,47 +8,47 @@ sql_engine: Snowflake --- -- Re-aggregate Metric via Group By SELECT - subq_12.booking__ds__month - , subq_12.metric_time__week + subq_12.metric_time__week + , subq_12.booking__ds__month , subq_12.every_two_days_bookers_fill_nulls_with_0 FROM ( -- Window Function for Metric Re-aggregation SELECT - subq_11.booking__ds__month - , subq_11.metric_time__week + subq_11.metric_time__week + , subq_11.booking__ds__month , FIRST_VALUE(subq_11.every_two_days_bookers_fill_nulls_with_0) OVER ( PARTITION BY - subq_11.booking__ds__month - , subq_11.metric_time__week + subq_11.metric_time__week + , subq_11.booking__ds__month ORDER BY subq_11.metric_time__day ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS every_two_days_bookers_fill_nulls_with_0 FROM ( -- Compute Metrics via Expressions SELECT - subq_10.booking__ds__month + subq_10.metric_time__day , subq_10.metric_time__week - , subq_10.metric_time__day + , subq_10.booking__ds__month , COALESCE(subq_10.bookers, 0) AS every_two_days_bookers_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_9.booking__ds__month AS booking__ds__month + subq_9.metric_time__day AS metric_time__day , subq_9.metric_time__week AS metric_time__week - , subq_9.metric_time__day AS metric_time__day + , subq_9.booking__ds__month AS booking__ds__month , subq_6.bookers AS bookers FROM ( -- Pass Only Elements: ['booking__ds__month', 'metric_time__week', 'metric_time__day'] SELECT - subq_8.booking__ds__month + subq_8.metric_time__day , subq_8.metric_time__week - , subq_8.metric_time__day + , subq_8.booking__ds__month FROM ( -- Change Column Aliases SELECT - subq_7.ds__month AS booking__ds__month + subq_7.ds__day AS metric_time__day , subq_7.ds__week AS metric_time__week - , subq_7.ds__day AS metric_time__day + , subq_7.ds__month AS booking__ds__month , subq_7.ds__quarter , subq_7.ds__year , subq_7.ds__extract_year @@ -414,6 +414,6 @@ FROM ( ) subq_11 ) subq_12 GROUP BY - subq_12.booking__ds__month - , subq_12.metric_time__week + subq_12.metric_time__week + , subq_12.booking__ds__month , subq_12.every_two_days_bookers_fill_nulls_with_0 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Snowflake/test_window_metric_with_non_default_grains__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Snowflake/test_window_metric_with_non_default_grains__plan0_optimized.sql index 4a5e31a4fc..69ca59ef0e 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Snowflake/test_window_metric_with_non_default_grains__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Snowflake/test_window_metric_with_non_default_grains__plan0_optimized.sql @@ -8,28 +8,28 @@ sql_engine: Snowflake --- -- Re-aggregate Metric via Group By SELECT - booking__ds__month - , metric_time__week + metric_time__week + , booking__ds__month , every_two_days_bookers_fill_nulls_with_0 FROM ( -- Compute Metrics via Expressions -- Window Function for Metric Re-aggregation SELECT - booking__ds__month - , metric_time__week + metric_time__week + , booking__ds__month , FIRST_VALUE(COALESCE(bookers, 0)) OVER ( PARTITION BY - booking__ds__month - , metric_time__week + metric_time__week + , booking__ds__month ORDER BY metric_time__day ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS every_two_days_bookers_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('month', time_spine_src_28006.ds) AS booking__ds__month + time_spine_src_28006.ds AS metric_time__day , DATE_TRUNC('week', time_spine_src_28006.ds) AS metric_time__week - , time_spine_src_28006.ds AS metric_time__day + , DATE_TRUNC('month', time_spine_src_28006.ds) AS booking__ds__month , subq_19.bookers AS bookers FROM ***************************.mf_time_spine time_spine_src_28006 LEFT OUTER JOIN ( @@ -60,6 +60,6 @@ FROM ( ) subq_23 ) subq_25 GROUP BY - booking__ds__month - , metric_time__week + metric_time__week + , booking__ds__month , every_two_days_bookers_fill_nulls_with_0 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Trino/test_window_metric_with_non_default_grains__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Trino/test_window_metric_with_non_default_grains__plan0.sql index a895385e11..683266f1a4 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Trino/test_window_metric_with_non_default_grains__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Trino/test_window_metric_with_non_default_grains__plan0.sql @@ -8,47 +8,47 @@ sql_engine: Trino --- -- Re-aggregate Metric via Group By SELECT - subq_12.booking__ds__month - , subq_12.metric_time__week + subq_12.metric_time__week + , subq_12.booking__ds__month , subq_12.every_two_days_bookers_fill_nulls_with_0 FROM ( -- Window Function for Metric Re-aggregation SELECT - subq_11.booking__ds__month - , subq_11.metric_time__week + subq_11.metric_time__week + , subq_11.booking__ds__month , FIRST_VALUE(subq_11.every_two_days_bookers_fill_nulls_with_0) OVER ( PARTITION BY - subq_11.booking__ds__month - , subq_11.metric_time__week + subq_11.metric_time__week + , subq_11.booking__ds__month ORDER BY subq_11.metric_time__day ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS every_two_days_bookers_fill_nulls_with_0 FROM ( -- Compute Metrics via Expressions SELECT - subq_10.booking__ds__month + subq_10.metric_time__day , subq_10.metric_time__week - , subq_10.metric_time__day + , subq_10.booking__ds__month , COALESCE(subq_10.bookers, 0) AS every_two_days_bookers_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_9.booking__ds__month AS booking__ds__month + subq_9.metric_time__day AS metric_time__day , subq_9.metric_time__week AS metric_time__week - , subq_9.metric_time__day AS metric_time__day + , subq_9.booking__ds__month AS booking__ds__month , subq_6.bookers AS bookers FROM ( -- Pass Only Elements: ['booking__ds__month', 'metric_time__week', 'metric_time__day'] SELECT - subq_8.booking__ds__month + subq_8.metric_time__day , subq_8.metric_time__week - , subq_8.metric_time__day + , subq_8.booking__ds__month FROM ( -- Change Column Aliases SELECT - subq_7.ds__month AS booking__ds__month + subq_7.ds__day AS metric_time__day , subq_7.ds__week AS metric_time__week - , subq_7.ds__day AS metric_time__day + , subq_7.ds__month AS booking__ds__month , subq_7.ds__quarter , subq_7.ds__year , subq_7.ds__extract_year @@ -414,6 +414,6 @@ FROM ( ) subq_11 ) subq_12 GROUP BY - subq_12.booking__ds__month - , subq_12.metric_time__week + subq_12.metric_time__week + , subq_12.booking__ds__month , subq_12.every_two_days_bookers_fill_nulls_with_0 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Trino/test_window_metric_with_non_default_grains__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Trino/test_window_metric_with_non_default_grains__plan0_optimized.sql index 86b0938c51..82242858a4 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Trino/test_window_metric_with_non_default_grains__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlPlan/Trino/test_window_metric_with_non_default_grains__plan0_optimized.sql @@ -8,28 +8,28 @@ sql_engine: Trino --- -- Re-aggregate Metric via Group By SELECT - booking__ds__month - , metric_time__week + metric_time__week + , booking__ds__month , every_two_days_bookers_fill_nulls_with_0 FROM ( -- Compute Metrics via Expressions -- Window Function for Metric Re-aggregation SELECT - booking__ds__month - , metric_time__week + metric_time__week + , booking__ds__month , FIRST_VALUE(COALESCE(bookers, 0)) OVER ( PARTITION BY - booking__ds__month - , metric_time__week + metric_time__week + , booking__ds__month ORDER BY metric_time__day ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS every_two_days_bookers_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('month', time_spine_src_28006.ds) AS booking__ds__month + time_spine_src_28006.ds AS metric_time__day , DATE_TRUNC('week', time_spine_src_28006.ds) AS metric_time__week - , time_spine_src_28006.ds AS metric_time__day + , DATE_TRUNC('month', time_spine_src_28006.ds) AS booking__ds__month , subq_19.bookers AS bookers FROM ***************************.mf_time_spine time_spine_src_28006 LEFT OUTER JOIN ( @@ -60,6 +60,6 @@ FROM ( ) subq_23 ) subq_25 GROUP BY - booking__ds__month - , metric_time__week + metric_time__week + , booking__ds__month , every_two_days_bookers_fill_nulls_with_0 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_join_to_time_spine_metric_grouped_by_custom_grain__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_join_to_time_spine_metric_grouped_by_custom_grain__plan0.sql index f5c717f0e4..1d00bd7796 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_join_to_time_spine_metric_grouped_by_custom_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_join_to_time_spine_metric_grouped_by_custom_grain__plan0.sql @@ -18,8 +18,7 @@ FROM ( FROM ( -- Change Column Aliases SELECT - subq_5.ds__martian_day AS metric_time__martian_day - , subq_5.ds__day AS metric_time__day + subq_5.ds__day AS metric_time__day , subq_5.ds__week , subq_5.ds__month , subq_5.ds__quarter @@ -30,6 +29,7 @@ FROM ( , subq_5.ds__extract_day , subq_5.ds__extract_dow , subq_5.ds__extract_doy + , subq_5.ds__martian_day AS metric_time__martian_day FROM ( -- Read From Time Spine 'mf_time_spine' SELECT diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_join_to_timespine_metric_with_custom_granularity_filter__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_join_to_timespine_metric_with_custom_granularity_filter__plan0.sql index 0cf0886a44..e56180a7be 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_join_to_timespine_metric_with_custom_granularity_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_join_to_timespine_metric_with_custom_granularity_filter__plan0.sql @@ -18,7 +18,8 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__week + subq_7.metric_time__day + , subq_7.ds__week , subq_7.ds__month , subq_7.ds__quarter , subq_7.ds__year @@ -29,12 +30,10 @@ FROM ( , subq_7.ds__extract_dow , subq_7.ds__extract_doy , subq_7.metric_time__martian_day - , subq_7.metric_time__day FROM ( -- Change Column Aliases SELECT - subq_6.ds__martian_day AS metric_time__martian_day - , subq_6.ds__day AS metric_time__day + subq_6.ds__day AS metric_time__day , subq_6.ds__week , subq_6.ds__month , subq_6.ds__quarter @@ -45,6 +44,7 @@ FROM ( , subq_6.ds__extract_day , subq_6.ds__extract_dow , subq_6.ds__extract_doy + , subq_6.ds__martian_day AS metric_time__martian_day FROM ( -- Read From Time Spine 'mf_time_spine' SELECT diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_join_to_timespine_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_join_to_timespine_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql index 318501924a..b140eb6b2e 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_join_to_timespine_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_join_to_timespine_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql @@ -18,7 +18,8 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__week + subq_7.metric_time__day + , subq_7.ds__week , subq_7.ds__month , subq_7.ds__quarter , subq_7.ds__year @@ -28,13 +29,11 @@ FROM ( , subq_7.ds__extract_day , subq_7.ds__extract_dow , subq_7.ds__extract_doy - , subq_7.metric_time__day , subq_7.metric_time__martian_day FROM ( -- Change Column Aliases SELECT subq_6.ds__day AS metric_time__day - , subq_6.ds__martian_day AS metric_time__martian_day , subq_6.ds__week , subq_6.ds__month , subq_6.ds__quarter @@ -45,6 +44,7 @@ FROM ( , subq_6.ds__extract_day , subq_6.ds__extract_dow , subq_6.ds__extract_doy + , subq_6.ds__martian_day AS metric_time__martian_day FROM ( -- Read From Time Spine 'mf_time_spine' SELECT diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_join_to_time_spine_metric_grouped_by_custom_grain__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_join_to_time_spine_metric_grouped_by_custom_grain__plan0.sql index 18a5d12a01..1114fa9224 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_join_to_time_spine_metric_grouped_by_custom_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_join_to_time_spine_metric_grouped_by_custom_grain__plan0.sql @@ -18,8 +18,7 @@ FROM ( FROM ( -- Change Column Aliases SELECT - subq_5.ds__martian_day AS metric_time__martian_day - , subq_5.ds__day AS metric_time__day + subq_5.ds__day AS metric_time__day , subq_5.ds__week , subq_5.ds__month , subq_5.ds__quarter @@ -30,6 +29,7 @@ FROM ( , subq_5.ds__extract_day , subq_5.ds__extract_dow , subq_5.ds__extract_doy + , subq_5.ds__martian_day AS metric_time__martian_day FROM ( -- Read From Time Spine 'mf_time_spine' SELECT diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_join_to_timespine_metric_with_custom_granularity_filter__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_join_to_timespine_metric_with_custom_granularity_filter__plan0.sql index 78e1b6c1ba..3e3de4ddbf 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_join_to_timespine_metric_with_custom_granularity_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_join_to_timespine_metric_with_custom_granularity_filter__plan0.sql @@ -18,7 +18,8 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__week + subq_7.metric_time__day + , subq_7.ds__week , subq_7.ds__month , subq_7.ds__quarter , subq_7.ds__year @@ -29,12 +30,10 @@ FROM ( , subq_7.ds__extract_dow , subq_7.ds__extract_doy , subq_7.metric_time__martian_day - , subq_7.metric_time__day FROM ( -- Change Column Aliases SELECT - subq_6.ds__martian_day AS metric_time__martian_day - , subq_6.ds__day AS metric_time__day + subq_6.ds__day AS metric_time__day , subq_6.ds__week , subq_6.ds__month , subq_6.ds__quarter @@ -45,6 +44,7 @@ FROM ( , subq_6.ds__extract_day , subq_6.ds__extract_dow , subq_6.ds__extract_doy + , subq_6.ds__martian_day AS metric_time__martian_day FROM ( -- Read From Time Spine 'mf_time_spine' SELECT diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_join_to_timespine_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_join_to_timespine_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql index 62557cf252..00cf119558 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_join_to_timespine_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_join_to_timespine_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql @@ -18,7 +18,8 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__week + subq_7.metric_time__day + , subq_7.ds__week , subq_7.ds__month , subq_7.ds__quarter , subq_7.ds__year @@ -28,13 +29,11 @@ FROM ( , subq_7.ds__extract_day , subq_7.ds__extract_dow , subq_7.ds__extract_doy - , subq_7.metric_time__day , subq_7.metric_time__martian_day FROM ( -- Change Column Aliases SELECT subq_6.ds__day AS metric_time__day - , subq_6.ds__martian_day AS metric_time__martian_day , subq_6.ds__week , subq_6.ds__month , subq_6.ds__quarter @@ -45,6 +44,7 @@ FROM ( , subq_6.ds__extract_day , subq_6.ds__extract_dow , subq_6.ds__extract_doy + , subq_6.ds__martian_day AS metric_time__martian_day FROM ( -- Read From Time Spine 'mf_time_spine' SELECT diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/DuckDB/test_join_to_time_spine_metric_grouped_by_custom_grain__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/DuckDB/test_join_to_time_spine_metric_grouped_by_custom_grain__plan0.sql index c97759a07c..8da69f58bb 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/DuckDB/test_join_to_time_spine_metric_grouped_by_custom_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/DuckDB/test_join_to_time_spine_metric_grouped_by_custom_grain__plan0.sql @@ -18,8 +18,7 @@ FROM ( FROM ( -- Change Column Aliases SELECT - subq_5.ds__martian_day AS metric_time__martian_day - , subq_5.ds__day AS metric_time__day + subq_5.ds__day AS metric_time__day , subq_5.ds__week , subq_5.ds__month , subq_5.ds__quarter @@ -30,6 +29,7 @@ FROM ( , subq_5.ds__extract_day , subq_5.ds__extract_dow , subq_5.ds__extract_doy + , subq_5.ds__martian_day AS metric_time__martian_day FROM ( -- Read From Time Spine 'mf_time_spine' SELECT diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/DuckDB/test_join_to_timespine_metric_with_custom_granularity_filter__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/DuckDB/test_join_to_timespine_metric_with_custom_granularity_filter__plan0.sql index 710baa9d84..8c1303b809 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/DuckDB/test_join_to_timespine_metric_with_custom_granularity_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/DuckDB/test_join_to_timespine_metric_with_custom_granularity_filter__plan0.sql @@ -18,7 +18,8 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__week + subq_7.metric_time__day + , subq_7.ds__week , subq_7.ds__month , subq_7.ds__quarter , subq_7.ds__year @@ -29,12 +30,10 @@ FROM ( , subq_7.ds__extract_dow , subq_7.ds__extract_doy , subq_7.metric_time__martian_day - , subq_7.metric_time__day FROM ( -- Change Column Aliases SELECT - subq_6.ds__martian_day AS metric_time__martian_day - , subq_6.ds__day AS metric_time__day + subq_6.ds__day AS metric_time__day , subq_6.ds__week , subq_6.ds__month , subq_6.ds__quarter @@ -45,6 +44,7 @@ FROM ( , subq_6.ds__extract_day , subq_6.ds__extract_dow , subq_6.ds__extract_doy + , subq_6.ds__martian_day AS metric_time__martian_day FROM ( -- Read From Time Spine 'mf_time_spine' SELECT diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/DuckDB/test_join_to_timespine_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/DuckDB/test_join_to_timespine_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql index 156e5cb5e4..f60a3d48e1 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/DuckDB/test_join_to_timespine_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/DuckDB/test_join_to_timespine_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql @@ -18,7 +18,8 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__week + subq_7.metric_time__day + , subq_7.ds__week , subq_7.ds__month , subq_7.ds__quarter , subq_7.ds__year @@ -28,13 +29,11 @@ FROM ( , subq_7.ds__extract_day , subq_7.ds__extract_dow , subq_7.ds__extract_doy - , subq_7.metric_time__day , subq_7.metric_time__martian_day FROM ( -- Change Column Aliases SELECT subq_6.ds__day AS metric_time__day - , subq_6.ds__martian_day AS metric_time__martian_day , subq_6.ds__week , subq_6.ds__month , subq_6.ds__quarter @@ -45,6 +44,7 @@ FROM ( , subq_6.ds__extract_day , subq_6.ds__extract_dow , subq_6.ds__extract_doy + , subq_6.ds__martian_day AS metric_time__martian_day FROM ( -- Read From Time Spine 'mf_time_spine' SELECT diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_join_to_time_spine_metric_grouped_by_custom_grain__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_join_to_time_spine_metric_grouped_by_custom_grain__plan0.sql index 11c4ba0783..4803c1bd39 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_join_to_time_spine_metric_grouped_by_custom_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_join_to_time_spine_metric_grouped_by_custom_grain__plan0.sql @@ -18,8 +18,7 @@ FROM ( FROM ( -- Change Column Aliases SELECT - subq_5.ds__martian_day AS metric_time__martian_day - , subq_5.ds__day AS metric_time__day + subq_5.ds__day AS metric_time__day , subq_5.ds__week , subq_5.ds__month , subq_5.ds__quarter @@ -30,6 +29,7 @@ FROM ( , subq_5.ds__extract_day , subq_5.ds__extract_dow , subq_5.ds__extract_doy + , subq_5.ds__martian_day AS metric_time__martian_day FROM ( -- Read From Time Spine 'mf_time_spine' SELECT diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_join_to_timespine_metric_with_custom_granularity_filter__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_join_to_timespine_metric_with_custom_granularity_filter__plan0.sql index e2a23dff43..8db63e2710 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_join_to_timespine_metric_with_custom_granularity_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_join_to_timespine_metric_with_custom_granularity_filter__plan0.sql @@ -18,7 +18,8 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__week + subq_7.metric_time__day + , subq_7.ds__week , subq_7.ds__month , subq_7.ds__quarter , subq_7.ds__year @@ -29,12 +30,10 @@ FROM ( , subq_7.ds__extract_dow , subq_7.ds__extract_doy , subq_7.metric_time__martian_day - , subq_7.metric_time__day FROM ( -- Change Column Aliases SELECT - subq_6.ds__martian_day AS metric_time__martian_day - , subq_6.ds__day AS metric_time__day + subq_6.ds__day AS metric_time__day , subq_6.ds__week , subq_6.ds__month , subq_6.ds__quarter @@ -45,6 +44,7 @@ FROM ( , subq_6.ds__extract_day , subq_6.ds__extract_dow , subq_6.ds__extract_doy + , subq_6.ds__martian_day AS metric_time__martian_day FROM ( -- Read From Time Spine 'mf_time_spine' SELECT diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_join_to_timespine_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_join_to_timespine_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql index f07c9626f8..5b69d62c82 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_join_to_timespine_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_join_to_timespine_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql @@ -18,7 +18,8 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__week + subq_7.metric_time__day + , subq_7.ds__week , subq_7.ds__month , subq_7.ds__quarter , subq_7.ds__year @@ -28,13 +29,11 @@ FROM ( , subq_7.ds__extract_day , subq_7.ds__extract_dow , subq_7.ds__extract_doy - , subq_7.metric_time__day , subq_7.metric_time__martian_day FROM ( -- Change Column Aliases SELECT subq_6.ds__day AS metric_time__day - , subq_6.ds__martian_day AS metric_time__martian_day , subq_6.ds__week , subq_6.ds__month , subq_6.ds__quarter @@ -45,6 +44,7 @@ FROM ( , subq_6.ds__extract_day , subq_6.ds__extract_dow , subq_6.ds__extract_doy + , subq_6.ds__martian_day AS metric_time__martian_day FROM ( -- Read From Time Spine 'mf_time_spine' SELECT diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_join_to_time_spine_metric_grouped_by_custom_grain__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_join_to_time_spine_metric_grouped_by_custom_grain__plan0.sql index b0493a7319..5b13dc4bf3 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_join_to_time_spine_metric_grouped_by_custom_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_join_to_time_spine_metric_grouped_by_custom_grain__plan0.sql @@ -18,8 +18,7 @@ FROM ( FROM ( -- Change Column Aliases SELECT - subq_5.ds__martian_day AS metric_time__martian_day - , subq_5.ds__day AS metric_time__day + subq_5.ds__day AS metric_time__day , subq_5.ds__week , subq_5.ds__month , subq_5.ds__quarter @@ -30,6 +29,7 @@ FROM ( , subq_5.ds__extract_day , subq_5.ds__extract_dow , subq_5.ds__extract_doy + , subq_5.ds__martian_day AS metric_time__martian_day FROM ( -- Read From Time Spine 'mf_time_spine' SELECT diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_join_to_timespine_metric_with_custom_granularity_filter__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_join_to_timespine_metric_with_custom_granularity_filter__plan0.sql index 875524e29b..d671199e9f 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_join_to_timespine_metric_with_custom_granularity_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_join_to_timespine_metric_with_custom_granularity_filter__plan0.sql @@ -18,7 +18,8 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__week + subq_7.metric_time__day + , subq_7.ds__week , subq_7.ds__month , subq_7.ds__quarter , subq_7.ds__year @@ -29,12 +30,10 @@ FROM ( , subq_7.ds__extract_dow , subq_7.ds__extract_doy , subq_7.metric_time__martian_day - , subq_7.metric_time__day FROM ( -- Change Column Aliases SELECT - subq_6.ds__martian_day AS metric_time__martian_day - , subq_6.ds__day AS metric_time__day + subq_6.ds__day AS metric_time__day , subq_6.ds__week , subq_6.ds__month , subq_6.ds__quarter @@ -45,6 +44,7 @@ FROM ( , subq_6.ds__extract_day , subq_6.ds__extract_dow , subq_6.ds__extract_doy + , subq_6.ds__martian_day AS metric_time__martian_day FROM ( -- Read From Time Spine 'mf_time_spine' SELECT diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_join_to_timespine_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_join_to_timespine_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql index 57417cffb6..6da6fff672 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_join_to_timespine_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_join_to_timespine_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql @@ -18,7 +18,8 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__week + subq_7.metric_time__day + , subq_7.ds__week , subq_7.ds__month , subq_7.ds__quarter , subq_7.ds__year @@ -28,13 +29,11 @@ FROM ( , subq_7.ds__extract_day , subq_7.ds__extract_dow , subq_7.ds__extract_doy - , subq_7.metric_time__day , subq_7.metric_time__martian_day FROM ( -- Change Column Aliases SELECT subq_6.ds__day AS metric_time__day - , subq_6.ds__martian_day AS metric_time__martian_day , subq_6.ds__week , subq_6.ds__month , subq_6.ds__quarter @@ -45,6 +44,7 @@ FROM ( , subq_6.ds__extract_day , subq_6.ds__extract_dow , subq_6.ds__extract_doy + , subq_6.ds__martian_day AS metric_time__martian_day FROM ( -- Read From Time Spine 'mf_time_spine' SELECT diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_join_to_time_spine_metric_grouped_by_custom_grain__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_join_to_time_spine_metric_grouped_by_custom_grain__plan0.sql index 48f02fff02..6ae1938bf2 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_join_to_time_spine_metric_grouped_by_custom_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_join_to_time_spine_metric_grouped_by_custom_grain__plan0.sql @@ -18,8 +18,7 @@ FROM ( FROM ( -- Change Column Aliases SELECT - subq_5.ds__martian_day AS metric_time__martian_day - , subq_5.ds__day AS metric_time__day + subq_5.ds__day AS metric_time__day , subq_5.ds__week , subq_5.ds__month , subq_5.ds__quarter @@ -30,6 +29,7 @@ FROM ( , subq_5.ds__extract_day , subq_5.ds__extract_dow , subq_5.ds__extract_doy + , subq_5.ds__martian_day AS metric_time__martian_day FROM ( -- Read From Time Spine 'mf_time_spine' SELECT diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_join_to_timespine_metric_with_custom_granularity_filter__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_join_to_timespine_metric_with_custom_granularity_filter__plan0.sql index 53a3efafdd..bf6615536d 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_join_to_timespine_metric_with_custom_granularity_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_join_to_timespine_metric_with_custom_granularity_filter__plan0.sql @@ -18,7 +18,8 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__week + subq_7.metric_time__day + , subq_7.ds__week , subq_7.ds__month , subq_7.ds__quarter , subq_7.ds__year @@ -29,12 +30,10 @@ FROM ( , subq_7.ds__extract_dow , subq_7.ds__extract_doy , subq_7.metric_time__martian_day - , subq_7.metric_time__day FROM ( -- Change Column Aliases SELECT - subq_6.ds__martian_day AS metric_time__martian_day - , subq_6.ds__day AS metric_time__day + subq_6.ds__day AS metric_time__day , subq_6.ds__week , subq_6.ds__month , subq_6.ds__quarter @@ -45,6 +44,7 @@ FROM ( , subq_6.ds__extract_day , subq_6.ds__extract_dow , subq_6.ds__extract_doy + , subq_6.ds__martian_day AS metric_time__martian_day FROM ( -- Read From Time Spine 'mf_time_spine' SELECT diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_join_to_timespine_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_join_to_timespine_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql index e0b4097b29..fbfc517893 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_join_to_timespine_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_join_to_timespine_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql @@ -18,7 +18,8 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__week + subq_7.metric_time__day + , subq_7.ds__week , subq_7.ds__month , subq_7.ds__quarter , subq_7.ds__year @@ -28,13 +29,11 @@ FROM ( , subq_7.ds__extract_day , subq_7.ds__extract_dow , subq_7.ds__extract_doy - , subq_7.metric_time__day , subq_7.metric_time__martian_day FROM ( -- Change Column Aliases SELECT subq_6.ds__day AS metric_time__day - , subq_6.ds__martian_day AS metric_time__martian_day , subq_6.ds__week , subq_6.ds__month , subq_6.ds__quarter @@ -45,6 +44,7 @@ FROM ( , subq_6.ds__extract_day , subq_6.ds__extract_dow , subq_6.ds__extract_doy + , subq_6.ds__martian_day AS metric_time__martian_day FROM ( -- Read From Time Spine 'mf_time_spine' SELECT diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_join_to_time_spine_metric_grouped_by_custom_grain__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_join_to_time_spine_metric_grouped_by_custom_grain__plan0.sql index 4a8496cf04..3697d16be1 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_join_to_time_spine_metric_grouped_by_custom_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_join_to_time_spine_metric_grouped_by_custom_grain__plan0.sql @@ -18,8 +18,7 @@ FROM ( FROM ( -- Change Column Aliases SELECT - subq_5.ds__martian_day AS metric_time__martian_day - , subq_5.ds__day AS metric_time__day + subq_5.ds__day AS metric_time__day , subq_5.ds__week , subq_5.ds__month , subq_5.ds__quarter @@ -30,6 +29,7 @@ FROM ( , subq_5.ds__extract_day , subq_5.ds__extract_dow , subq_5.ds__extract_doy + , subq_5.ds__martian_day AS metric_time__martian_day FROM ( -- Read From Time Spine 'mf_time_spine' SELECT diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_join_to_timespine_metric_with_custom_granularity_filter__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_join_to_timespine_metric_with_custom_granularity_filter__plan0.sql index 25bd7b0afc..3567ba827e 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_join_to_timespine_metric_with_custom_granularity_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_join_to_timespine_metric_with_custom_granularity_filter__plan0.sql @@ -18,7 +18,8 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__week + subq_7.metric_time__day + , subq_7.ds__week , subq_7.ds__month , subq_7.ds__quarter , subq_7.ds__year @@ -29,12 +30,10 @@ FROM ( , subq_7.ds__extract_dow , subq_7.ds__extract_doy , subq_7.metric_time__martian_day - , subq_7.metric_time__day FROM ( -- Change Column Aliases SELECT - subq_6.ds__martian_day AS metric_time__martian_day - , subq_6.ds__day AS metric_time__day + subq_6.ds__day AS metric_time__day , subq_6.ds__week , subq_6.ds__month , subq_6.ds__quarter @@ -45,6 +44,7 @@ FROM ( , subq_6.ds__extract_day , subq_6.ds__extract_dow , subq_6.ds__extract_doy + , subq_6.ds__martian_day AS metric_time__martian_day FROM ( -- Read From Time Spine 'mf_time_spine' SELECT diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_join_to_timespine_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_join_to_timespine_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql index 0ded27ae77..f0d59bb8f1 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_join_to_timespine_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_join_to_timespine_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql @@ -18,7 +18,8 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__week + subq_7.metric_time__day + , subq_7.ds__week , subq_7.ds__month , subq_7.ds__quarter , subq_7.ds__year @@ -28,13 +29,11 @@ FROM ( , subq_7.ds__extract_day , subq_7.ds__extract_dow , subq_7.ds__extract_doy - , subq_7.metric_time__day , subq_7.metric_time__martian_day FROM ( -- Change Column Aliases SELECT subq_6.ds__day AS metric_time__day - , subq_6.ds__martian_day AS metric_time__martian_day , subq_6.ds__week , subq_6.ds__month , subq_6.ds__quarter @@ -45,6 +44,7 @@ FROM ( , subq_6.ds__extract_day , subq_6.ds__extract_dow , subq_6.ds__extract_doy + , subq_6.ds__martian_day AS metric_time__martian_day FROM ( -- Read From Time Spine 'mf_time_spine' SELECT 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 886da3fb21..cf44aae1e6 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 @@ -52,9 +52,9 @@ FROM ( FROM ( -- Change Column Aliases SELECT - subq_2.ds__month AS metric_time__month - , subq_2.ds__day + subq_2.ds__day , subq_2.ds__week + , subq_2.ds__month AS metric_time__month , subq_2.ds__quarter , subq_2.ds__year , subq_2.ds__extract_year diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_metric_with_offset_window_and_granularity__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_metric_with_offset_window_and_granularity__plan0.sql index 6f74beb8aa..8d70034ab2 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_metric_with_offset_window_and_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_derived_metric_with_offset_window_and_granularity__plan0.sql @@ -352,9 +352,9 @@ FROM ( -- Change Column Aliases SELECT subq_7.ds__day AS metric_time__day - , subq_7.ds__quarter AS metric_time__quarter , subq_7.ds__week , subq_7.ds__month + , subq_7.ds__quarter AS metric_time__quarter , subq_7.ds__year , subq_7.ds__extract_year , subq_7.ds__extract_quarter 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.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.sql index 6386f07c5a..5312eb623c 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.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.sql @@ -137,10 +137,10 @@ FROM ( -- Change Column Aliases SELECT subq_2.ds__day AS metric_time__day - , subq_2.ds__year AS metric_time__year , subq_2.ds__week , subq_2.ds__month , subq_2.ds__quarter + , subq_2.ds__year AS metric_time__year , subq_2.ds__extract_year , subq_2.ds__extract_quarter , subq_2.ds__extract_month @@ -496,10 +496,10 @@ FROM ( -- Change Column Aliases SELECT subq_11.ds__day AS metric_time__day - , subq_11.ds__year AS metric_time__year , subq_11.ds__week , subq_11.ds__month , subq_11.ds__quarter + , subq_11.ds__year AS metric_time__year , subq_11.ds__extract_year , subq_11.ds__extract_quarter , subq_11.ds__extract_month diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql index a784c088fa..547de71995 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql @@ -234,8 +234,8 @@ FROM ( -- Change Column Aliases SELECT subq_2.ds__day AS metric_time__day - , subq_2.ds__month AS metric_time__month , subq_2.ds__week + , subq_2.ds__month AS metric_time__month , subq_2.ds__quarter , subq_2.ds__year , subq_2.ds__extract_year 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 e8d3345c51..cec47e4bd9 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 @@ -142,10 +142,10 @@ FROM ( -- Change Column Aliases SELECT subq_2.ds__day AS metric_time__day - , subq_2.ds__month AS metric_time__month - , subq_2.ds__year AS metric_time__year , subq_2.ds__week + , subq_2.ds__month AS metric_time__month , subq_2.ds__quarter + , subq_2.ds__year AS metric_time__year , subq_2.ds__extract_year , subq_2.ds__extract_quarter , subq_2.ds__extract_month diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql index fb697bd2a0..e4f9595506 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/BigQuery/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql @@ -240,8 +240,8 @@ FROM ( -- Change Column Aliases SELECT subq_2.ds__day AS metric_time__day - , subq_2.ds__month AS metric_time__month , subq_2.ds__week + , subq_2.ds__month AS metric_time__month , subq_2.ds__quarter , subq_2.ds__year , subq_2.ds__extract_year 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 78efe08e85..8a6ed0220c 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 @@ -150,10 +150,10 @@ FROM ( -- Change Column Aliases SELECT subq_2.ds__day AS metric_time__day - , subq_2.ds__month AS metric_time__month - , subq_2.ds__year AS metric_time__year , subq_2.ds__week + , subq_2.ds__month AS metric_time__month , subq_2.ds__quarter + , subq_2.ds__year AS metric_time__year , subq_2.ds__extract_year , subq_2.ds__extract_quarter , subq_2.ds__extract_month 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 53b9e469a9..051df9c618 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 @@ -52,9 +52,9 @@ FROM ( FROM ( -- Change Column Aliases SELECT - subq_2.ds__month AS metric_time__month - , subq_2.ds__day + subq_2.ds__day , subq_2.ds__week + , subq_2.ds__month AS metric_time__month , subq_2.ds__quarter , subq_2.ds__year , subq_2.ds__extract_year diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_metric_with_offset_window_and_granularity__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_metric_with_offset_window_and_granularity__plan0.sql index 3a194c4c98..b6b50a8890 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_metric_with_offset_window_and_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_derived_metric_with_offset_window_and_granularity__plan0.sql @@ -352,9 +352,9 @@ FROM ( -- Change Column Aliases SELECT subq_7.ds__day AS metric_time__day - , subq_7.ds__quarter AS metric_time__quarter , subq_7.ds__week , subq_7.ds__month + , subq_7.ds__quarter AS metric_time__quarter , subq_7.ds__year , subq_7.ds__extract_year , subq_7.ds__extract_quarter 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.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.sql index 7b6af2867f..0dbc5726f7 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.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.sql @@ -137,10 +137,10 @@ FROM ( -- Change Column Aliases SELECT subq_2.ds__day AS metric_time__day - , subq_2.ds__year AS metric_time__year , subq_2.ds__week , subq_2.ds__month , subq_2.ds__quarter + , subq_2.ds__year AS metric_time__year , subq_2.ds__extract_year , subq_2.ds__extract_quarter , subq_2.ds__extract_month @@ -496,10 +496,10 @@ FROM ( -- Change Column Aliases SELECT subq_11.ds__day AS metric_time__day - , subq_11.ds__year AS metric_time__year , subq_11.ds__week , subq_11.ds__month , subq_11.ds__quarter + , subq_11.ds__year AS metric_time__year , subq_11.ds__extract_year , subq_11.ds__extract_quarter , subq_11.ds__extract_month diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql index a724cfc021..27975db1da 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql @@ -234,8 +234,8 @@ FROM ( -- Change Column Aliases SELECT subq_2.ds__day AS metric_time__day - , subq_2.ds__month AS metric_time__month , subq_2.ds__week + , subq_2.ds__month AS metric_time__month , subq_2.ds__quarter , subq_2.ds__year , subq_2.ds__extract_year 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 c460959fa2..9b6113b52a 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 @@ -142,10 +142,10 @@ FROM ( -- Change Column Aliases SELECT subq_2.ds__day AS metric_time__day - , subq_2.ds__month AS metric_time__month - , subq_2.ds__year AS metric_time__year , subq_2.ds__week + , subq_2.ds__month AS metric_time__month , subq_2.ds__quarter + , subq_2.ds__year AS metric_time__year , subq_2.ds__extract_year , subq_2.ds__extract_quarter , subq_2.ds__extract_month diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql index 1cd9069be2..5d503c52de 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Databricks/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql @@ -240,8 +240,8 @@ FROM ( -- Change Column Aliases SELECT subq_2.ds__day AS metric_time__day - , subq_2.ds__month AS metric_time__month , subq_2.ds__week + , subq_2.ds__month AS metric_time__month , subq_2.ds__quarter , subq_2.ds__year , subq_2.ds__extract_year 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 9286cff132..cac5a3edbb 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 @@ -150,10 +150,10 @@ FROM ( -- Change Column Aliases SELECT subq_2.ds__day AS metric_time__day - , subq_2.ds__month AS metric_time__month - , subq_2.ds__year AS metric_time__year , subq_2.ds__week + , subq_2.ds__month AS metric_time__month , subq_2.ds__quarter + , subq_2.ds__year AS metric_time__year , subq_2.ds__extract_year , subq_2.ds__extract_quarter , subq_2.ds__extract_month 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 2aee922b30..42cba00530 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 @@ -52,9 +52,9 @@ FROM ( FROM ( -- Change Column Aliases SELECT - subq_2.ds__month AS metric_time__month - , subq_2.ds__day + subq_2.ds__day , subq_2.ds__week + , subq_2.ds__month AS metric_time__month , subq_2.ds__quarter , subq_2.ds__year , subq_2.ds__extract_year diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_offset_window_and_granularity__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_offset_window_and_granularity__plan0.sql index 4ede9e08d2..0d507fae8b 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_offset_window_and_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_offset_window_and_granularity__plan0.sql @@ -352,9 +352,9 @@ FROM ( -- Change Column Aliases SELECT subq_7.ds__day AS metric_time__day - , subq_7.ds__quarter AS metric_time__quarter , subq_7.ds__week , subq_7.ds__month + , subq_7.ds__quarter AS metric_time__quarter , subq_7.ds__year , subq_7.ds__extract_year , subq_7.ds__extract_quarter 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.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.sql index 1d5827eea4..5ddaf7477f 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.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.sql @@ -137,10 +137,10 @@ FROM ( -- Change Column Aliases SELECT subq_2.ds__day AS metric_time__day - , subq_2.ds__year AS metric_time__year , subq_2.ds__week , subq_2.ds__month , subq_2.ds__quarter + , subq_2.ds__year AS metric_time__year , subq_2.ds__extract_year , subq_2.ds__extract_quarter , subq_2.ds__extract_month @@ -496,10 +496,10 @@ FROM ( -- Change Column Aliases SELECT subq_11.ds__day AS metric_time__day - , subq_11.ds__year AS metric_time__year , subq_11.ds__week , subq_11.ds__month , subq_11.ds__quarter + , subq_11.ds__year AS metric_time__year , subq_11.ds__extract_year , subq_11.ds__extract_quarter , subq_11.ds__extract_month diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql index b0b6ac3fd0..492eed4ecf 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql @@ -234,8 +234,8 @@ FROM ( -- Change Column Aliases SELECT subq_2.ds__day AS metric_time__day - , subq_2.ds__month AS metric_time__month , subq_2.ds__week + , subq_2.ds__month AS metric_time__month , subq_2.ds__quarter , subq_2.ds__year , subq_2.ds__extract_year 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 7ff287fbf9..81b8c1d72f 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 @@ -142,10 +142,10 @@ FROM ( -- Change Column Aliases SELECT subq_2.ds__day AS metric_time__day - , subq_2.ds__month AS metric_time__month - , subq_2.ds__year AS metric_time__year , subq_2.ds__week + , subq_2.ds__month AS metric_time__month , subq_2.ds__quarter + , subq_2.ds__year AS metric_time__year , subq_2.ds__extract_year , subq_2.ds__extract_quarter , subq_2.ds__extract_month diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql index 11695bd14c..0193f74be4 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql @@ -240,8 +240,8 @@ FROM ( -- Change Column Aliases SELECT subq_2.ds__day AS metric_time__day - , subq_2.ds__month AS metric_time__month , subq_2.ds__week + , subq_2.ds__month AS metric_time__month , subq_2.ds__quarter , subq_2.ds__year , subq_2.ds__extract_year 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 9f27bbfd82..7f0ee4bc9a 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 @@ -150,10 +150,10 @@ FROM ( -- Change Column Aliases SELECT subq_2.ds__day AS metric_time__day - , subq_2.ds__month AS metric_time__month - , subq_2.ds__year AS metric_time__year , subq_2.ds__week + , subq_2.ds__month AS metric_time__month , subq_2.ds__quarter + , subq_2.ds__year AS metric_time__year , subq_2.ds__extract_year , subq_2.ds__extract_quarter , subq_2.ds__extract_month 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 823bb85c29..5df2f19c7a 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 @@ -52,9 +52,9 @@ FROM ( FROM ( -- Change Column Aliases SELECT - subq_2.ds__month AS metric_time__month - , subq_2.ds__day + subq_2.ds__day , subq_2.ds__week + , subq_2.ds__month AS metric_time__month , subq_2.ds__quarter , subq_2.ds__year , subq_2.ds__extract_year diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_metric_with_offset_window_and_granularity__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_metric_with_offset_window_and_granularity__plan0.sql index ed7b75c923..54e3dc332a 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_metric_with_offset_window_and_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_derived_metric_with_offset_window_and_granularity__plan0.sql @@ -352,9 +352,9 @@ FROM ( -- Change Column Aliases SELECT subq_7.ds__day AS metric_time__day - , subq_7.ds__quarter AS metric_time__quarter , subq_7.ds__week , subq_7.ds__month + , subq_7.ds__quarter AS metric_time__quarter , subq_7.ds__year , subq_7.ds__extract_year , subq_7.ds__extract_quarter 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.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.sql index ae0f821ebd..676c004637 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.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.sql @@ -137,10 +137,10 @@ FROM ( -- Change Column Aliases SELECT subq_2.ds__day AS metric_time__day - , subq_2.ds__year AS metric_time__year , subq_2.ds__week , subq_2.ds__month , subq_2.ds__quarter + , subq_2.ds__year AS metric_time__year , subq_2.ds__extract_year , subq_2.ds__extract_quarter , subq_2.ds__extract_month @@ -496,10 +496,10 @@ FROM ( -- Change Column Aliases SELECT subq_11.ds__day AS metric_time__day - , subq_11.ds__year AS metric_time__year , subq_11.ds__week , subq_11.ds__month , subq_11.ds__quarter + , subq_11.ds__year AS metric_time__year , subq_11.ds__extract_year , subq_11.ds__extract_quarter , subq_11.ds__extract_month diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql index de44b7a580..6dafa7824b 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql @@ -234,8 +234,8 @@ FROM ( -- Change Column Aliases SELECT subq_2.ds__day AS metric_time__day - , subq_2.ds__month AS metric_time__month , subq_2.ds__week + , subq_2.ds__month AS metric_time__month , subq_2.ds__quarter , subq_2.ds__year , subq_2.ds__extract_year 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 95fe4e8e8a..14cba6de99 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 @@ -142,10 +142,10 @@ FROM ( -- Change Column Aliases SELECT subq_2.ds__day AS metric_time__day - , subq_2.ds__month AS metric_time__month - , subq_2.ds__year AS metric_time__year , subq_2.ds__week + , subq_2.ds__month AS metric_time__month , subq_2.ds__quarter + , subq_2.ds__year AS metric_time__year , subq_2.ds__extract_year , subq_2.ds__extract_quarter , subq_2.ds__extract_month diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql index 5129d9082d..e90ee146a0 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Postgres/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql @@ -240,8 +240,8 @@ FROM ( -- Change Column Aliases SELECT subq_2.ds__day AS metric_time__day - , subq_2.ds__month AS metric_time__month , subq_2.ds__week + , subq_2.ds__month AS metric_time__month , subq_2.ds__quarter , subq_2.ds__year , subq_2.ds__extract_year 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 e0a8b5ff0a..13a5607ec6 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 @@ -150,10 +150,10 @@ FROM ( -- Change Column Aliases SELECT subq_2.ds__day AS metric_time__day - , subq_2.ds__month AS metric_time__month - , subq_2.ds__year AS metric_time__year , subq_2.ds__week + , subq_2.ds__month AS metric_time__month , subq_2.ds__quarter + , subq_2.ds__year AS metric_time__year , subq_2.ds__extract_year , subq_2.ds__extract_quarter , subq_2.ds__extract_month 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 cb9ab0f48d..95ce006b45 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 @@ -52,9 +52,9 @@ FROM ( FROM ( -- Change Column Aliases SELECT - subq_2.ds__month AS metric_time__month - , subq_2.ds__day + subq_2.ds__day , subq_2.ds__week + , subq_2.ds__month AS metric_time__month , subq_2.ds__quarter , subq_2.ds__year , subq_2.ds__extract_year diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_metric_with_offset_window_and_granularity__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_metric_with_offset_window_and_granularity__plan0.sql index 4f37b04e1f..8d6f2bf761 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_metric_with_offset_window_and_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_derived_metric_with_offset_window_and_granularity__plan0.sql @@ -352,9 +352,9 @@ FROM ( -- Change Column Aliases SELECT subq_7.ds__day AS metric_time__day - , subq_7.ds__quarter AS metric_time__quarter , subq_7.ds__week , subq_7.ds__month + , subq_7.ds__quarter AS metric_time__quarter , subq_7.ds__year , subq_7.ds__extract_year , subq_7.ds__extract_quarter 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.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.sql index 976b311928..040cbc1451 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.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.sql @@ -137,10 +137,10 @@ FROM ( -- Change Column Aliases SELECT subq_2.ds__day AS metric_time__day - , subq_2.ds__year AS metric_time__year , subq_2.ds__week , subq_2.ds__month , subq_2.ds__quarter + , subq_2.ds__year AS metric_time__year , subq_2.ds__extract_year , subq_2.ds__extract_quarter , subq_2.ds__extract_month @@ -496,10 +496,10 @@ FROM ( -- Change Column Aliases SELECT subq_11.ds__day AS metric_time__day - , subq_11.ds__year AS metric_time__year , subq_11.ds__week , subq_11.ds__month , subq_11.ds__quarter + , subq_11.ds__year AS metric_time__year , subq_11.ds__extract_year , subq_11.ds__extract_quarter , subq_11.ds__extract_month diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql index 05e34bda24..ad856e2b27 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql @@ -234,8 +234,8 @@ FROM ( -- Change Column Aliases SELECT subq_2.ds__day AS metric_time__day - , subq_2.ds__month AS metric_time__month , subq_2.ds__week + , subq_2.ds__month AS metric_time__month , subq_2.ds__quarter , subq_2.ds__year , subq_2.ds__extract_year 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 0238b9c927..477fe62c2b 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 @@ -142,10 +142,10 @@ FROM ( -- Change Column Aliases SELECT subq_2.ds__day AS metric_time__day - , subq_2.ds__month AS metric_time__month - , subq_2.ds__year AS metric_time__year , subq_2.ds__week + , subq_2.ds__month AS metric_time__month , subq_2.ds__quarter + , subq_2.ds__year AS metric_time__year , subq_2.ds__extract_year , subq_2.ds__extract_quarter , subq_2.ds__extract_month diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql index d8a6659318..ea523a7236 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Redshift/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql @@ -240,8 +240,8 @@ FROM ( -- Change Column Aliases SELECT subq_2.ds__day AS metric_time__day - , subq_2.ds__month AS metric_time__month , subq_2.ds__week + , subq_2.ds__month AS metric_time__month , subq_2.ds__quarter , subq_2.ds__year , subq_2.ds__extract_year 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 1cb45a2c01..978fbefbb5 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 @@ -150,10 +150,10 @@ FROM ( -- Change Column Aliases SELECT subq_2.ds__day AS metric_time__day - , subq_2.ds__month AS metric_time__month - , subq_2.ds__year AS metric_time__year , subq_2.ds__week + , subq_2.ds__month AS metric_time__month , subq_2.ds__quarter + , subq_2.ds__year AS metric_time__year , subq_2.ds__extract_year , subq_2.ds__extract_quarter , subq_2.ds__extract_month 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 ff52b01f7c..f32424a389 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 @@ -52,9 +52,9 @@ FROM ( FROM ( -- Change Column Aliases SELECT - subq_2.ds__month AS metric_time__month - , subq_2.ds__day + subq_2.ds__day , subq_2.ds__week + , subq_2.ds__month AS metric_time__month , subq_2.ds__quarter , subq_2.ds__year , subq_2.ds__extract_year diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_metric_with_offset_window_and_granularity__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_metric_with_offset_window_and_granularity__plan0.sql index 8970e9b9d5..1a4ff9a7df 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_metric_with_offset_window_and_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_derived_metric_with_offset_window_and_granularity__plan0.sql @@ -352,9 +352,9 @@ FROM ( -- Change Column Aliases SELECT subq_7.ds__day AS metric_time__day - , subq_7.ds__quarter AS metric_time__quarter , subq_7.ds__week , subq_7.ds__month + , subq_7.ds__quarter AS metric_time__quarter , subq_7.ds__year , subq_7.ds__extract_year , subq_7.ds__extract_quarter 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.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.sql index 09ec10dc8f..154cac500f 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.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.sql @@ -137,10 +137,10 @@ FROM ( -- Change Column Aliases SELECT subq_2.ds__day AS metric_time__day - , subq_2.ds__year AS metric_time__year , subq_2.ds__week , subq_2.ds__month , subq_2.ds__quarter + , subq_2.ds__year AS metric_time__year , subq_2.ds__extract_year , subq_2.ds__extract_quarter , subq_2.ds__extract_month @@ -496,10 +496,10 @@ FROM ( -- Change Column Aliases SELECT subq_11.ds__day AS metric_time__day - , subq_11.ds__year AS metric_time__year , subq_11.ds__week , subq_11.ds__month , subq_11.ds__quarter + , subq_11.ds__year AS metric_time__year , subq_11.ds__extract_year , subq_11.ds__extract_quarter , subq_11.ds__extract_month diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql index 214a58d167..fd05f68e43 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql @@ -234,8 +234,8 @@ FROM ( -- Change Column Aliases SELECT subq_2.ds__day AS metric_time__day - , subq_2.ds__month AS metric_time__month , subq_2.ds__week + , subq_2.ds__month AS metric_time__month , subq_2.ds__quarter , subq_2.ds__year , subq_2.ds__extract_year 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 3809e8e337..718b48aa1e 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 @@ -142,10 +142,10 @@ FROM ( -- Change Column Aliases SELECT subq_2.ds__day AS metric_time__day - , subq_2.ds__month AS metric_time__month - , subq_2.ds__year AS metric_time__year , subq_2.ds__week + , subq_2.ds__month AS metric_time__month , subq_2.ds__quarter + , subq_2.ds__year AS metric_time__year , subq_2.ds__extract_year , subq_2.ds__extract_quarter , subq_2.ds__extract_month diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql index b2d078c006..c2ef593b24 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Snowflake/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql @@ -240,8 +240,8 @@ FROM ( -- Change Column Aliases SELECT subq_2.ds__day AS metric_time__day - , subq_2.ds__month AS metric_time__month , subq_2.ds__week + , subq_2.ds__month AS metric_time__month , subq_2.ds__quarter , subq_2.ds__year , subq_2.ds__extract_year 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 b3e9cc46ef..0a9c2a2564 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 @@ -150,10 +150,10 @@ FROM ( -- Change Column Aliases SELECT subq_2.ds__day AS metric_time__day - , subq_2.ds__month AS metric_time__month - , subq_2.ds__year AS metric_time__year , subq_2.ds__week + , subq_2.ds__month AS metric_time__month , subq_2.ds__quarter + , subq_2.ds__year AS metric_time__year , subq_2.ds__extract_year , subq_2.ds__extract_quarter , subq_2.ds__extract_month 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 1ab71d23a6..a2d761b425 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 @@ -52,9 +52,9 @@ FROM ( FROM ( -- Change Column Aliases SELECT - subq_2.ds__month AS metric_time__month - , subq_2.ds__day + subq_2.ds__day , subq_2.ds__week + , subq_2.ds__month AS metric_time__month , subq_2.ds__quarter , subq_2.ds__year , subq_2.ds__extract_year diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_metric_with_offset_window_and_granularity__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_metric_with_offset_window_and_granularity__plan0.sql index 99402f2d85..5358c9010c 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_metric_with_offset_window_and_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_derived_metric_with_offset_window_and_granularity__plan0.sql @@ -352,9 +352,9 @@ FROM ( -- Change Column Aliases SELECT subq_7.ds__day AS metric_time__day - , subq_7.ds__quarter AS metric_time__quarter , subq_7.ds__week , subq_7.ds__month + , subq_7.ds__quarter AS metric_time__quarter , subq_7.ds__year , subq_7.ds__extract_year , subq_7.ds__extract_quarter 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.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.sql index bf94ae2594..9272a64b62 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.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.sql @@ -137,10 +137,10 @@ FROM ( -- Change Column Aliases SELECT subq_2.ds__day AS metric_time__day - , subq_2.ds__year AS metric_time__year , subq_2.ds__week , subq_2.ds__month , subq_2.ds__quarter + , subq_2.ds__year AS metric_time__year , subq_2.ds__extract_year , subq_2.ds__extract_quarter , subq_2.ds__extract_month @@ -496,10 +496,10 @@ FROM ( -- Change Column Aliases SELECT subq_11.ds__day AS metric_time__day - , subq_11.ds__year AS metric_time__year , subq_11.ds__week , subq_11.ds__month , subq_11.ds__quarter + , subq_11.ds__year AS metric_time__year , subq_11.ds__extract_year , subq_11.ds__extract_quarter , subq_11.ds__extract_month diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql index 7fde19919b..3f7d78cbae 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql @@ -234,8 +234,8 @@ FROM ( -- Change Column Aliases SELECT subq_2.ds__day AS metric_time__day - , subq_2.ds__month AS metric_time__month , subq_2.ds__week + , subq_2.ds__month AS metric_time__month , subq_2.ds__quarter , subq_2.ds__year , subq_2.ds__extract_year 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 cd7a91cacd..5d3f4c247b 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 @@ -142,10 +142,10 @@ FROM ( -- Change Column Aliases SELECT subq_2.ds__day AS metric_time__day - , subq_2.ds__month AS metric_time__month - , subq_2.ds__year AS metric_time__year , subq_2.ds__week + , subq_2.ds__month AS metric_time__month , subq_2.ds__quarter + , subq_2.ds__year AS metric_time__year , subq_2.ds__extract_year , subq_2.ds__extract_quarter , subq_2.ds__extract_month diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql index d68ba86524..a1567a6ec0 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/Trino/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql @@ -240,8 +240,8 @@ FROM ( -- Change Column Aliases SELECT subq_2.ds__day AS metric_time__day - , subq_2.ds__month AS metric_time__month , subq_2.ds__week + , subq_2.ds__month AS metric_time__month , subq_2.ds__quarter , subq_2.ds__year , subq_2.ds__extract_year 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 ef64a79e61..c141e60983 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 @@ -150,10 +150,10 @@ FROM ( -- Change Column Aliases SELECT subq_2.ds__day AS metric_time__day - , subq_2.ds__month AS metric_time__month - , subq_2.ds__year AS metric_time__year , subq_2.ds__week + , subq_2.ds__month AS metric_time__month , subq_2.ds__quarter + , subq_2.ds__year AS metric_time__year , subq_2.ds__extract_year , subq_2.ds__extract_quarter , subq_2.ds__extract_month diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql index 96edca34db..3b4d330573 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql @@ -18,7 +18,9 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__week + subq_6.metric_time__day + , subq_6.ds__week + , subq_6.metric_time__month , subq_6.ds__quarter , subq_6.ds__year , subq_6.ds__extract_year @@ -28,14 +30,12 @@ FROM ( , subq_6.ds__extract_dow , subq_6.ds__extract_doy , subq_6.ds__martian_day - , subq_6.metric_time__day - , subq_6.metric_time__month FROM ( -- Change Column Aliases SELECT subq_5.ds__day AS metric_time__day - , subq_5.ds__month AS metric_time__month , subq_5.ds__week + , subq_5.ds__month AS metric_time__month , subq_5.ds__quarter , subq_5.ds__year , subq_5.ds__extract_year diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql index f400517cac..542d034781 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql @@ -18,7 +18,10 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__week + subq_6.booking__ds__day + , subq_6.metric_time__day + , subq_6.ds__week + , subq_6.booking__ds__month , subq_6.ds__quarter , subq_6.ds__year , subq_6.ds__extract_year @@ -28,16 +31,13 @@ FROM ( , subq_6.ds__extract_dow , subq_6.ds__extract_doy , subq_6.ds__martian_day - , subq_6.booking__ds__day - , subq_6.metric_time__day - , subq_6.booking__ds__month FROM ( -- Change Column Aliases SELECT subq_5.ds__day AS booking__ds__day , subq_5.ds__day AS metric_time__day - , subq_5.ds__month AS booking__ds__month , subq_5.ds__week + , subq_5.ds__month AS booking__ds__month , subq_5.ds__quarter , subq_5.ds__year , subq_5.ds__extract_year diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql index 6c870c0226..ec0cb9e0da 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql @@ -18,7 +18,9 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__week + subq_6.metric_time__day + , subq_6.ds__week + , subq_6.booking__ds__month , subq_6.ds__quarter , subq_6.ds__year , subq_6.ds__extract_year @@ -28,14 +30,12 @@ FROM ( , subq_6.ds__extract_dow , subq_6.ds__extract_doy , subq_6.ds__martian_day - , subq_6.metric_time__day - , subq_6.booking__ds__month FROM ( -- Change Column Aliases SELECT subq_5.ds__day AS metric_time__day - , subq_5.ds__month AS booking__ds__month , subq_5.ds__week + , subq_5.ds__month AS booking__ds__month , subq_5.ds__quarter , subq_5.ds__year , subq_5.ds__extract_year diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/BigQuery/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/BigQuery/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql index a1c206a72e..9795e3e3d3 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/BigQuery/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/BigQuery/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql @@ -18,7 +18,9 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_6.ts__week + subq_6.metric_time__hour + , subq_6.metric_time__day + , subq_6.ts__week , subq_6.ts__month , subq_6.ts__quarter , subq_6.ts__year @@ -28,13 +30,11 @@ FROM ( , subq_6.ts__extract_day , subq_6.ts__extract_dow , subq_6.ts__extract_doy - , subq_6.metric_time__day - , subq_6.metric_time__hour FROM ( -- Change Column Aliases SELECT - subq_5.ts__day AS metric_time__day - , subq_5.ts__hour AS metric_time__hour + subq_5.ts__hour AS metric_time__hour + , subq_5.ts__day AS metric_time__day , subq_5.ts__week , subq_5.ts__month , subq_5.ts__quarter diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/BigQuery/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/BigQuery/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql index 16b7b528f7..16dc5afafe 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/BigQuery/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/BigQuery/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql @@ -16,8 +16,8 @@ FROM ( -- Read From Time Spine 'mf_time_spine_hour' -- Change Column Aliases SELECT - DATETIME_TRUNC(ts, day) AS metric_time__day - , ts AS metric_time__hour + ts AS metric_time__hour + , DATETIME_TRUNC(ts, day) AS metric_time__day FROM ***************************.mf_time_spine_hour time_spine_src_28005 ) subq_16 WHERE (metric_time__hour > '2020-01-01 00:09:00') AND (metric_time__day = '2020-01-01') diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/BigQuery/test_join_to_time_spine_with_filters__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/BigQuery/test_join_to_time_spine_with_filters__plan0.sql index 27a3341e0a..b91456b9a1 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/BigQuery/test_join_to_time_spine_with_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/BigQuery/test_join_to_time_spine_with_filters__plan0.sql @@ -23,7 +23,9 @@ FROM ( FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_8.ds__month + subq_8.metric_time__day + , subq_8.metric_time__week + , subq_8.ds__month , subq_8.ds__quarter , subq_8.ds__year , subq_8.ds__extract_year @@ -33,12 +35,12 @@ FROM ( , subq_8.ds__extract_dow , subq_8.ds__extract_doy , subq_8.ds__martian_day - , subq_8.metric_time__day - , subq_8.metric_time__week FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__month + subq_7.metric_time__day + , subq_7.metric_time__week + , subq_7.ds__month , subq_7.ds__quarter , subq_7.ds__year , subq_7.ds__extract_year @@ -48,8 +50,6 @@ FROM ( , subq_7.ds__extract_dow , subq_7.ds__extract_doy , subq_7.ds__martian_day - , subq_7.metric_time__day - , subq_7.metric_time__week FROM ( -- Change Column Aliases SELECT diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/BigQuery/test_simple_fill_nulls_with_0_month__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/BigQuery/test_simple_fill_nulls_with_0_month__plan0.sql index a0292d4cea..aa0e75701e 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/BigQuery/test_simple_fill_nulls_with_0_month__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/BigQuery/test_simple_fill_nulls_with_0_month__plan0.sql @@ -18,9 +18,9 @@ FROM ( FROM ( -- Change Column Aliases SELECT - subq_4.ds__month AS metric_time__month - , subq_4.ds__day + subq_4.ds__day , subq_4.ds__week + , subq_4.ds__month AS metric_time__month , subq_4.ds__quarter , subq_4.ds__year , subq_4.ds__extract_year diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Databricks/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Databricks/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql index d48cf9db24..e1af9aeb58 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Databricks/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Databricks/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql @@ -18,7 +18,9 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__week + subq_6.metric_time__day + , subq_6.ds__week + , subq_6.metric_time__month , subq_6.ds__quarter , subq_6.ds__year , subq_6.ds__extract_year @@ -28,14 +30,12 @@ FROM ( , subq_6.ds__extract_dow , subq_6.ds__extract_doy , subq_6.ds__martian_day - , subq_6.metric_time__day - , subq_6.metric_time__month FROM ( -- Change Column Aliases SELECT subq_5.ds__day AS metric_time__day - , subq_5.ds__month AS metric_time__month , subq_5.ds__week + , subq_5.ds__month AS metric_time__month , subq_5.ds__quarter , subq_5.ds__year , subq_5.ds__extract_year diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Databricks/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Databricks/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql index 86e9b8c9ce..3f0af2107b 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Databricks/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Databricks/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql @@ -18,7 +18,10 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__week + subq_6.booking__ds__day + , subq_6.metric_time__day + , subq_6.ds__week + , subq_6.booking__ds__month , subq_6.ds__quarter , subq_6.ds__year , subq_6.ds__extract_year @@ -28,16 +31,13 @@ FROM ( , subq_6.ds__extract_dow , subq_6.ds__extract_doy , subq_6.ds__martian_day - , subq_6.booking__ds__day - , subq_6.metric_time__day - , subq_6.booking__ds__month FROM ( -- Change Column Aliases SELECT subq_5.ds__day AS booking__ds__day , subq_5.ds__day AS metric_time__day - , subq_5.ds__month AS booking__ds__month , subq_5.ds__week + , subq_5.ds__month AS booking__ds__month , subq_5.ds__quarter , subq_5.ds__year , subq_5.ds__extract_year diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Databricks/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Databricks/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql index dd874f6c50..ce41018eee 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Databricks/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Databricks/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql @@ -18,7 +18,9 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__week + subq_6.metric_time__day + , subq_6.ds__week + , subq_6.booking__ds__month , subq_6.ds__quarter , subq_6.ds__year , subq_6.ds__extract_year @@ -28,14 +30,12 @@ FROM ( , subq_6.ds__extract_dow , subq_6.ds__extract_doy , subq_6.ds__martian_day - , subq_6.metric_time__day - , subq_6.booking__ds__month FROM ( -- Change Column Aliases SELECT subq_5.ds__day AS metric_time__day - , subq_5.ds__month AS booking__ds__month , subq_5.ds__week + , subq_5.ds__month AS booking__ds__month , subq_5.ds__quarter , subq_5.ds__year , subq_5.ds__extract_year diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Databricks/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Databricks/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql index ce82121f18..47f5cd58be 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Databricks/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Databricks/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql @@ -18,7 +18,9 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_6.ts__week + subq_6.metric_time__hour + , subq_6.metric_time__day + , subq_6.ts__week , subq_6.ts__month , subq_6.ts__quarter , subq_6.ts__year @@ -28,13 +30,11 @@ FROM ( , subq_6.ts__extract_day , subq_6.ts__extract_dow , subq_6.ts__extract_doy - , subq_6.metric_time__day - , subq_6.metric_time__hour FROM ( -- Change Column Aliases SELECT - subq_5.ts__day AS metric_time__day - , subq_5.ts__hour AS metric_time__hour + subq_5.ts__hour AS metric_time__hour + , subq_5.ts__day AS metric_time__day , subq_5.ts__week , subq_5.ts__month , subq_5.ts__quarter diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Databricks/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Databricks/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql index 70b215bba9..8f7b68b166 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Databricks/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Databricks/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql @@ -16,8 +16,8 @@ FROM ( -- Read From Time Spine 'mf_time_spine_hour' -- Change Column Aliases SELECT - DATE_TRUNC('day', ts) AS metric_time__day - , ts AS metric_time__hour + ts AS metric_time__hour + , DATE_TRUNC('day', ts) AS metric_time__day FROM ***************************.mf_time_spine_hour time_spine_src_28005 ) subq_16 WHERE (metric_time__hour > '2020-01-01 00:09:00') AND (metric_time__day = '2020-01-01') diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Databricks/test_join_to_time_spine_with_filters__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Databricks/test_join_to_time_spine_with_filters__plan0.sql index d1c4005409..da884c4046 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Databricks/test_join_to_time_spine_with_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Databricks/test_join_to_time_spine_with_filters__plan0.sql @@ -23,7 +23,9 @@ FROM ( FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_8.ds__month + subq_8.metric_time__day + , subq_8.metric_time__week + , subq_8.ds__month , subq_8.ds__quarter , subq_8.ds__year , subq_8.ds__extract_year @@ -33,12 +35,12 @@ FROM ( , subq_8.ds__extract_dow , subq_8.ds__extract_doy , subq_8.ds__martian_day - , subq_8.metric_time__day - , subq_8.metric_time__week FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__month + subq_7.metric_time__day + , subq_7.metric_time__week + , subq_7.ds__month , subq_7.ds__quarter , subq_7.ds__year , subq_7.ds__extract_year @@ -48,8 +50,6 @@ FROM ( , subq_7.ds__extract_dow , subq_7.ds__extract_doy , subq_7.ds__martian_day - , subq_7.metric_time__day - , subq_7.metric_time__week FROM ( -- Change Column Aliases SELECT diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Databricks/test_simple_fill_nulls_with_0_month__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Databricks/test_simple_fill_nulls_with_0_month__plan0.sql index b733b1e1e7..8170944d86 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Databricks/test_simple_fill_nulls_with_0_month__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Databricks/test_simple_fill_nulls_with_0_month__plan0.sql @@ -18,9 +18,9 @@ FROM ( FROM ( -- Change Column Aliases SELECT - subq_4.ds__month AS metric_time__month - , subq_4.ds__day + subq_4.ds__day , subq_4.ds__week + , subq_4.ds__month AS metric_time__month , subq_4.ds__quarter , subq_4.ds__year , subq_4.ds__extract_year diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql index ea9c07be1a..d3cd92a43f 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql @@ -18,7 +18,9 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__week + subq_6.metric_time__day + , subq_6.ds__week + , subq_6.metric_time__month , subq_6.ds__quarter , subq_6.ds__year , subq_6.ds__extract_year @@ -28,14 +30,12 @@ FROM ( , subq_6.ds__extract_dow , subq_6.ds__extract_doy , subq_6.ds__martian_day - , subq_6.metric_time__day - , subq_6.metric_time__month FROM ( -- Change Column Aliases SELECT subq_5.ds__day AS metric_time__day - , subq_5.ds__month AS metric_time__month , subq_5.ds__week + , subq_5.ds__month AS metric_time__month , subq_5.ds__quarter , subq_5.ds__year , subq_5.ds__extract_year diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql index 8de3706f65..0180ffe119 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql @@ -18,7 +18,10 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__week + subq_6.booking__ds__day + , subq_6.metric_time__day + , subq_6.ds__week + , subq_6.booking__ds__month , subq_6.ds__quarter , subq_6.ds__year , subq_6.ds__extract_year @@ -28,16 +31,13 @@ FROM ( , subq_6.ds__extract_dow , subq_6.ds__extract_doy , subq_6.ds__martian_day - , subq_6.booking__ds__day - , subq_6.metric_time__day - , subq_6.booking__ds__month FROM ( -- Change Column Aliases SELECT subq_5.ds__day AS booking__ds__day , subq_5.ds__day AS metric_time__day - , subq_5.ds__month AS booking__ds__month , subq_5.ds__week + , subq_5.ds__month AS booking__ds__month , subq_5.ds__quarter , subq_5.ds__year , subq_5.ds__extract_year diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql index a40701c932..e13ab88256 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql @@ -18,7 +18,9 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__week + subq_6.metric_time__day + , subq_6.ds__week + , subq_6.booking__ds__month , subq_6.ds__quarter , subq_6.ds__year , subq_6.ds__extract_year @@ -28,14 +30,12 @@ FROM ( , subq_6.ds__extract_dow , subq_6.ds__extract_doy , subq_6.ds__martian_day - , subq_6.metric_time__day - , subq_6.booking__ds__month FROM ( -- Change Column Aliases SELECT subq_5.ds__day AS metric_time__day - , subq_5.ds__month AS booking__ds__month , subq_5.ds__week + , subq_5.ds__month AS booking__ds__month , subq_5.ds__quarter , subq_5.ds__year , subq_5.ds__extract_year diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql index 62fddb8e7a..33e2737b08 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql @@ -18,7 +18,9 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_6.ts__week + subq_6.metric_time__hour + , subq_6.metric_time__day + , subq_6.ts__week , subq_6.ts__month , subq_6.ts__quarter , subq_6.ts__year @@ -28,13 +30,11 @@ FROM ( , subq_6.ts__extract_day , subq_6.ts__extract_dow , subq_6.ts__extract_doy - , subq_6.metric_time__day - , subq_6.metric_time__hour FROM ( -- Change Column Aliases SELECT - subq_5.ts__day AS metric_time__day - , subq_5.ts__hour AS metric_time__hour + subq_5.ts__hour AS metric_time__hour + , subq_5.ts__day AS metric_time__day , subq_5.ts__week , subq_5.ts__month , subq_5.ts__quarter diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql index 40962ba36b..796df4b8e0 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql @@ -16,8 +16,8 @@ FROM ( -- Read From Time Spine 'mf_time_spine_hour' -- Change Column Aliases SELECT - DATE_TRUNC('day', ts) AS metric_time__day - , ts AS metric_time__hour + ts AS metric_time__hour + , DATE_TRUNC('day', ts) AS metric_time__day FROM ***************************.mf_time_spine_hour time_spine_src_28005 ) subq_16 WHERE (metric_time__hour > '2020-01-01 00:09:00') AND (metric_time__day = '2020-01-01') diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_join_to_time_spine_with_filters__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_join_to_time_spine_with_filters__plan0.sql index e5e3fae835..645f31182d 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_join_to_time_spine_with_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_join_to_time_spine_with_filters__plan0.sql @@ -23,7 +23,9 @@ FROM ( FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_8.ds__month + subq_8.metric_time__day + , subq_8.metric_time__week + , subq_8.ds__month , subq_8.ds__quarter , subq_8.ds__year , subq_8.ds__extract_year @@ -33,12 +35,12 @@ FROM ( , subq_8.ds__extract_dow , subq_8.ds__extract_doy , subq_8.ds__martian_day - , subq_8.metric_time__day - , subq_8.metric_time__week FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__month + subq_7.metric_time__day + , subq_7.metric_time__week + , subq_7.ds__month , subq_7.ds__quarter , subq_7.ds__year , subq_7.ds__extract_year @@ -48,8 +50,6 @@ FROM ( , subq_7.ds__extract_dow , subq_7.ds__extract_doy , subq_7.ds__martian_day - , subq_7.metric_time__day - , subq_7.metric_time__week FROM ( -- Change Column Aliases SELECT diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_simple_fill_nulls_with_0_month__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_simple_fill_nulls_with_0_month__plan0.sql index 81c05fd111..d3a38d45fd 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_simple_fill_nulls_with_0_month__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_simple_fill_nulls_with_0_month__plan0.sql @@ -18,9 +18,9 @@ FROM ( FROM ( -- Change Column Aliases SELECT - subq_4.ds__month AS metric_time__month - , subq_4.ds__day + subq_4.ds__day , subq_4.ds__week + , subq_4.ds__month AS metric_time__month , subq_4.ds__quarter , subq_4.ds__year , subq_4.ds__extract_year diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Postgres/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Postgres/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql index 613ff9b9f7..25971a0351 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Postgres/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Postgres/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql @@ -18,7 +18,9 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__week + subq_6.metric_time__day + , subq_6.ds__week + , subq_6.metric_time__month , subq_6.ds__quarter , subq_6.ds__year , subq_6.ds__extract_year @@ -28,14 +30,12 @@ FROM ( , subq_6.ds__extract_dow , subq_6.ds__extract_doy , subq_6.ds__martian_day - , subq_6.metric_time__day - , subq_6.metric_time__month FROM ( -- Change Column Aliases SELECT subq_5.ds__day AS metric_time__day - , subq_5.ds__month AS metric_time__month , subq_5.ds__week + , subq_5.ds__month AS metric_time__month , subq_5.ds__quarter , subq_5.ds__year , subq_5.ds__extract_year diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Postgres/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Postgres/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql index a436bd0273..cb94b85045 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Postgres/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Postgres/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql @@ -18,7 +18,10 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__week + subq_6.booking__ds__day + , subq_6.metric_time__day + , subq_6.ds__week + , subq_6.booking__ds__month , subq_6.ds__quarter , subq_6.ds__year , subq_6.ds__extract_year @@ -28,16 +31,13 @@ FROM ( , subq_6.ds__extract_dow , subq_6.ds__extract_doy , subq_6.ds__martian_day - , subq_6.booking__ds__day - , subq_6.metric_time__day - , subq_6.booking__ds__month FROM ( -- Change Column Aliases SELECT subq_5.ds__day AS booking__ds__day , subq_5.ds__day AS metric_time__day - , subq_5.ds__month AS booking__ds__month , subq_5.ds__week + , subq_5.ds__month AS booking__ds__month , subq_5.ds__quarter , subq_5.ds__year , subq_5.ds__extract_year diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Postgres/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Postgres/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql index caaba9e357..024bfed62d 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Postgres/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Postgres/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql @@ -18,7 +18,9 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__week + subq_6.metric_time__day + , subq_6.ds__week + , subq_6.booking__ds__month , subq_6.ds__quarter , subq_6.ds__year , subq_6.ds__extract_year @@ -28,14 +30,12 @@ FROM ( , subq_6.ds__extract_dow , subq_6.ds__extract_doy , subq_6.ds__martian_day - , subq_6.metric_time__day - , subq_6.booking__ds__month FROM ( -- Change Column Aliases SELECT subq_5.ds__day AS metric_time__day - , subq_5.ds__month AS booking__ds__month , subq_5.ds__week + , subq_5.ds__month AS booking__ds__month , subq_5.ds__quarter , subq_5.ds__year , subq_5.ds__extract_year diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Postgres/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Postgres/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql index 83cc067fbb..f2f9ee17dc 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Postgres/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Postgres/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql @@ -18,7 +18,9 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_6.ts__week + subq_6.metric_time__hour + , subq_6.metric_time__day + , subq_6.ts__week , subq_6.ts__month , subq_6.ts__quarter , subq_6.ts__year @@ -28,13 +30,11 @@ FROM ( , subq_6.ts__extract_day , subq_6.ts__extract_dow , subq_6.ts__extract_doy - , subq_6.metric_time__day - , subq_6.metric_time__hour FROM ( -- Change Column Aliases SELECT - subq_5.ts__day AS metric_time__day - , subq_5.ts__hour AS metric_time__hour + subq_5.ts__hour AS metric_time__hour + , subq_5.ts__day AS metric_time__day , subq_5.ts__week , subq_5.ts__month , subq_5.ts__quarter diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Postgres/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Postgres/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql index e77eda9809..fe97d6ccc3 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Postgres/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Postgres/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql @@ -16,8 +16,8 @@ FROM ( -- Read From Time Spine 'mf_time_spine_hour' -- Change Column Aliases SELECT - DATE_TRUNC('day', ts) AS metric_time__day - , ts AS metric_time__hour + ts AS metric_time__hour + , DATE_TRUNC('day', ts) AS metric_time__day FROM ***************************.mf_time_spine_hour time_spine_src_28005 ) subq_16 WHERE (metric_time__hour > '2020-01-01 00:09:00') AND (metric_time__day = '2020-01-01') diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Postgres/test_join_to_time_spine_with_filters__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Postgres/test_join_to_time_spine_with_filters__plan0.sql index 1d71a3fa39..a012a4779e 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Postgres/test_join_to_time_spine_with_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Postgres/test_join_to_time_spine_with_filters__plan0.sql @@ -23,7 +23,9 @@ FROM ( FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_8.ds__month + subq_8.metric_time__day + , subq_8.metric_time__week + , subq_8.ds__month , subq_8.ds__quarter , subq_8.ds__year , subq_8.ds__extract_year @@ -33,12 +35,12 @@ FROM ( , subq_8.ds__extract_dow , subq_8.ds__extract_doy , subq_8.ds__martian_day - , subq_8.metric_time__day - , subq_8.metric_time__week FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__month + subq_7.metric_time__day + , subq_7.metric_time__week + , subq_7.ds__month , subq_7.ds__quarter , subq_7.ds__year , subq_7.ds__extract_year @@ -48,8 +50,6 @@ FROM ( , subq_7.ds__extract_dow , subq_7.ds__extract_doy , subq_7.ds__martian_day - , subq_7.metric_time__day - , subq_7.metric_time__week FROM ( -- Change Column Aliases SELECT diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Postgres/test_simple_fill_nulls_with_0_month__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Postgres/test_simple_fill_nulls_with_0_month__plan0.sql index 1395a904cc..8e5e82a756 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Postgres/test_simple_fill_nulls_with_0_month__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Postgres/test_simple_fill_nulls_with_0_month__plan0.sql @@ -18,9 +18,9 @@ FROM ( FROM ( -- Change Column Aliases SELECT - subq_4.ds__month AS metric_time__month - , subq_4.ds__day + subq_4.ds__day , subq_4.ds__week + , subq_4.ds__month AS metric_time__month , subq_4.ds__quarter , subq_4.ds__year , subq_4.ds__extract_year diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Redshift/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Redshift/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql index 05d55b4642..756c463784 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Redshift/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Redshift/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql @@ -18,7 +18,9 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__week + subq_6.metric_time__day + , subq_6.ds__week + , subq_6.metric_time__month , subq_6.ds__quarter , subq_6.ds__year , subq_6.ds__extract_year @@ -28,14 +30,12 @@ FROM ( , subq_6.ds__extract_dow , subq_6.ds__extract_doy , subq_6.ds__martian_day - , subq_6.metric_time__day - , subq_6.metric_time__month FROM ( -- Change Column Aliases SELECT subq_5.ds__day AS metric_time__day - , subq_5.ds__month AS metric_time__month , subq_5.ds__week + , subq_5.ds__month AS metric_time__month , subq_5.ds__quarter , subq_5.ds__year , subq_5.ds__extract_year diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Redshift/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Redshift/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql index 8a919d4840..3a0e305f72 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Redshift/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Redshift/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql @@ -18,7 +18,10 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__week + subq_6.booking__ds__day + , subq_6.metric_time__day + , subq_6.ds__week + , subq_6.booking__ds__month , subq_6.ds__quarter , subq_6.ds__year , subq_6.ds__extract_year @@ -28,16 +31,13 @@ FROM ( , subq_6.ds__extract_dow , subq_6.ds__extract_doy , subq_6.ds__martian_day - , subq_6.booking__ds__day - , subq_6.metric_time__day - , subq_6.booking__ds__month FROM ( -- Change Column Aliases SELECT subq_5.ds__day AS booking__ds__day , subq_5.ds__day AS metric_time__day - , subq_5.ds__month AS booking__ds__month , subq_5.ds__week + , subq_5.ds__month AS booking__ds__month , subq_5.ds__quarter , subq_5.ds__year , subq_5.ds__extract_year diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Redshift/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Redshift/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql index 570e63b540..d7944f7332 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Redshift/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Redshift/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql @@ -18,7 +18,9 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__week + subq_6.metric_time__day + , subq_6.ds__week + , subq_6.booking__ds__month , subq_6.ds__quarter , subq_6.ds__year , subq_6.ds__extract_year @@ -28,14 +30,12 @@ FROM ( , subq_6.ds__extract_dow , subq_6.ds__extract_doy , subq_6.ds__martian_day - , subq_6.metric_time__day - , subq_6.booking__ds__month FROM ( -- Change Column Aliases SELECT subq_5.ds__day AS metric_time__day - , subq_5.ds__month AS booking__ds__month , subq_5.ds__week + , subq_5.ds__month AS booking__ds__month , subq_5.ds__quarter , subq_5.ds__year , subq_5.ds__extract_year diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Redshift/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Redshift/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql index 3e6568ab61..1b8edd8b69 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Redshift/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Redshift/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql @@ -18,7 +18,9 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_6.ts__week + subq_6.metric_time__hour + , subq_6.metric_time__day + , subq_6.ts__week , subq_6.ts__month , subq_6.ts__quarter , subq_6.ts__year @@ -28,13 +30,11 @@ FROM ( , subq_6.ts__extract_day , subq_6.ts__extract_dow , subq_6.ts__extract_doy - , subq_6.metric_time__day - , subq_6.metric_time__hour FROM ( -- Change Column Aliases SELECT - subq_5.ts__day AS metric_time__day - , subq_5.ts__hour AS metric_time__hour + subq_5.ts__hour AS metric_time__hour + , subq_5.ts__day AS metric_time__day , subq_5.ts__week , subq_5.ts__month , subq_5.ts__quarter diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Redshift/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Redshift/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql index 911deb7948..17f35d96bc 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Redshift/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Redshift/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql @@ -16,8 +16,8 @@ FROM ( -- Read From Time Spine 'mf_time_spine_hour' -- Change Column Aliases SELECT - DATE_TRUNC('day', ts) AS metric_time__day - , ts AS metric_time__hour + ts AS metric_time__hour + , DATE_TRUNC('day', ts) AS metric_time__day FROM ***************************.mf_time_spine_hour time_spine_src_28005 ) subq_16 WHERE (metric_time__hour > '2020-01-01 00:09:00') AND (metric_time__day = '2020-01-01') diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Redshift/test_join_to_time_spine_with_filters__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Redshift/test_join_to_time_spine_with_filters__plan0.sql index 960df99a07..6ff201115e 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Redshift/test_join_to_time_spine_with_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Redshift/test_join_to_time_spine_with_filters__plan0.sql @@ -23,7 +23,9 @@ FROM ( FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_8.ds__month + subq_8.metric_time__day + , subq_8.metric_time__week + , subq_8.ds__month , subq_8.ds__quarter , subq_8.ds__year , subq_8.ds__extract_year @@ -33,12 +35,12 @@ FROM ( , subq_8.ds__extract_dow , subq_8.ds__extract_doy , subq_8.ds__martian_day - , subq_8.metric_time__day - , subq_8.metric_time__week FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__month + subq_7.metric_time__day + , subq_7.metric_time__week + , subq_7.ds__month , subq_7.ds__quarter , subq_7.ds__year , subq_7.ds__extract_year @@ -48,8 +50,6 @@ FROM ( , subq_7.ds__extract_dow , subq_7.ds__extract_doy , subq_7.ds__martian_day - , subq_7.metric_time__day - , subq_7.metric_time__week FROM ( -- Change Column Aliases SELECT diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Redshift/test_simple_fill_nulls_with_0_month__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Redshift/test_simple_fill_nulls_with_0_month__plan0.sql index bf636fce3c..bfc6f4027f 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Redshift/test_simple_fill_nulls_with_0_month__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Redshift/test_simple_fill_nulls_with_0_month__plan0.sql @@ -18,9 +18,9 @@ FROM ( FROM ( -- Change Column Aliases SELECT - subq_4.ds__month AS metric_time__month - , subq_4.ds__day + subq_4.ds__day , subq_4.ds__week + , subq_4.ds__month AS metric_time__month , subq_4.ds__quarter , subq_4.ds__year , subq_4.ds__extract_year diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql index 6a1816a439..aa655a7880 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql @@ -18,7 +18,9 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__week + subq_6.metric_time__day + , subq_6.ds__week + , subq_6.metric_time__month , subq_6.ds__quarter , subq_6.ds__year , subq_6.ds__extract_year @@ -28,14 +30,12 @@ FROM ( , subq_6.ds__extract_dow , subq_6.ds__extract_doy , subq_6.ds__martian_day - , subq_6.metric_time__day - , subq_6.metric_time__month FROM ( -- Change Column Aliases SELECT subq_5.ds__day AS metric_time__day - , subq_5.ds__month AS metric_time__month , subq_5.ds__week + , subq_5.ds__month AS metric_time__month , subq_5.ds__quarter , subq_5.ds__year , subq_5.ds__extract_year diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql index f565ab4493..02ae18658b 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql @@ -18,7 +18,10 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__week + subq_6.booking__ds__day + , subq_6.metric_time__day + , subq_6.ds__week + , subq_6.booking__ds__month , subq_6.ds__quarter , subq_6.ds__year , subq_6.ds__extract_year @@ -28,16 +31,13 @@ FROM ( , subq_6.ds__extract_dow , subq_6.ds__extract_doy , subq_6.ds__martian_day - , subq_6.booking__ds__day - , subq_6.metric_time__day - , subq_6.booking__ds__month FROM ( -- Change Column Aliases SELECT subq_5.ds__day AS booking__ds__day , subq_5.ds__day AS metric_time__day - , subq_5.ds__month AS booking__ds__month , subq_5.ds__week + , subq_5.ds__month AS booking__ds__month , subq_5.ds__quarter , subq_5.ds__year , subq_5.ds__extract_year diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql index 67b0945186..e769c3f01c 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql @@ -18,7 +18,9 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__week + subq_6.metric_time__day + , subq_6.ds__week + , subq_6.booking__ds__month , subq_6.ds__quarter , subq_6.ds__year , subq_6.ds__extract_year @@ -28,14 +30,12 @@ FROM ( , subq_6.ds__extract_dow , subq_6.ds__extract_doy , subq_6.ds__martian_day - , subq_6.metric_time__day - , subq_6.booking__ds__month FROM ( -- Change Column Aliases SELECT subq_5.ds__day AS metric_time__day - , subq_5.ds__month AS booking__ds__month , subq_5.ds__week + , subq_5.ds__month AS booking__ds__month , subq_5.ds__quarter , subq_5.ds__year , subq_5.ds__extract_year diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Snowflake/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Snowflake/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql index ccde941e08..a119263e21 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Snowflake/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Snowflake/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql @@ -18,7 +18,9 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_6.ts__week + subq_6.metric_time__hour + , subq_6.metric_time__day + , subq_6.ts__week , subq_6.ts__month , subq_6.ts__quarter , subq_6.ts__year @@ -28,13 +30,11 @@ FROM ( , subq_6.ts__extract_day , subq_6.ts__extract_dow , subq_6.ts__extract_doy - , subq_6.metric_time__day - , subq_6.metric_time__hour FROM ( -- Change Column Aliases SELECT - subq_5.ts__day AS metric_time__day - , subq_5.ts__hour AS metric_time__hour + subq_5.ts__hour AS metric_time__hour + , subq_5.ts__day AS metric_time__day , subq_5.ts__week , subq_5.ts__month , subq_5.ts__quarter diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Snowflake/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Snowflake/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql index e9e63dd182..8b3acbd417 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Snowflake/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Snowflake/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql @@ -16,8 +16,8 @@ FROM ( -- Read From Time Spine 'mf_time_spine_hour' -- Change Column Aliases SELECT - DATE_TRUNC('day', ts) AS metric_time__day - , ts AS metric_time__hour + ts AS metric_time__hour + , DATE_TRUNC('day', ts) AS metric_time__day FROM ***************************.mf_time_spine_hour time_spine_src_28005 ) subq_16 WHERE (metric_time__hour > '2020-01-01 00:09:00') AND (metric_time__day = '2020-01-01') diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Snowflake/test_join_to_time_spine_with_filters__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Snowflake/test_join_to_time_spine_with_filters__plan0.sql index ccb0af5b45..007fc30da5 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Snowflake/test_join_to_time_spine_with_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Snowflake/test_join_to_time_spine_with_filters__plan0.sql @@ -23,7 +23,9 @@ FROM ( FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_8.ds__month + subq_8.metric_time__day + , subq_8.metric_time__week + , subq_8.ds__month , subq_8.ds__quarter , subq_8.ds__year , subq_8.ds__extract_year @@ -33,12 +35,12 @@ FROM ( , subq_8.ds__extract_dow , subq_8.ds__extract_doy , subq_8.ds__martian_day - , subq_8.metric_time__day - , subq_8.metric_time__week FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__month + subq_7.metric_time__day + , subq_7.metric_time__week + , subq_7.ds__month , subq_7.ds__quarter , subq_7.ds__year , subq_7.ds__extract_year @@ -48,8 +50,6 @@ FROM ( , subq_7.ds__extract_dow , subq_7.ds__extract_doy , subq_7.ds__martian_day - , subq_7.metric_time__day - , subq_7.metric_time__week FROM ( -- Change Column Aliases SELECT diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Snowflake/test_simple_fill_nulls_with_0_month__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Snowflake/test_simple_fill_nulls_with_0_month__plan0.sql index f3f30f32cd..0aabe553b7 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Snowflake/test_simple_fill_nulls_with_0_month__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Snowflake/test_simple_fill_nulls_with_0_month__plan0.sql @@ -18,9 +18,9 @@ FROM ( FROM ( -- Change Column Aliases SELECT - subq_4.ds__month AS metric_time__month - , subq_4.ds__day + subq_4.ds__day , subq_4.ds__week + , subq_4.ds__month AS metric_time__month , subq_4.ds__quarter , subq_4.ds__year , subq_4.ds__extract_year diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Trino/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Trino/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql index 6275f67b93..63cbb01169 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Trino/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Trino/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql @@ -18,7 +18,9 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__week + subq_6.metric_time__day + , subq_6.ds__week + , subq_6.metric_time__month , subq_6.ds__quarter , subq_6.ds__year , subq_6.ds__extract_year @@ -28,14 +30,12 @@ FROM ( , subq_6.ds__extract_dow , subq_6.ds__extract_doy , subq_6.ds__martian_day - , subq_6.metric_time__day - , subq_6.metric_time__month FROM ( -- Change Column Aliases SELECT subq_5.ds__day AS metric_time__day - , subq_5.ds__month AS metric_time__month , subq_5.ds__week + , subq_5.ds__month AS metric_time__month , subq_5.ds__quarter , subq_5.ds__year , subq_5.ds__extract_year diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Trino/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Trino/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql index 29385ce13a..5ce2d0995e 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Trino/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Trino/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql @@ -18,7 +18,10 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__week + subq_6.booking__ds__day + , subq_6.metric_time__day + , subq_6.ds__week + , subq_6.booking__ds__month , subq_6.ds__quarter , subq_6.ds__year , subq_6.ds__extract_year @@ -28,16 +31,13 @@ FROM ( , subq_6.ds__extract_dow , subq_6.ds__extract_doy , subq_6.ds__martian_day - , subq_6.booking__ds__day - , subq_6.metric_time__day - , subq_6.booking__ds__month FROM ( -- Change Column Aliases SELECT subq_5.ds__day AS booking__ds__day , subq_5.ds__day AS metric_time__day - , subq_5.ds__month AS booking__ds__month , subq_5.ds__week + , subq_5.ds__month AS booking__ds__month , subq_5.ds__quarter , subq_5.ds__year , subq_5.ds__extract_year diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Trino/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Trino/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql index a24e70996b..444b052eac 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Trino/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Trino/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql @@ -18,7 +18,9 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__week + subq_6.metric_time__day + , subq_6.ds__week + , subq_6.booking__ds__month , subq_6.ds__quarter , subq_6.ds__year , subq_6.ds__extract_year @@ -28,14 +30,12 @@ FROM ( , subq_6.ds__extract_dow , subq_6.ds__extract_doy , subq_6.ds__martian_day - , subq_6.metric_time__day - , subq_6.booking__ds__month FROM ( -- Change Column Aliases SELECT subq_5.ds__day AS metric_time__day - , subq_5.ds__month AS booking__ds__month , subq_5.ds__week + , subq_5.ds__month AS booking__ds__month , subq_5.ds__quarter , subq_5.ds__year , subq_5.ds__extract_year diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Trino/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Trino/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql index 3d3988cf90..2fe7f58dad 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Trino/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Trino/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql @@ -18,7 +18,9 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_6.ts__week + subq_6.metric_time__hour + , subq_6.metric_time__day + , subq_6.ts__week , subq_6.ts__month , subq_6.ts__quarter , subq_6.ts__year @@ -28,13 +30,11 @@ FROM ( , subq_6.ts__extract_day , subq_6.ts__extract_dow , subq_6.ts__extract_doy - , subq_6.metric_time__day - , subq_6.metric_time__hour FROM ( -- Change Column Aliases SELECT - subq_5.ts__day AS metric_time__day - , subq_5.ts__hour AS metric_time__hour + subq_5.ts__hour AS metric_time__hour + , subq_5.ts__day AS metric_time__day , subq_5.ts__week , subq_5.ts__month , subq_5.ts__quarter diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Trino/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Trino/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql index 9225ef5cfc..f848896c2d 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Trino/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Trino/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql @@ -16,8 +16,8 @@ FROM ( -- Read From Time Spine 'mf_time_spine_hour' -- Change Column Aliases SELECT - DATE_TRUNC('day', ts) AS metric_time__day - , ts AS metric_time__hour + ts AS metric_time__hour + , DATE_TRUNC('day', ts) AS metric_time__day FROM ***************************.mf_time_spine_hour time_spine_src_28005 ) subq_16 WHERE (metric_time__hour > '2020-01-01 00:09:00') AND (metric_time__day = '2020-01-01') diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Trino/test_join_to_time_spine_with_filters__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Trino/test_join_to_time_spine_with_filters__plan0.sql index 9f9e4912a2..395a3dceeb 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Trino/test_join_to_time_spine_with_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Trino/test_join_to_time_spine_with_filters__plan0.sql @@ -23,7 +23,9 @@ FROM ( FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_8.ds__month + subq_8.metric_time__day + , subq_8.metric_time__week + , subq_8.ds__month , subq_8.ds__quarter , subq_8.ds__year , subq_8.ds__extract_year @@ -33,12 +35,12 @@ FROM ( , subq_8.ds__extract_dow , subq_8.ds__extract_doy , subq_8.ds__martian_day - , subq_8.metric_time__day - , subq_8.metric_time__week FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__month + subq_7.metric_time__day + , subq_7.metric_time__week + , subq_7.ds__month , subq_7.ds__quarter , subq_7.ds__year , subq_7.ds__extract_year @@ -48,8 +50,6 @@ FROM ( , subq_7.ds__extract_dow , subq_7.ds__extract_doy , subq_7.ds__martian_day - , subq_7.metric_time__day - , subq_7.metric_time__week FROM ( -- Change Column Aliases SELECT diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Trino/test_simple_fill_nulls_with_0_month__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Trino/test_simple_fill_nulls_with_0_month__plan0.sql index 380273fae3..7fb571d0a2 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Trino/test_simple_fill_nulls_with_0_month__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/Trino/test_simple_fill_nulls_with_0_month__plan0.sql @@ -18,9 +18,9 @@ FROM ( FROM ( -- Change Column Aliases SELECT - subq_4.ds__month AS metric_time__month - , subq_4.ds__day + subq_4.ds__day , subq_4.ds__week + , subq_4.ds__month AS metric_time__month , subq_4.ds__quarter , subq_4.ds__year , subq_4.ds__extract_year diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/BigQuery/test_offset_window_with_date_part__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/BigQuery/test_offset_window_with_date_part__plan0.sql index 9ac345a079..7d7f9f9d3a 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/BigQuery/test_offset_window_with_date_part__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/BigQuery/test_offset_window_with_date_part__plan0.sql @@ -352,7 +352,6 @@ FROM ( -- Change Column Aliases SELECT subq_7.ds__day AS metric_time__day - , subq_7.ds__extract_dow AS metric_time__extract_dow , subq_7.ds__week , subq_7.ds__month , subq_7.ds__quarter @@ -361,6 +360,7 @@ FROM ( , subq_7.ds__extract_quarter , subq_7.ds__extract_month , subq_7.ds__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow , subq_7.ds__extract_doy , subq_7.ds__martian_day FROM ( diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/BigQuery/test_subdaily_time_constraint_with_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/BigQuery/test_subdaily_time_constraint_with_metric__plan0.sql index bc0e7ccf48..49ba7e7cd3 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/BigQuery/test_subdaily_time_constraint_with_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/BigQuery/test_subdaily_time_constraint_with_metric__plan0.sql @@ -23,7 +23,8 @@ FROM ( FROM ( -- Constrain Time Range to [2020-01-01T02:00:00, 2020-01-01T05:00:00] SELECT - subq_6.ts__day + subq_6.metric_time__hour + , subq_6.ts__day , subq_6.ts__week , subq_6.ts__month , subq_6.ts__quarter @@ -34,7 +35,6 @@ FROM ( , subq_6.ts__extract_day , subq_6.ts__extract_dow , subq_6.ts__extract_doy - , subq_6.metric_time__hour FROM ( -- Change Column Aliases SELECT diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Databricks/test_offset_window_with_date_part__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Databricks/test_offset_window_with_date_part__plan0.sql index 9995adafe8..aef44447d5 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Databricks/test_offset_window_with_date_part__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Databricks/test_offset_window_with_date_part__plan0.sql @@ -352,7 +352,6 @@ FROM ( -- Change Column Aliases SELECT subq_7.ds__day AS metric_time__day - , subq_7.ds__extract_dow AS metric_time__extract_dow , subq_7.ds__week , subq_7.ds__month , subq_7.ds__quarter @@ -361,6 +360,7 @@ FROM ( , subq_7.ds__extract_quarter , subq_7.ds__extract_month , subq_7.ds__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow , subq_7.ds__extract_doy , subq_7.ds__martian_day FROM ( diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Databricks/test_subdaily_time_constraint_with_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Databricks/test_subdaily_time_constraint_with_metric__plan0.sql index fcfed24283..b972426868 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Databricks/test_subdaily_time_constraint_with_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Databricks/test_subdaily_time_constraint_with_metric__plan0.sql @@ -23,7 +23,8 @@ FROM ( FROM ( -- Constrain Time Range to [2020-01-01T02:00:00, 2020-01-01T05:00:00] SELECT - subq_6.ts__day + subq_6.metric_time__hour + , subq_6.ts__day , subq_6.ts__week , subq_6.ts__month , subq_6.ts__quarter @@ -34,7 +35,6 @@ FROM ( , subq_6.ts__extract_day , subq_6.ts__extract_dow , subq_6.ts__extract_doy - , subq_6.metric_time__hour FROM ( -- Change Column Aliases SELECT diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/DuckDB/test_offset_window_with_date_part__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/DuckDB/test_offset_window_with_date_part__plan0.sql index 81b8d3102d..e9ac131621 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/DuckDB/test_offset_window_with_date_part__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/DuckDB/test_offset_window_with_date_part__plan0.sql @@ -352,7 +352,6 @@ FROM ( -- Change Column Aliases SELECT subq_7.ds__day AS metric_time__day - , subq_7.ds__extract_dow AS metric_time__extract_dow , subq_7.ds__week , subq_7.ds__month , subq_7.ds__quarter @@ -361,6 +360,7 @@ FROM ( , subq_7.ds__extract_quarter , subq_7.ds__extract_month , subq_7.ds__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow , subq_7.ds__extract_doy , subq_7.ds__martian_day FROM ( diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/DuckDB/test_subdaily_time_constraint_with_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/DuckDB/test_subdaily_time_constraint_with_metric__plan0.sql index 13336354fc..9163159724 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/DuckDB/test_subdaily_time_constraint_with_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/DuckDB/test_subdaily_time_constraint_with_metric__plan0.sql @@ -23,7 +23,8 @@ FROM ( FROM ( -- Constrain Time Range to [2020-01-01T02:00:00, 2020-01-01T05:00:00] SELECT - subq_6.ts__day + subq_6.metric_time__hour + , subq_6.ts__day , subq_6.ts__week , subq_6.ts__month , subq_6.ts__quarter @@ -34,7 +35,6 @@ FROM ( , subq_6.ts__extract_day , subq_6.ts__extract_dow , subq_6.ts__extract_doy - , subq_6.metric_time__hour FROM ( -- Change Column Aliases SELECT diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Postgres/test_offset_window_with_date_part__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Postgres/test_offset_window_with_date_part__plan0.sql index 7d63ccb295..b407a2080e 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Postgres/test_offset_window_with_date_part__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Postgres/test_offset_window_with_date_part__plan0.sql @@ -352,7 +352,6 @@ FROM ( -- Change Column Aliases SELECT subq_7.ds__day AS metric_time__day - , subq_7.ds__extract_dow AS metric_time__extract_dow , subq_7.ds__week , subq_7.ds__month , subq_7.ds__quarter @@ -361,6 +360,7 @@ FROM ( , subq_7.ds__extract_quarter , subq_7.ds__extract_month , subq_7.ds__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow , subq_7.ds__extract_doy , subq_7.ds__martian_day FROM ( diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Postgres/test_subdaily_time_constraint_with_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Postgres/test_subdaily_time_constraint_with_metric__plan0.sql index 6f5bdbd17b..0b790fb63f 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Postgres/test_subdaily_time_constraint_with_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Postgres/test_subdaily_time_constraint_with_metric__plan0.sql @@ -23,7 +23,8 @@ FROM ( FROM ( -- Constrain Time Range to [2020-01-01T02:00:00, 2020-01-01T05:00:00] SELECT - subq_6.ts__day + subq_6.metric_time__hour + , subq_6.ts__day , subq_6.ts__week , subq_6.ts__month , subq_6.ts__quarter @@ -34,7 +35,6 @@ FROM ( , subq_6.ts__extract_day , subq_6.ts__extract_dow , subq_6.ts__extract_doy - , subq_6.metric_time__hour FROM ( -- Change Column Aliases SELECT diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Redshift/test_offset_window_with_date_part__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Redshift/test_offset_window_with_date_part__plan0.sql index dfbc4c831f..f9bcd9dc66 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Redshift/test_offset_window_with_date_part__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Redshift/test_offset_window_with_date_part__plan0.sql @@ -352,7 +352,6 @@ FROM ( -- Change Column Aliases SELECT subq_7.ds__day AS metric_time__day - , subq_7.ds__extract_dow AS metric_time__extract_dow , subq_7.ds__week , subq_7.ds__month , subq_7.ds__quarter @@ -361,6 +360,7 @@ FROM ( , subq_7.ds__extract_quarter , subq_7.ds__extract_month , subq_7.ds__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow , subq_7.ds__extract_doy , subq_7.ds__martian_day FROM ( diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Redshift/test_subdaily_time_constraint_with_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Redshift/test_subdaily_time_constraint_with_metric__plan0.sql index edee599bbf..bb2d3dc609 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Redshift/test_subdaily_time_constraint_with_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Redshift/test_subdaily_time_constraint_with_metric__plan0.sql @@ -23,7 +23,8 @@ FROM ( FROM ( -- Constrain Time Range to [2020-01-01T02:00:00, 2020-01-01T05:00:00] SELECT - subq_6.ts__day + subq_6.metric_time__hour + , subq_6.ts__day , subq_6.ts__week , subq_6.ts__month , subq_6.ts__quarter @@ -34,7 +35,6 @@ FROM ( , subq_6.ts__extract_day , subq_6.ts__extract_dow , subq_6.ts__extract_doy - , subq_6.metric_time__hour FROM ( -- Change Column Aliases SELECT diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Snowflake/test_offset_window_with_date_part__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Snowflake/test_offset_window_with_date_part__plan0.sql index a6882fb7e4..0433dd71e9 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Snowflake/test_offset_window_with_date_part__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Snowflake/test_offset_window_with_date_part__plan0.sql @@ -352,7 +352,6 @@ FROM ( -- Change Column Aliases SELECT subq_7.ds__day AS metric_time__day - , subq_7.ds__extract_dow AS metric_time__extract_dow , subq_7.ds__week , subq_7.ds__month , subq_7.ds__quarter @@ -361,6 +360,7 @@ FROM ( , subq_7.ds__extract_quarter , subq_7.ds__extract_month , subq_7.ds__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow , subq_7.ds__extract_doy , subq_7.ds__martian_day FROM ( diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Snowflake/test_subdaily_time_constraint_with_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Snowflake/test_subdaily_time_constraint_with_metric__plan0.sql index 2c61e86422..5ea52552ed 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Snowflake/test_subdaily_time_constraint_with_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Snowflake/test_subdaily_time_constraint_with_metric__plan0.sql @@ -23,7 +23,8 @@ FROM ( FROM ( -- Constrain Time Range to [2020-01-01T02:00:00, 2020-01-01T05:00:00] SELECT - subq_6.ts__day + subq_6.metric_time__hour + , subq_6.ts__day , subq_6.ts__week , subq_6.ts__month , subq_6.ts__quarter @@ -34,7 +35,6 @@ FROM ( , subq_6.ts__extract_day , subq_6.ts__extract_dow , subq_6.ts__extract_doy - , subq_6.metric_time__hour FROM ( -- Change Column Aliases SELECT diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Trino/test_offset_window_with_date_part__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Trino/test_offset_window_with_date_part__plan0.sql index 76c944eca9..352fa3e2d2 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Trino/test_offset_window_with_date_part__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Trino/test_offset_window_with_date_part__plan0.sql @@ -352,7 +352,6 @@ FROM ( -- Change Column Aliases SELECT subq_7.ds__day AS metric_time__day - , subq_7.ds__extract_dow AS metric_time__extract_dow , subq_7.ds__week , subq_7.ds__month , subq_7.ds__quarter @@ -361,6 +360,7 @@ FROM ( , subq_7.ds__extract_quarter , subq_7.ds__extract_month , subq_7.ds__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow , subq_7.ds__extract_doy , subq_7.ds__martian_day FROM ( diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Trino/test_subdaily_time_constraint_with_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Trino/test_subdaily_time_constraint_with_metric__plan0.sql index 7801dae2b0..727143509a 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Trino/test_subdaily_time_constraint_with_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlPlan/Trino/test_subdaily_time_constraint_with_metric__plan0.sql @@ -23,7 +23,8 @@ FROM ( FROM ( -- Constrain Time Range to [2020-01-01T02:00:00, 2020-01-01T05:00:00] SELECT - subq_6.ts__day + subq_6.metric_time__hour + , subq_6.ts__day , subq_6.ts__week , subq_6.ts__month , subq_6.ts__quarter @@ -34,7 +35,6 @@ FROM ( , subq_6.ts__extract_day , subq_6.ts__extract_dow , subq_6.ts__extract_doy - , subq_6.metric_time__hour FROM ( -- Change Column Aliases SELECT diff --git a/tests_metricflow/snapshots/test_query_output.py/str/DuckDB/test_derived_metric_alias__query_output.txt b/tests_metricflow/snapshots/test_query_output.py/str/DuckDB/test_derived_metric_alias__query_output.txt new file mode 100644 index 0000000000..3bd5675971 --- /dev/null +++ b/tests_metricflow/snapshots/test_query_output.py/str/DuckDB/test_derived_metric_alias__query_output.txt @@ -0,0 +1,12 @@ +test_name: test_derived_metric_alias +test_filename: test_query_output.py +--- +metric_time__day booking_fees_alias +------------------- -------------------- +2019-12-01T00:00:00 47.56 +2019-12-18T00:00:00 284.93 +2019-12-19T00:00:00 360.5 +2019-12-20T00:00:00 0 +2020-01-01T00:00:00 136.16 +2020-01-02T00:00:00 132.78 +2020-01-03T00:00:00 0 diff --git a/tests_metricflow/snapshots/test_query_output.py/str/DuckDB/test_metric_alias__query_output.txt b/tests_metricflow/snapshots/test_query_output.py/str/DuckDB/test_metric_alias__query_output.txt new file mode 100644 index 0000000000..3e8b3b6058 --- /dev/null +++ b/tests_metricflow/snapshots/test_query_output.py/str/DuckDB/test_metric_alias__query_output.txt @@ -0,0 +1,12 @@ +test_name: test_metric_alias +test_filename: test_query_output.py +--- +metric_time__day bookings_alias +------------------- ---------------- +2019-12-01T00:00:00 1 +2019-12-18T00:00:00 10 +2019-12-19T00:00:00 18 +2019-12-20T00:00:00 2 +2020-01-01T00:00:00 5 +2020-01-02T00:00:00 9 +2020-01-03T00:00:00 1 diff --git a/tests_metricflow/snapshots/test_query_output.py/str/DuckDB/test_multiple_metrics_with_alias__query_output.txt b/tests_metricflow/snapshots/test_query_output.py/str/DuckDB/test_multiple_metrics_with_alias__query_output.txt new file mode 100644 index 0000000000..e0a8b693a4 --- /dev/null +++ b/tests_metricflow/snapshots/test_query_output.py/str/DuckDB/test_multiple_metrics_with_alias__query_output.txt @@ -0,0 +1,12 @@ +test_name: test_multiple_metrics_with_alias +test_filename: test_query_output.py +--- +metric_time__day bookings_alias bookings_fees_alias +------------------- ---------------- --------------------- +2019-12-01T00:00:00 1 47.56 +2019-12-18T00:00:00 10 284.93 +2019-12-19T00:00:00 18 360.5 +2019-12-20T00:00:00 2 0 +2020-01-01T00:00:00 5 136.16 +2020-01-02T00:00:00 9 132.78 +2020-01-03T00:00:00 1 0 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlPlan/DuckDB/test_derived_metric_alias__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlPlan/DuckDB/test_derived_metric_alias__plan0.sql new file mode 100644 index 0000000000..0d07a9327b --- /dev/null +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlPlan/DuckDB/test_derived_metric_alias__plan0.sql @@ -0,0 +1,674 @@ +test_name: test_derived_metric_alias +test_filename: test_query_rendering.py +docstring: + Tests a plan with an aliased metric. +sql_engine: DuckDB +--- +-- Change Column Aliases +SELECT + subq_15.metric_time__day + , subq_15.booking_fees AS bookings_alias +FROM ( + -- Order By ['booking_fees'] + SELECT + subq_14.metric_time__day + , subq_14.booking_fees + FROM ( + -- Compute Metrics via Expressions + SELECT + subq_13.metric_time__day + , booking_value * 0.05 AS booking_fees + FROM ( + -- Compute Metrics via Expressions + SELECT + subq_12.metric_time__day + , subq_12.booking_value + FROM ( + -- Aggregate Measures + SELECT + subq_11.metric_time__day + , SUM(subq_11.booking_value) AS booking_value + FROM ( + -- Pass Only Elements: ['booking_value', 'metric_time__day'] + SELECT + subq_10.metric_time__day + , subq_10.booking_value + FROM ( + -- Constrain Output with WHERE + SELECT + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.metric_time__day + , subq_9.metric_time__week + , subq_9.metric_time__month + , subq_9.metric_time__quarter + , subq_9.metric_time__year + , subq_9.metric_time__extract_year + , subq_9.metric_time__extract_quarter + , subq_9.metric_time__extract_month + , subq_9.metric_time__extract_day + , subq_9.metric_time__extract_dow + , subq_9.metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.listing__booking_fees + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 + FROM ( + -- Join Standard Outputs + SELECT + subq_8.listing__booking_fees AS listing__booking_fees + , subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.ds_partitioned__day AS ds_partitioned__day + , subq_1.ds_partitioned__week AS ds_partitioned__week + , subq_1.ds_partitioned__month AS ds_partitioned__month + , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_1.ds_partitioned__year AS ds_partitioned__year + , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_1.paid_at__day AS paid_at__day + , subq_1.paid_at__week AS paid_at__week + , subq_1.paid_at__month AS paid_at__month + , subq_1.paid_at__quarter AS paid_at__quarter + , subq_1.paid_at__year AS paid_at__year + , subq_1.paid_at__extract_year AS paid_at__extract_year + , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_1.paid_at__extract_month AS paid_at__extract_month + , subq_1.paid_at__extract_day AS paid_at__extract_day + , subq_1.paid_at__extract_dow AS paid_at__extract_dow + , subq_1.paid_at__extract_doy AS paid_at__extract_doy + , subq_1.booking__ds__day AS booking__ds__day + , subq_1.booking__ds__week AS booking__ds__week + , subq_1.booking__ds__month AS booking__ds__month + , subq_1.booking__ds__quarter AS booking__ds__quarter + , subq_1.booking__ds__year AS booking__ds__year + , subq_1.booking__ds__extract_year AS booking__ds__extract_year + , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_1.booking__ds__extract_month AS booking__ds__extract_month + , subq_1.booking__ds__extract_day AS booking__ds__extract_day + , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day AS booking__paid_at__day + , subq_1.booking__paid_at__week AS booking__paid_at__week + , subq_1.booking__paid_at__month AS booking__paid_at__month + , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_1.booking__paid_at__year AS booking__paid_at__year + , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_1.metric_time__day AS metric_time__day + , subq_1.metric_time__week AS metric_time__week + , subq_1.metric_time__month AS metric_time__month + , subq_1.metric_time__quarter AS metric_time__quarter + , subq_1.metric_time__year AS metric_time__year + , subq_1.metric_time__extract_year AS metric_time__extract_year + , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_1.metric_time__extract_month AS metric_time__extract_month + , subq_1.metric_time__extract_day AS metric_time__extract_day + , subq_1.metric_time__extract_dow AS metric_time__extract_dow + , subq_1.metric_time__extract_doy AS metric_time__extract_doy + , subq_1.listing AS listing + , subq_1.guest AS guest + , subq_1.host AS host + , subq_1.booking__listing AS booking__listing + , subq_1.booking__guest AS booking__guest + , subq_1.booking__host AS booking__host + , subq_1.is_instant AS is_instant + , subq_1.booking__is_instant AS booking__is_instant + , subq_1.bookings AS bookings + , subq_1.instant_bookings AS instant_bookings + , subq_1.booking_value AS booking_value + , subq_1.max_booking_value AS max_booking_value + , subq_1.min_booking_value AS min_booking_value + , subq_1.bookers AS bookers + , subq_1.average_booking_value AS average_booking_value + , subq_1.referred_bookings AS referred_bookings + , subq_1.median_booking_value AS median_booking_value + , subq_1.booking_value_p99 AS booking_value_p99 + , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 + , 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 ( + -- Metric Time Dimension 'ds' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + SELECT + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__booking_fees'] + SELECT + subq_7.listing + , subq_7.listing__booking_fees + FROM ( + -- Compute Metrics via Expressions + SELECT + subq_6.listing + , booking_value * 0.05 AS listing__booking_fees + FROM ( + -- Compute Metrics via Expressions + SELECT + subq_5.listing + , subq_5.booking_value + FROM ( + -- Aggregate Measures + SELECT + subq_4.listing + , SUM(subq_4.booking_value) AS booking_value + FROM ( + -- Pass Only Elements: ['booking_value', 'listing'] + SELECT + subq_3.listing + , subq_3.booking_value + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + SELECT + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.listing + ) subq_5 + ) subq_6 + ) subq_7 + ) subq_8 + ON + subq_1.listing = subq_8.listing + ) subq_9 + WHERE listing__booking_fees > 2 + ) subq_10 + ) subq_11 + GROUP BY + subq_11.metric_time__day + ) subq_12 + ) subq_13 + ) subq_14 + ORDER BY subq_14.bookings_alias +) subq_15 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlPlan/DuckDB/test_derived_metric_alias__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlPlan/DuckDB/test_derived_metric_alias__plan0_optimized.sql new file mode 100644 index 0000000000..ef08bb3303 --- /dev/null +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlPlan/DuckDB/test_derived_metric_alias__plan0_optimized.sql @@ -0,0 +1,68 @@ +test_name: test_derived_metric_alias +test_filename: test_query_rendering.py +docstring: + Tests a plan with an aliased metric. +sql_engine: DuckDB +--- +-- Order By ['booking_fees'] +-- Change Column Aliases +WITH sma_28009_cte AS ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + , listing_id AS listing + , booking_value + FROM ***************************.fct_bookings bookings_source_src_28000 +) + +SELECT + metric_time__day AS metric_time__day + , booking_fees AS bookings_alias +FROM ( + -- Compute Metrics via Expressions + SELECT + metric_time__day + , booking_value * 0.05 AS booking_fees + FROM ( + -- Constrain Output with WHERE + -- Pass Only Elements: ['booking_value', 'metric_time__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + metric_time__day + , SUM(booking_value) AS booking_value + FROM ( + -- Join Standard Outputs + SELECT + subq_23.listing__booking_fees AS listing__booking_fees + , sma_28009_cte.metric_time__day AS metric_time__day + , sma_28009_cte.booking_value AS booking_value + FROM sma_28009_cte sma_28009_cte + LEFT OUTER JOIN ( + -- Compute Metrics via Expressions + -- Pass Only Elements: ['listing', 'listing__booking_fees'] + SELECT + listing + , booking_value * 0.05 AS listing__booking_fees + FROM ( + -- Read From CTE For node_id=sma_28009 + -- Pass Only Elements: ['booking_value', 'listing'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + listing + , SUM(booking_value) AS booking_value + FROM sma_28009_cte sma_28009_cte + GROUP BY + listing + ) subq_21 + ) subq_23 + ON + sma_28009_cte.listing = subq_23.listing + ) subq_24 + WHERE listing__booking_fees > 2 + GROUP BY + metric_time__day + ) subq_28 +) subq_29 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlPlan/DuckDB/test_metric_alias__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlPlan/DuckDB/test_metric_alias__plan0.sql new file mode 100644 index 0000000000..ccdd4eae12 --- /dev/null +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlPlan/DuckDB/test_metric_alias__plan0.sql @@ -0,0 +1,662 @@ +test_name: test_metric_alias +test_filename: test_query_rendering.py +docstring: + Tests a plan with an aliased metric. +sql_engine: DuckDB +--- +-- Change Column Aliases +SELECT + subq_13.metric_time__month + , subq_13.bookings AS bookings_alias +FROM ( + -- Order By ['bookings'] + SELECT + subq_12.metric_time__month + , subq_12.bookings + FROM ( + -- Compute Metrics via Expressions + SELECT + subq_11.metric_time__month + , subq_11.bookings + FROM ( + -- Aggregate Measures + SELECT + subq_10.metric_time__month + , SUM(subq_10.bookings) AS bookings + FROM ( + -- Pass Only Elements: ['bookings', 'metric_time__month'] + SELECT + subq_9.metric_time__month + , subq_9.bookings + FROM ( + -- Constrain Output with WHERE + SELECT + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.paid_at__day + , subq_8.paid_at__week + , subq_8.paid_at__month + , subq_8.paid_at__quarter + , subq_8.paid_at__year + , subq_8.paid_at__extract_year + , subq_8.paid_at__extract_quarter + , subq_8.paid_at__extract_month + , subq_8.paid_at__extract_day + , subq_8.paid_at__extract_dow + , subq_8.paid_at__extract_doy + , subq_8.booking__ds__day + , subq_8.booking__ds__week + , subq_8.booking__ds__month + , subq_8.booking__ds__quarter + , subq_8.booking__ds__year + , subq_8.booking__ds__extract_year + , subq_8.booking__ds__extract_quarter + , subq_8.booking__ds__extract_month + , subq_8.booking__ds__extract_day + , subq_8.booking__ds__extract_dow + , subq_8.booking__ds__extract_doy + , subq_8.booking__ds_partitioned__day + , subq_8.booking__ds_partitioned__week + , subq_8.booking__ds_partitioned__month + , subq_8.booking__ds_partitioned__quarter + , subq_8.booking__ds_partitioned__year + , subq_8.booking__ds_partitioned__extract_year + , subq_8.booking__ds_partitioned__extract_quarter + , subq_8.booking__ds_partitioned__extract_month + , subq_8.booking__ds_partitioned__extract_day + , subq_8.booking__ds_partitioned__extract_dow + , subq_8.booking__ds_partitioned__extract_doy + , subq_8.booking__paid_at__day + , subq_8.booking__paid_at__week + , subq_8.booking__paid_at__month + , subq_8.booking__paid_at__quarter + , subq_8.booking__paid_at__year + , subq_8.booking__paid_at__extract_year + , subq_8.booking__paid_at__extract_quarter + , subq_8.booking__paid_at__extract_month + , subq_8.booking__paid_at__extract_day + , subq_8.booking__paid_at__extract_dow + , subq_8.booking__paid_at__extract_doy + , subq_8.metric_time__day + , subq_8.metric_time__week + , subq_8.metric_time__month + , subq_8.metric_time__quarter + , subq_8.metric_time__year + , subq_8.metric_time__extract_year + , subq_8.metric_time__extract_quarter + , subq_8.metric_time__extract_month + , subq_8.metric_time__extract_day + , subq_8.metric_time__extract_dow + , subq_8.metric_time__extract_doy + , subq_8.listing + , subq_8.guest + , subq_8.host + , subq_8.booking__listing + , subq_8.booking__guest + , subq_8.booking__host + , subq_8.is_instant + , subq_8.booking__is_instant + , subq_8.listing__bookings + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 + FROM ( + -- Join Standard Outputs + SELECT + subq_7.listing__bookings AS listing__bookings + , subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.ds_partitioned__day AS ds_partitioned__day + , subq_1.ds_partitioned__week AS ds_partitioned__week + , subq_1.ds_partitioned__month AS ds_partitioned__month + , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_1.ds_partitioned__year AS ds_partitioned__year + , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_1.paid_at__day AS paid_at__day + , subq_1.paid_at__week AS paid_at__week + , subq_1.paid_at__month AS paid_at__month + , subq_1.paid_at__quarter AS paid_at__quarter + , subq_1.paid_at__year AS paid_at__year + , subq_1.paid_at__extract_year AS paid_at__extract_year + , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_1.paid_at__extract_month AS paid_at__extract_month + , subq_1.paid_at__extract_day AS paid_at__extract_day + , subq_1.paid_at__extract_dow AS paid_at__extract_dow + , subq_1.paid_at__extract_doy AS paid_at__extract_doy + , subq_1.booking__ds__day AS booking__ds__day + , subq_1.booking__ds__week AS booking__ds__week + , subq_1.booking__ds__month AS booking__ds__month + , subq_1.booking__ds__quarter AS booking__ds__quarter + , subq_1.booking__ds__year AS booking__ds__year + , subq_1.booking__ds__extract_year AS booking__ds__extract_year + , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_1.booking__ds__extract_month AS booking__ds__extract_month + , subq_1.booking__ds__extract_day AS booking__ds__extract_day + , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day AS booking__paid_at__day + , subq_1.booking__paid_at__week AS booking__paid_at__week + , subq_1.booking__paid_at__month AS booking__paid_at__month + , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_1.booking__paid_at__year AS booking__paid_at__year + , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_1.metric_time__day AS metric_time__day + , subq_1.metric_time__week AS metric_time__week + , subq_1.metric_time__month AS metric_time__month + , subq_1.metric_time__quarter AS metric_time__quarter + , subq_1.metric_time__year AS metric_time__year + , subq_1.metric_time__extract_year AS metric_time__extract_year + , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_1.metric_time__extract_month AS metric_time__extract_month + , subq_1.metric_time__extract_day AS metric_time__extract_day + , subq_1.metric_time__extract_dow AS metric_time__extract_dow + , subq_1.metric_time__extract_doy AS metric_time__extract_doy + , subq_1.listing AS listing + , subq_1.guest AS guest + , subq_1.host AS host + , subq_1.booking__listing AS booking__listing + , subq_1.booking__guest AS booking__guest + , subq_1.booking__host AS booking__host + , subq_1.is_instant AS is_instant + , subq_1.booking__is_instant AS booking__is_instant + , subq_1.bookings AS bookings + , subq_1.instant_bookings AS instant_bookings + , subq_1.booking_value AS booking_value + , subq_1.max_booking_value AS max_booking_value + , subq_1.min_booking_value AS min_booking_value + , subq_1.bookers AS bookers + , subq_1.average_booking_value AS average_booking_value + , subq_1.referred_bookings AS referred_bookings + , subq_1.median_booking_value AS median_booking_value + , subq_1.booking_value_p99 AS booking_value_p99 + , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 + , 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 ( + -- Metric Time Dimension 'ds' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + SELECT + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__bookings'] + SELECT + subq_6.listing + , subq_6.listing__bookings + FROM ( + -- Compute Metrics via Expressions + SELECT + subq_5.listing + , subq_5.bookings AS listing__bookings + FROM ( + -- Aggregate Measures + SELECT + subq_4.listing + , SUM(subq_4.bookings) AS bookings + FROM ( + -- Pass Only Elements: ['bookings', 'listing'] + SELECT + subq_3.listing + , subq_3.bookings + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + SELECT + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.listing + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.listing = subq_7.listing + ) subq_8 + WHERE listing__bookings > 2 + ) subq_9 + ) subq_10 + GROUP BY + subq_10.metric_time__month + ) subq_11 + ) subq_12 + ORDER BY subq_12.bookings_alias +) subq_13 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlPlan/DuckDB/test_metric_alias__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlPlan/DuckDB/test_metric_alias__plan0_optimized.sql new file mode 100644 index 0000000000..4b9d9726f0 --- /dev/null +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlPlan/DuckDB/test_metric_alias__plan0_optimized.sql @@ -0,0 +1,63 @@ +test_name: test_metric_alias +test_filename: test_query_rendering.py +docstring: + Tests a plan with an aliased metric. +sql_engine: DuckDB +--- +-- Order By ['bookings'] +-- Change Column Aliases +WITH sma_28009_cte AS ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' + SELECT + DATE_TRUNC('month', ds) AS metric_time__month + , listing_id AS listing + , 1 AS bookings + FROM ***************************.fct_bookings bookings_source_src_28000 +) + +SELECT + metric_time__month AS metric_time__month + , bookings AS bookings_alias +FROM ( + -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'metric_time__month'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + metric_time__month + , SUM(bookings) AS bookings + FROM ( + -- Join Standard Outputs + SELECT + subq_20.listing__bookings AS listing__bookings + , subq_15.metric_time__month AS metric_time__month + , subq_15.bookings AS bookings + FROM ( + -- Read From CTE For node_id=sma_28009 + SELECT + metric_time__month + , listing + , bookings + FROM sma_28009_cte sma_28009_cte + ) subq_15 + LEFT OUTER JOIN ( + -- Read From CTE For node_id=sma_28009 + -- Pass Only Elements: ['bookings', 'listing'] + -- Aggregate Measures + -- Compute Metrics via Expressions + -- Pass Only Elements: ['listing', 'listing__bookings'] + SELECT + listing + , SUM(bookings) AS listing__bookings + FROM sma_28009_cte sma_28009_cte + GROUP BY + listing + ) subq_20 + ON + subq_15.listing = subq_20.listing + ) subq_21 + WHERE listing__bookings > 2 + GROUP BY + metric_time__month +) subq_25 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/BigQuery/test_join_to_time_spine_with_input_measure_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/BigQuery/test_join_to_time_spine_with_input_measure_constraint__plan0.sql index 1df5f45cc6..fd297867dc 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/BigQuery/test_join_to_time_spine_with_input_measure_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/BigQuery/test_join_to_time_spine_with_input_measure_constraint__plan0.sql @@ -24,7 +24,8 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__week + subq_6.metric_time__day + , subq_6.ds__week , subq_6.ds__month , subq_6.ds__quarter , subq_6.ds__year @@ -35,7 +36,6 @@ FROM ( , subq_6.ds__extract_dow , subq_6.ds__extract_doy , subq_6.ds__martian_day - , subq_6.metric_time__day FROM ( -- Change Column Aliases SELECT diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/BigQuery/test_join_to_time_spine_with_queried_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/BigQuery/test_join_to_time_spine_with_queried_time_constraint__plan0.sql index 6a875e67f6..3c3020b5f9 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/BigQuery/test_join_to_time_spine_with_queried_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/BigQuery/test_join_to_time_spine_with_queried_time_constraint__plan0.sql @@ -25,7 +25,8 @@ FROM ( FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_6.ds__week + subq_6.metric_time__day + , subq_6.ds__week , subq_6.ds__month , subq_6.ds__quarter , subq_6.ds__year @@ -36,7 +37,6 @@ FROM ( , subq_6.ds__extract_dow , subq_6.ds__extract_doy , subq_6.ds__martian_day - , subq_6.metric_time__day FROM ( -- Change Column Aliases SELECT diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Databricks/test_join_to_time_spine_with_input_measure_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Databricks/test_join_to_time_spine_with_input_measure_constraint__plan0.sql index 114757a39f..e65a6a29ef 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Databricks/test_join_to_time_spine_with_input_measure_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Databricks/test_join_to_time_spine_with_input_measure_constraint__plan0.sql @@ -24,7 +24,8 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__week + subq_6.metric_time__day + , subq_6.ds__week , subq_6.ds__month , subq_6.ds__quarter , subq_6.ds__year @@ -35,7 +36,6 @@ FROM ( , subq_6.ds__extract_dow , subq_6.ds__extract_doy , subq_6.ds__martian_day - , subq_6.metric_time__day FROM ( -- Change Column Aliases SELECT diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Databricks/test_join_to_time_spine_with_queried_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Databricks/test_join_to_time_spine_with_queried_time_constraint__plan0.sql index 8a75fa0e60..d9315b72c6 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Databricks/test_join_to_time_spine_with_queried_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Databricks/test_join_to_time_spine_with_queried_time_constraint__plan0.sql @@ -25,7 +25,8 @@ FROM ( FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_6.ds__week + subq_6.metric_time__day + , subq_6.ds__week , subq_6.ds__month , subq_6.ds__quarter , subq_6.ds__year @@ -36,7 +37,6 @@ FROM ( , subq_6.ds__extract_dow , subq_6.ds__extract_doy , subq_6.ds__martian_day - , subq_6.metric_time__day FROM ( -- Change Column Aliases SELECT diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/DuckDB/test_join_to_time_spine_with_input_measure_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/DuckDB/test_join_to_time_spine_with_input_measure_constraint__plan0.sql index 35c4688bc3..f29c887bdc 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/DuckDB/test_join_to_time_spine_with_input_measure_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/DuckDB/test_join_to_time_spine_with_input_measure_constraint__plan0.sql @@ -24,7 +24,8 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__week + subq_6.metric_time__day + , subq_6.ds__week , subq_6.ds__month , subq_6.ds__quarter , subq_6.ds__year @@ -35,7 +36,6 @@ FROM ( , subq_6.ds__extract_dow , subq_6.ds__extract_doy , subq_6.ds__martian_day - , subq_6.metric_time__day FROM ( -- Change Column Aliases SELECT diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/DuckDB/test_join_to_time_spine_with_queried_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/DuckDB/test_join_to_time_spine_with_queried_time_constraint__plan0.sql index 29b5b38422..aafef7d451 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/DuckDB/test_join_to_time_spine_with_queried_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/DuckDB/test_join_to_time_spine_with_queried_time_constraint__plan0.sql @@ -25,7 +25,8 @@ FROM ( FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_6.ds__week + subq_6.metric_time__day + , subq_6.ds__week , subq_6.ds__month , subq_6.ds__quarter , subq_6.ds__year @@ -36,7 +37,6 @@ FROM ( , subq_6.ds__extract_dow , subq_6.ds__extract_doy , subq_6.ds__martian_day - , subq_6.metric_time__day FROM ( -- Change Column Aliases SELECT diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Postgres/test_join_to_time_spine_with_input_measure_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Postgres/test_join_to_time_spine_with_input_measure_constraint__plan0.sql index 920de60edb..62e01364f5 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Postgres/test_join_to_time_spine_with_input_measure_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Postgres/test_join_to_time_spine_with_input_measure_constraint__plan0.sql @@ -24,7 +24,8 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__week + subq_6.metric_time__day + , subq_6.ds__week , subq_6.ds__month , subq_6.ds__quarter , subq_6.ds__year @@ -35,7 +36,6 @@ FROM ( , subq_6.ds__extract_dow , subq_6.ds__extract_doy , subq_6.ds__martian_day - , subq_6.metric_time__day FROM ( -- Change Column Aliases SELECT diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Postgres/test_join_to_time_spine_with_queried_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Postgres/test_join_to_time_spine_with_queried_time_constraint__plan0.sql index c54ea7faa8..6c442f9200 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Postgres/test_join_to_time_spine_with_queried_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Postgres/test_join_to_time_spine_with_queried_time_constraint__plan0.sql @@ -25,7 +25,8 @@ FROM ( FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_6.ds__week + subq_6.metric_time__day + , subq_6.ds__week , subq_6.ds__month , subq_6.ds__quarter , subq_6.ds__year @@ -36,7 +37,6 @@ FROM ( , subq_6.ds__extract_dow , subq_6.ds__extract_doy , subq_6.ds__martian_day - , subq_6.metric_time__day FROM ( -- Change Column Aliases SELECT diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Redshift/test_join_to_time_spine_with_input_measure_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Redshift/test_join_to_time_spine_with_input_measure_constraint__plan0.sql index 4cc8afbcc6..c9da5aaf9a 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Redshift/test_join_to_time_spine_with_input_measure_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Redshift/test_join_to_time_spine_with_input_measure_constraint__plan0.sql @@ -24,7 +24,8 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__week + subq_6.metric_time__day + , subq_6.ds__week , subq_6.ds__month , subq_6.ds__quarter , subq_6.ds__year @@ -35,7 +36,6 @@ FROM ( , subq_6.ds__extract_dow , subq_6.ds__extract_doy , subq_6.ds__martian_day - , subq_6.metric_time__day FROM ( -- Change Column Aliases SELECT diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Redshift/test_join_to_time_spine_with_queried_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Redshift/test_join_to_time_spine_with_queried_time_constraint__plan0.sql index ea63630656..2c1fe1db14 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Redshift/test_join_to_time_spine_with_queried_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Redshift/test_join_to_time_spine_with_queried_time_constraint__plan0.sql @@ -25,7 +25,8 @@ FROM ( FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_6.ds__week + subq_6.metric_time__day + , subq_6.ds__week , subq_6.ds__month , subq_6.ds__quarter , subq_6.ds__year @@ -36,7 +37,6 @@ FROM ( , subq_6.ds__extract_dow , subq_6.ds__extract_doy , subq_6.ds__martian_day - , subq_6.metric_time__day FROM ( -- Change Column Aliases SELECT diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Snowflake/test_join_to_time_spine_with_input_measure_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Snowflake/test_join_to_time_spine_with_input_measure_constraint__plan0.sql index 7d5fda79f5..21054fd461 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Snowflake/test_join_to_time_spine_with_input_measure_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Snowflake/test_join_to_time_spine_with_input_measure_constraint__plan0.sql @@ -24,7 +24,8 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__week + subq_6.metric_time__day + , subq_6.ds__week , subq_6.ds__month , subq_6.ds__quarter , subq_6.ds__year @@ -35,7 +36,6 @@ FROM ( , subq_6.ds__extract_dow , subq_6.ds__extract_doy , subq_6.ds__martian_day - , subq_6.metric_time__day FROM ( -- Change Column Aliases SELECT diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Snowflake/test_join_to_time_spine_with_queried_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Snowflake/test_join_to_time_spine_with_queried_time_constraint__plan0.sql index e193fcfa02..3e137fb0b4 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Snowflake/test_join_to_time_spine_with_queried_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Snowflake/test_join_to_time_spine_with_queried_time_constraint__plan0.sql @@ -25,7 +25,8 @@ FROM ( FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_6.ds__week + subq_6.metric_time__day + , subq_6.ds__week , subq_6.ds__month , subq_6.ds__quarter , subq_6.ds__year @@ -36,7 +37,6 @@ FROM ( , subq_6.ds__extract_dow , subq_6.ds__extract_doy , subq_6.ds__martian_day - , subq_6.metric_time__day FROM ( -- Change Column Aliases SELECT diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Trino/test_join_to_time_spine_with_input_measure_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Trino/test_join_to_time_spine_with_input_measure_constraint__plan0.sql index ddd426a606..5671fb98b4 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Trino/test_join_to_time_spine_with_input_measure_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Trino/test_join_to_time_spine_with_input_measure_constraint__plan0.sql @@ -24,7 +24,8 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__week + subq_6.metric_time__day + , subq_6.ds__week , subq_6.ds__month , subq_6.ds__quarter , subq_6.ds__year @@ -35,7 +36,6 @@ FROM ( , subq_6.ds__extract_dow , subq_6.ds__extract_doy , subq_6.ds__martian_day - , subq_6.metric_time__day FROM ( -- Change Column Aliases SELECT diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Trino/test_join_to_time_spine_with_queried_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Trino/test_join_to_time_spine_with_queried_time_constraint__plan0.sql index 01c381f014..20bc625243 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Trino/test_join_to_time_spine_with_queried_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlPlan/Trino/test_join_to_time_spine_with_queried_time_constraint__plan0.sql @@ -25,7 +25,8 @@ FROM ( FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_6.ds__week + subq_6.metric_time__day + , subq_6.ds__week , subq_6.ds__month , subq_6.ds__quarter , subq_6.ds__year @@ -36,7 +37,6 @@ FROM ( , subq_6.ds__extract_dow , subq_6.ds__extract_doy , subq_6.ds__martian_day - , subq_6.metric_time__day FROM ( -- Change Column Aliases SELECT