From ba8e91a4b349c8a7bb8609d96402a0669af39661 Mon Sep 17 00:00:00 2001 From: Will Deng Date: Wed, 8 Nov 2023 14:22:14 -0500 Subject: [PATCH 01/14] Added AddGeneratedUuidColumnNode --- metricflow/dag/id_generation.py | 1 + metricflow/dataflow/dataflow_plan.py | 39 +++++++++++++++ .../source_scan/cm_branch_combiner.py | 7 +++ .../source_scan/source_scan_optimizer.py | 5 ++ metricflow/plan_conversion/dataflow_to_sql.py | 48 +++++++++++++++++++ .../plan_conversion/instance_converters.py | 17 +++++++ .../source_scan/test_source_scan_optimizer.py | 4 ++ 7 files changed, 121 insertions(+) diff --git a/metricflow/dag/id_generation.py b/metricflow/dag/id_generation.py index b5d4b38f89..1f7a00c8b7 100644 --- a/metricflow/dag/id_generation.py +++ b/metricflow/dag/id_generation.py @@ -23,6 +23,7 @@ DATAFLOW_NODE_SET_MEASURE_AGGREGATION_TIME = "sma" DATAFLOW_NODE_SEMI_ADDITIVE_JOIN_ID_PREFIX = "saj" DATAFLOW_NODE_JOIN_TO_TIME_SPINE_ID_PREFIX = "jts" +DATAFLOW_NODE_ADD_UUID_COLUMN_PREFIX = "auid" SQL_EXPR_COLUMN_REFERENCE_ID_PREFIX = "cr" SQL_EXPR_COMPARISON_ID_PREFIX = "cmp" diff --git a/metricflow/dataflow/dataflow_plan.py b/metricflow/dataflow/dataflow_plan.py index 1a04ed254d..78d3d4ef68 100644 --- a/metricflow/dataflow/dataflow_plan.py +++ b/metricflow/dataflow/dataflow_plan.py @@ -16,6 +16,7 @@ from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity from metricflow.dag.id_generation import ( + DATAFLOW_NODE_ADD_UUID_COLUMN_PREFIX, DATAFLOW_NODE_AGGREGATE_MEASURES_ID_PREFIX, DATAFLOW_NODE_COMBINE_AGGREGATED_OUTPUTS_ID_PREFIX, DATAFLOW_NODE_COMPUTE_METRICS_ID_PREFIX, @@ -175,6 +176,10 @@ def visit_metric_time_dimension_transform_node( # noqa: D def visit_join_to_time_spine_node(self, node: JoinToTimeSpineNode) -> VisitorOutputT: # noqa: D pass + @abstractmethod + def visit_add_generated_uuid_column_node(self, node: AddGeneratedUuidColumnNode) -> VisitorOutputT: # noqa: D + pass + class BaseOutput(DataflowPlanNode, ABC): """A node that outputs data in a "base" format. @@ -1248,6 +1253,40 @@ def with_new_parents(self, new_parent_nodes: Sequence[BaseOutput]) -> ConstrainT ) +class AddGeneratedUuidColumnNode(BaseOutput): + """Adds a UUID column.""" + + def __init__(self, parent_node: BaseOutput) -> None: # noqa: D + super().__init__(node_id=self.create_unique_id(), parent_nodes=[parent_node]) + + @classmethod + def id_prefix(cls) -> str: # noqa: D + return DATAFLOW_NODE_ADD_UUID_COLUMN_PREFIX + + def accept(self, visitor: DataflowPlanNodeVisitor[VisitorOutputT]) -> VisitorOutputT: # noqa: D + return visitor.visit_add_generated_uuid_column_node(self) + + @property + def description(self) -> str: # noqa: D + return "Adds an internally generated UUID column" + + @property + def parent_node(self) -> DataflowPlanNode: # noqa: D + assert len(self.parent_nodes) == 1 + return self.parent_nodes[0] + + @property + def displayed_properties(self) -> List[DisplayedProperty]: # noqa: D + return super().displayed_properties + + def functionally_identical(self, other_node: DataflowPlanNode) -> bool: # noqa: D + return isinstance(other_node, self.__class__) + + def with_new_parents(self, new_parent_nodes: Sequence[BaseOutput]) -> AddGeneratedUuidColumnNode: # noqa: D + assert len(new_parent_nodes) == 1 + return AddGeneratedUuidColumnNode(parent_node=new_parent_nodes[0]) + + class DataflowPlan(MetricFlowDag[SinkOutput]): """Describes the flow of metric data as it goes from source nodes to sink nodes in the graph.""" diff --git a/metricflow/dataflow/optimizer/source_scan/cm_branch_combiner.py b/metricflow/dataflow/optimizer/source_scan/cm_branch_combiner.py index 535221f826..d4986bc1dc 100644 --- a/metricflow/dataflow/optimizer/source_scan/cm_branch_combiner.py +++ b/metricflow/dataflow/optimizer/source_scan/cm_branch_combiner.py @@ -5,6 +5,7 @@ from typing import List, Optional, Sequence from metricflow.dataflow.dataflow_plan import ( + AddGeneratedUuidColumnNode, AggregateMeasuresNode, BaseOutput, CombineAggregatedOutputsNode, @@ -401,3 +402,9 @@ def visit_metric_time_dimension_transform_node( # noqa: D def visit_join_to_time_spine_node(self, node: JoinToTimeSpineNode) -> ComputeMetricsBranchCombinerResult: # noqa: D self._log_visit_node_type(node) return self._default_handler(node) + + def visit_add_generated_uuid_column_node( # noqa: D + self, node: AddGeneratedUuidColumnNode + ) -> ComputeMetricsBranchCombinerResult: + self._log_visit_node_type(node) + return self._default_handler(node) diff --git a/metricflow/dataflow/optimizer/source_scan/source_scan_optimizer.py b/metricflow/dataflow/optimizer/source_scan/source_scan_optimizer.py index 7a5f2c39fe..b703b79e64 100644 --- a/metricflow/dataflow/optimizer/source_scan/source_scan_optimizer.py +++ b/metricflow/dataflow/optimizer/source_scan/source_scan_optimizer.py @@ -6,6 +6,7 @@ from metricflow.dag.id_generation import OPTIMIZED_DATAFLOW_PLAN_PREFIX, IdGeneratorRegistry from metricflow.dataflow.dataflow_plan import ( + AddGeneratedUuidColumnNode, AggregateMeasuresNode, BaseOutput, CombineAggregatedOutputsNode, @@ -331,3 +332,7 @@ def optimize(self, dataflow_plan: DataflowPlan) -> DataflowPlan: # noqa: D def visit_join_to_time_spine_node(self, node: JoinToTimeSpineNode) -> OptimizeBranchResult: # noqa: D self._log_visit_node_type(node) return self._default_base_output_handler(node) + + def visit_add_generated_uuid_column_node(self, node: AddGeneratedUuidColumnNode) -> OptimizeBranchResult: # noqa: D + self._log_visit_node_type(node) + return self._default_base_output_handler(node) diff --git a/metricflow/plan_conversion/dataflow_to_sql.py b/metricflow/plan_conversion/dataflow_to_sql.py index 8fcb273649..cc0e4a31d2 100644 --- a/metricflow/plan_conversion/dataflow_to_sql.py +++ b/metricflow/plan_conversion/dataflow_to_sql.py @@ -7,10 +7,12 @@ from dbt_semantic_interfaces.enum_extension import assert_values_exhausted from dbt_semantic_interfaces.protocols.metric import MetricInputMeasure, MetricType from dbt_semantic_interfaces.references import MetricModelReference +from dbt_semantic_interfaces.validations.unique_valid_name import MetricFlowReservedKeywords from metricflow.aggregation_properties import AggregationState from metricflow.dag.id_generation import IdGeneratorRegistry from metricflow.dataflow.dataflow_plan import ( + AddGeneratedUuidColumnNode, AggregateMeasuresNode, BaseOutput, CombineAggregatedOutputsNode, @@ -35,12 +37,14 @@ from metricflow.filters.time_constraint import TimeRangeConstraint from metricflow.instances import ( InstanceSet, + MetadataInstance, MetricInstance, TimeDimensionInstance, ) from metricflow.model.semantic_manifest_lookup import SemanticManifestLookup from metricflow.plan_conversion.instance_converters import ( AddLinkToLinkableElements, + AddMetadata, AddMetrics, AliasAggregatedMeasures, ChangeAssociatedColumns, @@ -73,6 +77,7 @@ from metricflow.specs.column_assoc import ColumnAssociation, ColumnAssociationResolver, SingleColumnCorrelationKey from metricflow.specs.specs import ( MeasureSpec, + MetadataSpec, MetricSpec, TimeDimensionSpec, ) @@ -92,6 +97,7 @@ SqlExtractExpression, SqlFunction, SqlFunctionExpression, + SqlGenerateUuidExpression, SqlLogicalExpression, SqlLogicalOperator, SqlRatioComputationExpression, @@ -1319,3 +1325,45 @@ def visit_join_to_time_spine_node(self, node: JoinToTimeSpineNode) -> SqlDataSet where=where, ), ) + + def visit_add_generated_uuid_column_node(self, node: AddGeneratedUuidColumnNode) -> SqlDataSet: + """Implements the behaviour of AddGeneratedUuidColumnNode. + + Builds a new dataset that is the same as the output dataset, but with an additional column + that contains a randomly generated UUID. + """ + input_data_set: SqlDataSet = node.parent_node.accept(self) + input_data_set_alias = self._next_unique_table_alias() + + gen_uuid_spec = MetadataSpec.from_name(MetricFlowReservedKeywords.MF_INTERNAL_UUID.value) + output_column_association = self._column_association_resolver.resolve_spec(gen_uuid_spec) + output_instance_set = input_data_set.instance_set.transform( + AddMetadata( + ( + MetadataInstance( + associated_columns=(output_column_association,), + spec=gen_uuid_spec, + ), + ) + ) + ) + gen_uuid_sql_select_column = SqlSelectColumn( + expr=SqlGenerateUuidExpression(), column_alias=output_column_association.column_name + ) + + return SqlDataSet( + instance_set=output_instance_set, + sql_select_node=SqlSelectStatementNode( + description="Add column with generated UUID", + select_columns=input_data_set.instance_set.transform( + CreateSelectColumnsForInstances(input_data_set_alias, self._column_association_resolver) + ).as_tuple() + + (gen_uuid_sql_select_column,), + from_source=input_data_set.sql_select_node, + from_source_alias=input_data_set_alias, + joins_descs=(), + group_bys=(), + where=None, + order_bys=(), + ), + ) diff --git a/metricflow/plan_conversion/instance_converters.py b/metricflow/plan_conversion/instance_converters.py index d56e1e8473..e95da2e836 100644 --- a/metricflow/plan_conversion/instance_converters.py +++ b/metricflow/plan_conversion/instance_converters.py @@ -970,3 +970,20 @@ def create_select_columns_for_instance_sets( ) return column_set.as_tuple() + + +class AddMetadata(InstanceSetTransform[InstanceSet]): + """Adds the given metric instances to the instance set.""" + + def __init__(self, metadata_instances: Sequence[MetadataInstance]) -> None: # noqa: D + self._metadata_instances = metadata_instances + + def transform(self, instance_set: InstanceSet) -> InstanceSet: # noqa: D + return InstanceSet( + measure_instances=instance_set.measure_instances, + dimension_instances=instance_set.dimension_instances, + time_dimension_instances=instance_set.time_dimension_instances, + entity_instances=instance_set.entity_instances, + metric_instances=instance_set.metric_instances, + metadata_instances=instance_set.metadata_instances + tuple(self._metadata_instances), + ) diff --git a/metricflow/test/dataflow/optimizer/source_scan/test_source_scan_optimizer.py b/metricflow/test/dataflow/optimizer/source_scan/test_source_scan_optimizer.py index c48e332b91..46e400c229 100644 --- a/metricflow/test/dataflow/optimizer/source_scan/test_source_scan_optimizer.py +++ b/metricflow/test/dataflow/optimizer/source_scan/test_source_scan_optimizer.py @@ -9,6 +9,7 @@ from metricflow.dataflow.builder.dataflow_plan_builder import DataflowPlanBuilder from metricflow.dataflow.dataflow_plan import ( + AddGeneratedUuidColumnNode, AggregateMeasuresNode, CombineAggregatedOutputsNode, ComputeMetricsNode, @@ -97,6 +98,9 @@ def visit_metric_time_dimension_transform_node(self, node: MetricTimeDimensionTr def visit_join_to_time_spine_node(self, node: JoinToTimeSpineNode) -> int: # noqa: D return self._sum_parents(node) + def visit_add_generated_uuid_column_node(self, node: AddGeneratedUuidColumnNode) -> int: # noqa :D + return self._sum_parents(node) + def count_source_nodes(self, dataflow_plan: DataflowPlan) -> int: # noqa: D return dataflow_plan.sink_output_node.accept(self) From 0f9dad4beed35389bd4ac6881d1b8664cebe5197 Mon Sep 17 00:00:00 2001 From: Will Deng Date: Wed, 8 Nov 2023 15:58:00 -0500 Subject: [PATCH 02/14] add JoinConversionEventsNode --- metricflow/dag/id_generation.py | 1 + metricflow/dataflow/dataflow_plan.py | 129 +++++++++++++++ .../source_scan/cm_branch_combiner.py | 7 + .../source_scan/source_scan_optimizer.py | 5 + metricflow/plan_conversion/dataflow_to_sql.py | 149 ++++++++++++++++++ .../plan_conversion/sql_join_builder.py | 115 ++++++++++---- .../source_scan/test_source_scan_optimizer.py | 4 + 7 files changed, 381 insertions(+), 29 deletions(-) diff --git a/metricflow/dag/id_generation.py b/metricflow/dag/id_generation.py index 1f7a00c8b7..4b3eeec1bf 100644 --- a/metricflow/dag/id_generation.py +++ b/metricflow/dag/id_generation.py @@ -24,6 +24,7 @@ DATAFLOW_NODE_SEMI_ADDITIVE_JOIN_ID_PREFIX = "saj" DATAFLOW_NODE_JOIN_TO_TIME_SPINE_ID_PREFIX = "jts" DATAFLOW_NODE_ADD_UUID_COLUMN_PREFIX = "auid" +DATAFLOW_NODE_JOIN_CONVERSION_EVENTS_PREFIX = "jce" SQL_EXPR_COLUMN_REFERENCE_ID_PREFIX = "cr" SQL_EXPR_COMPARISON_ID_PREFIX = "cmp" diff --git a/metricflow/dataflow/dataflow_plan.py b/metricflow/dataflow/dataflow_plan.py index 78d3d4ef68..960672f2fb 100644 --- a/metricflow/dataflow/dataflow_plan.py +++ b/metricflow/dataflow/dataflow_plan.py @@ -21,6 +21,7 @@ DATAFLOW_NODE_COMBINE_AGGREGATED_OUTPUTS_ID_PREFIX, DATAFLOW_NODE_COMPUTE_METRICS_ID_PREFIX, DATAFLOW_NODE_CONSTRAIN_TIME_RANGE_ID_PREFIX, + DATAFLOW_NODE_JOIN_CONVERSION_EVENTS_PREFIX, DATAFLOW_NODE_JOIN_SELF_OVER_TIME_RANGE_ID_PREFIX, DATAFLOW_NODE_JOIN_TO_STANDARD_OUTPUT_ID_PREFIX, DATAFLOW_NODE_JOIN_TO_TIME_SPINE_ID_PREFIX, @@ -41,8 +42,11 @@ from metricflow.dataset.sql_dataset import SqlDataSet from metricflow.filters.time_constraint import TimeRangeConstraint from metricflow.specs.specs import ( + EntitySpec, + InstanceSpec, InstanceSpecSet, LinklessEntitySpec, + MeasureSpec, MetricInputMeasureSpec, MetricSpec, OrderBySpec, @@ -180,6 +184,10 @@ def visit_join_to_time_spine_node(self, node: JoinToTimeSpineNode) -> VisitorOut def visit_add_generated_uuid_column_node(self, node: AddGeneratedUuidColumnNode) -> VisitorOutputT: # noqa: D pass + @abstractmethod + def visit_join_conversion_events_node(self, node: JoinConversionEventsNode) -> VisitorOutputT: # noqa: D + pass + class BaseOutput(DataflowPlanNode, ABC): """A node that outputs data in a "base" format. @@ -1287,6 +1295,127 @@ def with_new_parents(self, new_parent_nodes: Sequence[BaseOutput]) -> AddGenerat return AddGeneratedUuidColumnNode(parent_node=new_parent_nodes[0]) +class JoinConversionEventsNode(BaseOutput): + """Builds a data set containing successful conversion events.""" + + def __init__( + self, + base_node: BaseOutput, + base_time_dimension_spec: TimeDimensionSpec, + conversion_node: BaseOutput, + conversion_measure_spec: MeasureSpec, + conversion_time_dimension_spec: TimeDimensionSpec, + unique_identifier_keys: Sequence[InstanceSpec], + entity_spec: EntitySpec, + window: Optional[MetricTimeWindow] = None, + ) -> None: + """Constructor. + + Args: + base_node: node containing dataset for computing base events. + base_time_dimension_spec: time dimension for the base events to compute against. + conversion_node: node containing dataset to join base node for computing conversion events. + conversion_measure_spec: expose this measure in the resulting dataset for aggregation. + conversion_time_dimension_spec: time dimension for the conversion events to compute against. + unique_identifier_keys: columns to uniquely identify each conversion event. + entity_spec: the specific entity in which the conversion is happening for. + window: time range bound for when a conversion is still considered valid (default: INF). + """ + self._base_node = base_node + self._conversion_node = conversion_node + self._base_time_dimension_spec = base_time_dimension_spec + self._conversion_measure_spec = conversion_measure_spec + self._conversion_time_dimension_spec = conversion_time_dimension_spec + self._unique_identifier_keys = unique_identifier_keys + self._entity_spec = entity_spec + self._window = window + super().__init__(node_id=self.create_unique_id(), parent_nodes=[base_node, conversion_node]) + + @classmethod + def id_prefix(cls) -> str: # noqa: D + return DATAFLOW_NODE_JOIN_CONVERSION_EVENTS_PREFIX + + def accept(self, visitor: DataflowPlanNodeVisitor[VisitorOutputT]) -> VisitorOutputT: # noqa: D + return visitor.visit_join_conversion_events_node(self) + + @property + def base_node(self) -> DataflowPlanNode: # noqa: D + return self._base_node + + @property + def conversion_node(self) -> DataflowPlanNode: # noqa: D + return self._conversion_node + + @property + def conversion_measure_spec(self) -> MeasureSpec: # noqa: D + return self._conversion_measure_spec + + @property + def base_time_dimension_spec(self) -> TimeDimensionSpec: # noqa: D + return self._base_time_dimension_spec + + @property + def conversion_time_dimension_spec(self) -> TimeDimensionSpec: # noqa: D + return self._conversion_time_dimension_spec + + @property + def unique_identifier_keys(self) -> Sequence[InstanceSpec]: # noqa: D + return self._unique_identifier_keys + + @property + def entity_spec(self) -> EntitySpec: # noqa: D + return self._entity_spec + + @property + def window(self) -> Optional[MetricTimeWindow]: # noqa: D + return self._window + + @property + def description(self) -> str: # noqa: D + return f"Find conversions for {self.entity_spec.qualified_name} within the range of {f'{self.window.count} {self.window.granularity.value}' if self.window else 'INF'}" + + @property + def displayed_properties(self) -> List[DisplayedProperty]: # noqa: D + return ( + super().displayed_properties + + [ + DisplayedProperty("base_time_dimension_spec", self.base_time_dimension_spec), + DisplayedProperty("conversion_time_dimension_spec", self.conversion_time_dimension_spec), + DisplayedProperty("entity_spec", self.entity_spec), + DisplayedProperty("window", self.window), + ] + + [DisplayedProperty("unique_key_specs", unique_spec) for unique_spec in self.unique_identifier_keys] + + [ + DisplayedProperty("constant_property", constant_property) + for constant_property in self.constant_properties or [] + ] + ) + + def functionally_identical(self, other_node: DataflowPlanNode) -> bool: # noqa: D + return ( + isinstance(other_node, self.__class__) + and other_node.base_time_dimension_spec == self.base_time_dimension_spec + and other_node.conversion_time_dimension_spec == self.conversion_time_dimension_spec + and other_node.conversion_measure_spec == self.conversion_measure_spec + and other_node.unique_identifier_keys == self.unique_identifier_keys + and other_node.entity_spec == self.entity_spec + and other_node.window == self.window + ) + + def with_new_parents(self, new_parent_nodes: Sequence[BaseOutput]) -> JoinConversionEventsNode: # noqa: D + assert len(new_parent_nodes) == 2 + return JoinConversionEventsNode( + base_node=new_parent_nodes[0], + base_time_dimension_spec=self.base_time_dimension_spec, + conversion_node=new_parent_nodes[1], + conversion_measure_spec=self.conversion_measure_spec, + conversion_time_dimension_spec=self.conversion_time_dimension_spec, + unique_identifier_keys=self.unique_identifier_keys, + entity_spec=self.entity_spec, + window=self.window, + ) + + class DataflowPlan(MetricFlowDag[SinkOutput]): """Describes the flow of metric data as it goes from source nodes to sink nodes in the graph.""" diff --git a/metricflow/dataflow/optimizer/source_scan/cm_branch_combiner.py b/metricflow/dataflow/optimizer/source_scan/cm_branch_combiner.py index d4986bc1dc..c2dd61edfa 100644 --- a/metricflow/dataflow/optimizer/source_scan/cm_branch_combiner.py +++ b/metricflow/dataflow/optimizer/source_scan/cm_branch_combiner.py @@ -14,6 +14,7 @@ DataflowPlanNode, DataflowPlanNodeVisitor, FilterElementsNode, + JoinConversionEventsNode, JoinOverTimeRangeNode, JoinToBaseOutputNode, JoinToTimeSpineNode, @@ -408,3 +409,9 @@ def visit_add_generated_uuid_column_node( # noqa: D ) -> ComputeMetricsBranchCombinerResult: self._log_visit_node_type(node) return self._default_handler(node) + + def visit_join_conversion_events_node( # noqa: D + self, node: JoinConversionEventsNode + ) -> ComputeMetricsBranchCombinerResult: + self._log_visit_node_type(node) + return self._default_handler(node) diff --git a/metricflow/dataflow/optimizer/source_scan/source_scan_optimizer.py b/metricflow/dataflow/optimizer/source_scan/source_scan_optimizer.py index b703b79e64..6233c7e3df 100644 --- a/metricflow/dataflow/optimizer/source_scan/source_scan_optimizer.py +++ b/metricflow/dataflow/optimizer/source_scan/source_scan_optimizer.py @@ -16,6 +16,7 @@ DataflowPlanNode, DataflowPlanNodeVisitor, FilterElementsNode, + JoinConversionEventsNode, JoinOverTimeRangeNode, JoinToBaseOutputNode, JoinToTimeSpineNode, @@ -336,3 +337,7 @@ def visit_join_to_time_spine_node(self, node: JoinToTimeSpineNode) -> OptimizeBr def visit_add_generated_uuid_column_node(self, node: AddGeneratedUuidColumnNode) -> OptimizeBranchResult: # noqa: D self._log_visit_node_type(node) return self._default_base_output_handler(node) + + def visit_join_conversion_events_node(self, node: JoinConversionEventsNode) -> OptimizeBranchResult: # noqa: D + self._log_visit_node_type(node) + return self._default_base_output_handler(node) diff --git a/metricflow/plan_conversion/dataflow_to_sql.py b/metricflow/plan_conversion/dataflow_to_sql.py index cc0e4a31d2..6c48d2c335 100644 --- a/metricflow/plan_conversion/dataflow_to_sql.py +++ b/metricflow/plan_conversion/dataflow_to_sql.py @@ -21,6 +21,7 @@ ConstrainTimeRangeNode, DataflowPlanNodeVisitor, FilterElementsNode, + JoinConversionEventsNode, JoinOverTimeRangeNode, JoinToBaseOutputNode, JoinToTimeSpineNode, @@ -52,6 +53,7 @@ CreateSelectColumnForCombineOutputNode, CreateSelectColumnsForInstances, CreateSelectColumnsWithMeasuresAggregated, + CreateSqlColumnReferencesForInstances, FilterElements, FilterLinkableInstancesWithLeadingLink, RemoveMeasures, @@ -76,6 +78,7 @@ from metricflow.protocols.sql_client import SqlEngine from metricflow.specs.column_assoc import ColumnAssociation, ColumnAssociationResolver, SingleColumnCorrelationKey from metricflow.specs.specs import ( + InstanceSpecSet, MeasureSpec, MetadataSpec, MetricSpec, @@ -103,6 +106,9 @@ SqlRatioComputationExpression, SqlStringExpression, SqlStringLiteralExpression, + SqlWindowFunction, + SqlWindowFunctionExpression, + SqlWindowOrderByArgument, ) from metricflow.sql.sql_plan import ( SqlJoinDescription, @@ -1367,3 +1373,146 @@ def visit_add_generated_uuid_column_node(self, node: AddGeneratedUuidColumnNode) order_bys=(), ), ) + + def visit_join_conversion_events_node(self, node: JoinConversionEventsNode) -> SqlDataSet: + """Builds a resulting data set with all valid conversion events. + + This node takes the conversion and base data set and joins them against an entity and + a valid time range to get successful conversions. It then deduplicates opportunities + via the window function `first_value` to take the closest opportunity to the + corresponding conversion. Then it returns a data set with each row representing a + successful conversion. Duplication may exist in the result due to a single base event + being able to link to multiple conversion events. + """ + base_data_set: SqlDataSet = node.base_node.accept(self) + base_data_set_alias = self._next_unique_table_alias() + + conversion_data_set: SqlDataSet = node.conversion_node.accept(self) + conversion_data_set_alias = self._next_unique_table_alias() + + base_time_dimension_column_name = self._column_association_resolver.resolve_spec( + node.base_time_dimension_spec + ).column_name + conversion_time_dimension_column_name = self._column_association_resolver.resolve_spec( + node.conversion_time_dimension_spec + ).column_name + entity_column_name = self._column_association_resolver.resolve_spec(node.entity_spec).column_name + + # Builds the join conditions that is required for a successful conversion + sql_join_description = SqlQueryPlanJoinBuilder.make_join_conversion_join_description( + node=node, + base_data_set=AnnotatedSqlDataSet( + data_set=base_data_set, + alias=base_data_set_alias, + _metric_time_column_name=base_time_dimension_column_name, + ), + conversion_data_set=AnnotatedSqlDataSet( + data_set=conversion_data_set, + alias=conversion_data_set_alias, + _metric_time_column_name=conversion_time_dimension_column_name, + ), + column_equality_descriptions=( + ColumnEqualityDescription( + left_column_alias=entity_column_name, + right_column_alias=entity_column_name, + ), # add constant property here + ), + ) + + # Builds the first_value window function columns + base_sql_column_references = base_data_set.instance_set.transform( + CreateSqlColumnReferencesForInstances(base_data_set_alias, self._column_association_resolver) + ) + partition_by_columns = (entity_column_name, conversion_time_dimension_column_name) # add constant property here + base_sql_select_columns = tuple( + SqlSelectColumn( + expr=SqlWindowFunctionExpression( + sql_function=SqlWindowFunction.FIRST_VALUE, + sql_function_args=[ + SqlColumnReferenceExpression( + SqlColumnReference( + table_alias=base_data_set_alias, + column_name=base_sql_column_reference.col_ref.column_name, + ), + ) + ], + partition_by_args=[ + SqlColumnReferenceExpression( + SqlColumnReference( + table_alias=conversion_data_set_alias, + column_name=column, + ), + ) + for column in partition_by_columns + ], + order_by_args=[ + SqlWindowOrderByArgument( + expr=SqlColumnReferenceExpression( + SqlColumnReference( + table_alias=base_data_set_alias, + column_name=base_time_dimension_column_name, + ), + ), + descending=True, + ) + ], + ), + column_alias=base_sql_column_reference.col_ref.column_name, + ) + for base_sql_column_reference in base_sql_column_references + ) + + conversion_data_set_output_instance_set = conversion_data_set.instance_set.transform( + FilterElements(include_specs=InstanceSpecSet(measure_specs=(node.conversion_measure_spec,))) + ) + + # Deduplicate the fanout results + conversion_primary_key_select_columns = tuple( + SqlSelectColumn( + expr=SqlColumnReferenceExpression( + SqlColumnReference( + table_alias=conversion_data_set_alias, + column_name=self._column_association_resolver.resolve_spec(spec).column_name, + ), + ), + column_alias=self._column_association_resolver.resolve_spec(spec).column_name, + ) + for spec in node.conversion_primary_key_specs + ) + additional_conversion_select_columns = conversion_data_set_output_instance_set.transform( + CreateSelectColumnsForInstances(conversion_data_set_alias, self._column_association_resolver) + ).as_tuple() + deduped_sql_select_node = SqlSelectStatementNode( + description=f"Dedupe the fanout on {node.conversion_primary_key_specs} in the conversion data set", + select_columns=base_sql_select_columns + + conversion_primary_key_select_columns + + additional_conversion_select_columns, + from_source=base_data_set.sql_select_node, + from_source_alias=base_data_set_alias, + joins_descs=(sql_join_description,), + group_bys=(), + where=None, + order_bys=(), + distinct=True, + ) + + # Returns the original dataset with all the successful conversion + output_data_set_alias = self._next_unique_table_alias() + output_instance_set = ChangeAssociatedColumns(self._column_association_resolver).transform( + InstanceSet.merge([conversion_data_set_output_instance_set, base_data_set.instance_set]) + ) + return SqlDataSet( + instance_set=output_instance_set, + sql_select_node=SqlSelectStatementNode( + description=node.description, + select_columns=output_instance_set.transform( + CreateSelectColumnsForInstances(output_data_set_alias, self._column_association_resolver) + ).as_tuple(), + from_source=deduped_sql_select_node, + from_source_alias=output_data_set_alias, + joins_descs=(), + group_bys=(), + where=None, + order_bys=(), + ), + ) diff --git a/metricflow/plan_conversion/sql_join_builder.py b/metricflow/plan_conversion/sql_join_builder.py index e31e26d2c7..ae8f2bc2ef 100644 --- a/metricflow/plan_conversion/sql_join_builder.py +++ b/metricflow/plan_conversion/sql_join_builder.py @@ -3,7 +3,16 @@ from dataclasses import dataclass from typing import List, Optional, Sequence, Tuple -from metricflow.dataflow.dataflow_plan import JoinDescription, JoinOverTimeRangeNode, JoinToTimeSpineNode +from dbt_semantic_interfaces.protocols.metric import MetricTimeWindow +from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity + +from metricflow.assert_one_arg import assert_exactly_one_arg_set +from metricflow.dataflow.dataflow_plan import ( + JoinConversionEventsNode, + JoinDescription, + JoinOverTimeRangeNode, + JoinToTimeSpineNode, +) from metricflow.dataset.sql_dataset import SqlDataSet from metricflow.plan_conversion.sql_expression_builders import make_coalesced_expr from metricflow.sql.sql_exprs import ( @@ -403,64 +412,112 @@ def _make_equality_expression_for_full_outer_join( ) @staticmethod - def make_cumulative_metric_time_range_join_description( - node: JoinOverTimeRangeNode, - metric_data_set: AnnotatedSqlDataSet, - time_spine_data_set: AnnotatedSqlDataSet, - ) -> SqlJoinDescription: - """Make a join description to connect a cumulative metric input to a time spine dataset. + def _make_time_range_window_join_condition( + base_data_set: AnnotatedSqlDataSet, + time_comparison_dataset: AnnotatedSqlDataSet, + window: Optional[MetricTimeWindow] = None, + grain_to_date: Optional[TimeGranularity] = None, + ) -> SqlLogicalExpression: + """Helper to generate a renderable SqlExpression for expressing a time range window join condition. - Cumulative metrics must be joined against a time spine in a backward-looking fashion, with - a range determined by a time window (delta against metric_time) and optional cumulative grain. + The output will render the following expression: + + a.ds <= b.ds AND a.ds > b.ds - + If no window is present we join across all time -> "a.ds <= b.ds" """ - # Build an expression like "a.ds <= b.ds AND a.ds >= b.ds - - # If no window is present we join across all time -> "a.ds <= b.ds" - metric_time_column_expr = SqlColumnReferenceExpression( + if window or grain_to_date: + assert_exactly_one_arg_set(window=window, grain_to_date=grain_to_date) + base_column_expr = SqlColumnReferenceExpression( SqlColumnReference( - table_alias=metric_data_set.alias, - column_name=metric_data_set.metric_time_column_name, + table_alias=base_data_set.alias, + column_name=base_data_set.metric_time_column_name, ) ) - time_spine_column_expr = SqlColumnReferenceExpression( + time_comparison_column_expr = SqlColumnReferenceExpression( SqlColumnReference( - table_alias=time_spine_data_set.alias, - column_name=time_spine_data_set.metric_time_column_name, + table_alias=time_comparison_dataset.alias, + column_name=time_comparison_dataset.metric_time_column_name, ) ) # Comparison expression against the endpoint of the cumulative time range, - # meaning the metric time must always be BEFORE the time spine time + # meaning the base metrc time must always be BEFORE the comparison metric time end_of_range_comparison_expression = SqlComparisonExpression( - left_expr=metric_time_column_expr, + left_expr=base_column_expr, comparison=SqlComparison.LESS_THAN_OR_EQUALS, - right_expr=time_spine_column_expr, + right_expr=time_comparison_column_expr, ) comparison_expressions: List[SqlComparisonExpression] = [end_of_range_comparison_expression] - if node.window: + if window: start_of_range_comparison_expr = SqlComparisonExpression( - left_expr=metric_time_column_expr, + left_expr=base_column_expr, comparison=SqlComparison.GREATER_THAN, right_expr=SqlSubtractTimeIntervalExpression( - arg=time_spine_column_expr, - count=node.window.count, - granularity=node.window.granularity, + arg=time_comparison_column_expr, + count=window.count, + granularity=window.granularity, ), ) comparison_expressions.append(start_of_range_comparison_expr) - elif node.grain_to_date: + elif grain_to_date: start_of_range_comparison_expr = SqlComparisonExpression( - left_expr=metric_time_column_expr, + left_expr=base_column_expr, comparison=SqlComparison.GREATER_THAN_OR_EQUALS, - right_expr=SqlDateTruncExpression(arg=time_spine_column_expr, time_granularity=node.grain_to_date), + right_expr=SqlDateTruncExpression(arg=time_comparison_column_expr, time_granularity=grain_to_date), ) comparison_expressions.append(start_of_range_comparison_expr) - cumulative_join_condition = SqlLogicalExpression( + return SqlLogicalExpression( operator=SqlLogicalOperator.AND, args=tuple(comparison_expressions), ) + @staticmethod + def make_join_conversion_join_description( + node: JoinConversionEventsNode, + base_data_set: AnnotatedSqlDataSet, + conversion_data_set: AnnotatedSqlDataSet, + column_equality_descriptions: Sequence[ColumnEqualityDescription], + ) -> SqlJoinDescription: + """Make a join description for joining base-to-conversion data sets. + + A successful conversion is when a conversion event occurs after a corresponding base event + under the condition of being within the time range and other conditions (such as constant properties). + This builds the join description to satisfy all those conditions. + """ + window_condition = SqlQueryPlanJoinBuilder._make_time_range_window_join_condition( + base_data_set=base_data_set, + time_comparison_dataset=conversion_data_set, + window=node.window, + ) + return SqlQueryPlanJoinBuilder.make_column_equality_sql_join_description( + right_source_node=conversion_data_set.data_set.sql_select_node, + left_source_alias=base_data_set.alias, + right_source_alias=conversion_data_set.alias, + column_equality_descriptions=column_equality_descriptions, + join_type=SqlJoinType.INNER, + additional_on_conditions=(window_condition,), + ) + + @staticmethod + def make_cumulative_metric_time_range_join_description( + node: JoinOverTimeRangeNode, + metric_data_set: AnnotatedSqlDataSet, + time_spine_data_set: AnnotatedSqlDataSet, + ) -> SqlJoinDescription: + """Make a join description to connect a cumulative metric input to a time spine dataset. + + Cumulative metrics must be joined against a time spine in a backward-looking fashion, with + a range determined by a time window (delta against metric_time) and optional cumulative grain. + """ + cumulative_join_condition = SqlQueryPlanJoinBuilder._make_time_range_window_join_condition( + base_data_set=metric_data_set, + time_comparison_dataset=time_spine_data_set, + window=node.window, + grain_to_date=node.grain_to_date, + ) + return SqlJoinDescription( right_source=metric_data_set.data_set.sql_select_node, right_source_alias=metric_data_set.alias, diff --git a/metricflow/test/dataflow/optimizer/source_scan/test_source_scan_optimizer.py b/metricflow/test/dataflow/optimizer/source_scan/test_source_scan_optimizer.py index 46e400c229..e75dd3b2ab 100644 --- a/metricflow/test/dataflow/optimizer/source_scan/test_source_scan_optimizer.py +++ b/metricflow/test/dataflow/optimizer/source_scan/test_source_scan_optimizer.py @@ -18,6 +18,7 @@ DataflowPlanNode, DataflowPlanNodeVisitor, FilterElementsNode, + JoinConversionEventsNode, JoinOverTimeRangeNode, JoinToBaseOutputNode, JoinToTimeSpineNode, @@ -101,6 +102,9 @@ def visit_join_to_time_spine_node(self, node: JoinToTimeSpineNode) -> int: # no def visit_add_generated_uuid_column_node(self, node: AddGeneratedUuidColumnNode) -> int: # noqa :D return self._sum_parents(node) + def visit_join_conversion_events_node(self, node: JoinConversionEventsNode) -> int: # noqa: D + return self._sum_parents(node) + def count_source_nodes(self, dataflow_plan: DataflowPlan) -> int: # noqa: D return dataflow_plan.sink_output_node.accept(self) From 08d10f080b31366a4b4ad1d340b0782a3e09effc Mon Sep 17 00:00:00 2001 From: Will Deng Date: Fri, 17 Nov 2023 13:45:32 -0500 Subject: [PATCH 03/14] fix lookups and resolvers --- metricflow/model/semantics/linkable_spec_resolver.py | 6 ++++++ metricflow/model/semantics/metric_lookup.py | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/metricflow/model/semantics/linkable_spec_resolver.py b/metricflow/model/semantics/linkable_spec_resolver.py index 96bbef8167..60057ec099 100644 --- a/metricflow/model/semantics/linkable_spec_resolver.py +++ b/metricflow/model/semantics/linkable_spec_resolver.py @@ -500,6 +500,12 @@ def __init__( or metric.type is MetricType.RATIO ): linkable_sets_for_measure.append(self._get_linkable_element_set_for_measure(measure)) + elif metric.type is MetricType.CONVERSION: + if measure == metric.conversion_params.base_measure_reference: + # Only can query against the base measure's linkable elements + # as it joins everything back to the base measure data set so + # there is no way of getting the conversion elements + linkable_sets_for_measure.append(self._get_linkable_element_set_for_measure(measure)) else: assert_values_exhausted(metric.type) diff --git a/metricflow/model/semantics/metric_lookup.py b/metricflow/model/semantics/metric_lookup.py index 21cd0f781e..4f9df240d7 100644 --- a/metricflow/model/semantics/metric_lookup.py +++ b/metricflow/model/semantics/metric_lookup.py @@ -141,7 +141,9 @@ def configured_input_measure_for_metric( # noqa: D if metric.type is MetricType.CUMULATIVE or metric.type is MetricType.SIMPLE: assert len(metric.input_measures) == 1, "Simple and cumulative metrics should have one input measure." return metric.input_measures[0] - elif metric.type is MetricType.RATIO or metric.type is MetricType.DERIVED: + elif ( + metric.type is MetricType.RATIO or metric.type is MetricType.DERIVED or metric.type is MetricType.CONVERSION + ): return None else: assert_values_exhausted(metric.type) From c02e1759aa3de46525f446e4e71d12b3c10ed298 Mon Sep 17 00:00:00 2001 From: Will Deng Date: Mon, 4 Dec 2023 14:20:46 -0500 Subject: [PATCH 04/14] integrate conversion node to dataflow plan builder --- .../dataflow/builder/dataflow_plan_builder.py | 241 ++++++++++++++++-- .../model/semantics/linkable_spec_resolver.py | 6 +- metricflow/plan_conversion/dataflow_to_sql.py | 35 +++ metricflow/specs/specs.py | 5 + 4 files changed, 265 insertions(+), 22 deletions(-) diff --git a/metricflow/dataflow/builder/dataflow_plan_builder.py b/metricflow/dataflow/builder/dataflow_plan_builder.py index 0c8bda4306..2df03bb392 100644 --- a/metricflow/dataflow/builder/dataflow_plan_builder.py +++ b/metricflow/dataflow/builder/dataflow_plan_builder.py @@ -8,12 +8,19 @@ from dbt_semantic_interfaces.enum_extension import assert_values_exhausted from dbt_semantic_interfaces.implementations.metric import PydanticMetricTimeWindow from dbt_semantic_interfaces.pretty_print import pformat_big_objects -from dbt_semantic_interfaces.protocols.metric import MetricTimeWindow, MetricType +from dbt_semantic_interfaces.protocols.metric import ( + ConversionTypeParams, + MetricInputMeasure, + MetricTimeWindow, + MetricType, +) from dbt_semantic_interfaces.references import ( + MeasureReference, MetricReference, TimeDimensionReference, ) from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity +from dbt_semantic_interfaces.validations.unique_valid_name import MetricFlowReservedKeywords from metricflow.collection_helpers.pretty_print import mf_pformat from metricflow.dag.id_generation import DATAFLOW_PLAN_PREFIX, IdGeneratorRegistry @@ -24,6 +31,7 @@ NodeEvaluatorForLinkableInstances, ) from metricflow.dataflow.dataflow_plan import ( + AddGeneratedUuidColumnNode, AggregateMeasuresNode, BaseOutput, CombineAggregatedOutputsNode, @@ -31,6 +39,7 @@ ConstrainTimeRangeNode, DataflowPlan, FilterElementsNode, + JoinConversionEventsNode, JoinDescription, JoinOverTimeRangeNode, JoinToBaseOutputNode, @@ -57,12 +66,14 @@ from metricflow.specs.column_assoc import ColumnAssociationResolver from metricflow.specs.specs import ( CumulativeMeasureDescription, + EntitySpec, InstanceSpecSet, JoinToTimeSpineDescription, LinkableInstanceSpec, LinkableSpecSet, LinklessEntitySpec, MeasureSpec, + MetadataSpec, MetricFlowQuerySpec, MetricInputMeasureSpec, MetricSpec, @@ -205,6 +216,136 @@ def build_plan( return plan + def _build_aggregated_conversion_node( + self, + base_measure_spec: MetricInputMeasureSpec, + conversion_measure_spec: MetricInputMeasureSpec, + entity_spec: EntitySpec, + window: Optional[MetricTimeWindow], + queried_linkable_specs: LinkableSpecSet, + where_constraint: Optional[WhereFilterSpec] = None, + time_range_constraint: Optional[TimeRangeConstraint] = None, + ) -> BaseOutput: + """Builds a node that contains aggregated values of conversions and opportunities.""" + # Build measure recipes + base_required_linkable_specs, _ = self.__get_required_and_extraneous_linkable_specs( + queried_linkable_specs=queried_linkable_specs, + where_constraint=where_constraint, + ) + base_measure_recipe = self._find_dataflow_recipe( + measure_spec_properties=self._build_measure_spec_properties([base_measure_spec.measure_spec]), + time_range_constraint=time_range_constraint, + linkable_spec_set=base_required_linkable_specs, + ) + logger.info(f"Recipe for base measure aggregation:\n{pformat_big_objects(measure_recipe=base_measure_recipe)}") + conversion_measure_recipe = self._find_dataflow_recipe( + measure_spec_properties=self._build_measure_spec_properties([conversion_measure_spec.measure_spec]), + linkable_spec_set=LinkableSpecSet(), + ) + logger.info( + f"Recipe for conversion measure aggregation:\n{pformat_big_objects(measure_recipe=conversion_measure_recipe)}" + ) + if base_measure_recipe is None or conversion_measure_recipe is None: + # TODO: Better error message + raise UnableToSatisfyQueryError("Unable to get measure recipe") + + # Gets the aggregated opportunities + base_aggregated_measures_node = self.build_aggregated_measure( + metric_input_measure_spec=base_measure_spec, + queried_linkable_specs=queried_linkable_specs, + where_constraint=where_constraint, + time_range_constraint=time_range_constraint, + ) + + # Gets the successful conversions using JoinConversionEventsNode + # The conversion events are joined by the base events which are already time constrained. However, this could + # be still be constrained, where we adjust the time range to the window size similar to cumulative, but + # adjusted in the opposite direction. + conversion_measure_node = conversion_measure_recipe.source_node + + # Generate UUID column to uniquely identify each row + conversion_measure_node = AddGeneratedUuidColumnNode(parent_node=conversion_measure_node) + primary_key_specs = (MetadataSpec.from_name(MetricFlowReservedKeywords.MF_INTERNAL_UUID.value),) + + # Get the agg time dimension for each measure + base_time_dimension_reference = self._semantic_model_lookup.get_agg_time_dimension_for_measure( + base_measure_spec.measure_spec.reference + ) + conversion_time_dimension_reference = self._semantic_model_lookup.get_agg_time_dimension_for_measure( + conversion_measure_spec.measure_spec.reference + ) + join_conversion_node = JoinConversionEventsNode( + base_node=base_measure_recipe.source_node, + base_time_dimension_spec=TimeDimensionSpec.from_reference(base_time_dimension_reference), + conversion_node=conversion_measure_node, + conversion_measure_spec=conversion_measure_spec.measure_spec, + conversion_time_dimension_spec=TimeDimensionSpec.from_reference(conversion_time_dimension_reference), + conversion_primary_key_specs=primary_key_specs, + entity_spec=entity_spec, + window=window, + ) + conversion_measure_recipe = DataflowRecipe( + source_node=join_conversion_node, + required_local_linkable_specs=base_measure_recipe.required_local_linkable_specs, + join_linkable_instances_recipes=base_measure_recipe.join_linkable_instances_recipes, + ) + conversion_aggregated_measures_node = self.build_aggregated_measure( + metric_input_measure_spec=conversion_measure_spec, + queried_linkable_specs=queried_linkable_specs, + where_constraint=where_constraint, + time_range_constraint=time_range_constraint, + measure_recipe=conversion_measure_recipe, + ) + + # Combine the aggregated opportunities and conversion values + return CombineAggregatedOutputsNode( + parent_nodes=(base_aggregated_measures_node, conversion_aggregated_measures_node) + ) + + def _build_conversion_metric_output_node( + self, + metric_spec: MetricSpec, + queried_linkable_specs: LinkableSpecSet, + where_constraint: Optional[WhereFilterSpec] = None, + time_range_constraint: Optional[TimeRangeConstraint] = None, + ) -> ComputeMetricsNode: + """Builds a compute metric node for a conversion metric.""" + combined_where = where_constraint + if metric_spec.constraint: + combined_where = ( + combined_where.combine(metric_spec.constraint) if combined_where else metric_spec.constraint + ) + + metric = self._metric_lookup.get_metric(metric_spec.reference) + conversion_type_params = metric.type_params.conversion_type_params + assert conversion_type_params, "A conversion metric should have type_params.conversion_type_params defined." + base_measure, conversion_measure = self._build_input_measure_spec_for_conversion_metric( + metric_reference=metric_spec.reference, + conversion_type_params=conversion_type_params, + column_association_resolver=self._column_association_resolver, + ) + entity_spec = EntitySpec.from_name(conversion_type_params.entity) + logger.info( + f"For conversion metric {metric_spec},\n" + f"base_measure is:\n{pformat_big_objects(base_measure=base_measure)}\n" + f"conversion_measure is:\n{pformat_big_objects(conversion_measure=conversion_measure)}\n" + f"entity is:\n{pformat_big_objects(entity_spec=entity_spec)}" + ) + aggregated_measures_node = self._build_aggregated_conversion_node( + base_measure_spec=base_measure, + conversion_measure_spec=conversion_measure, + queried_linkable_specs=queried_linkable_specs, + where_constraint=combined_where, + time_range_constraint=time_range_constraint, + entity_spec=entity_spec, + window=conversion_type_params.window, + ) + + return self.build_computed_metrics_node( + metric_spec=metric_spec, + aggregated_measures_node=aggregated_measures_node, + ) + def _build_base_metric_output_node( self, metric_spec: MetricSpec, @@ -359,6 +500,13 @@ def _build_any_metric_output_node( filter_spec_factory=filter_spec_factory, time_range_constraint=time_range_constraint, ) + elif metric.type is MetricType.CONVERSION: + return self._build_conversion_metric_output_node( + metric_spec=metric_spec, + queried_linkable_specs=queried_linkable_specs, + where_constraint=where_constraint, + time_range_constraint=time_range_constraint, + ) assert_values_exhausted(metric.type) @@ -763,6 +911,51 @@ def build_computed_metrics_node( metric_specs=[metric_spec], ) + def _build_input_measure_spec_for_conversion_metric( + self, + metric_reference: MetricReference, + conversion_type_params: ConversionTypeParams, + column_association_resolver: ColumnAssociationResolver, + ) -> Tuple[MetricInputMeasureSpec, MetricInputMeasureSpec]: + """Return [base_measure_input, conversion_measure_input] for computing a conversion metric.""" + metric = self._metric_lookup.get_metric(metric_reference) + if metric.type is not MetricType.CONVERSION: + raise ValueError("This should only be called for conversion metrics.") + + assert ( + len(metric.input_measures) == 2 + ), f"A conversion metric should exactly 2 measures. Got{metric.input_measures}" + + def _get_matching_measure( + measure_to_match: MeasureReference, input_measures: Sequence[MetricInputMeasure] + ) -> MetricInputMeasureSpec: + matched_measure = next( + filter( + lambda x: measure_to_match == x.measure_reference, + input_measures, + ), + None, + ) + assert matched_measure, f"Unable to find {measure_to_match} in {input_measures}." + return MetricInputMeasureSpec( + measure_spec=MeasureSpec.from_name(matched_measure.name), + fill_nulls_with=matched_measure.fill_nulls_with, + constraint=WhereSpecFactory( + column_association_resolver=column_association_resolver, + ).create_from_where_filter_intersection(matched_measure.filter), + alias=matched_measure.alias, + ) + + base_input_measure = _get_matching_measure( + measure_to_match=conversion_type_params.base_measure.measure_reference, + input_measures=metric.input_measures, + ) + conversion_input_measure = _get_matching_measure( + measure_to_match=conversion_type_params.conversion_measure.measure_reference, + input_measures=metric.input_measures, + ) + return base_input_measure, conversion_input_measure + def _build_input_measure_spec_for_base_metric( self, filter_spec_factory: WhereSpecFactory, @@ -783,7 +976,9 @@ def _build_input_measure_spec_for_base_metric( if metric.type is MetricType.SIMPLE or metric.type is MetricType.CUMULATIVE: pass - elif metric.type is MetricType.RATIO or metric.type is MetricType.DERIVED: + elif ( + metric.type is MetricType.RATIO or metric.type is MetricType.DERIVED or metric.type is MetricType.CONVERSION + ): raise ValueError("This should only be called for base metrics.") else: assert_values_exhausted(metric.type) @@ -881,6 +1076,7 @@ def build_aggregated_measure( metric_input_measure_spec: MetricInputMeasureSpec, queried_linkable_specs: LinkableSpecSet, time_range_constraint: Optional[TimeRangeConstraint] = None, + measure_recipe: Optional[DataflowRecipe] = None, ) -> BaseOutput: """Returns a node where the measures are aggregated by the linkable specs and constrained appropriately. @@ -900,6 +1096,7 @@ def build_aggregated_measure( metric_input_measure_spec=metric_input_measure_spec, queried_linkable_specs=queried_linkable_specs, time_range_constraint=time_range_constraint, + measure_recipe=measure_recipe, ) def __get_required_and_extraneous_linkable_specs( @@ -929,6 +1126,7 @@ def _build_aggregated_measure_from_measure_source_node( metric_input_measure_spec: MetricInputMeasureSpec, queried_linkable_specs: LinkableSpecSet, time_range_constraint: Optional[TimeRangeConstraint] = None, + measure_recipe: Optional[DataflowRecipe] = None, ) -> BaseOutput: measure_spec = metric_input_measure_spec.measure_spec cumulative = metric_input_measure_spec.culmination_description is not None @@ -968,30 +1166,31 @@ def _build_aggregated_measure_from_measure_source_node( non_additive_dimension_spec=non_additive_dimension_spec, ) - logger.info( - f"Looking for a recipe to get:\n" - f"{pformat_big_objects(measure_specs=[measure_spec], required_linkable_set=required_linkable_specs)}" - ) - - find_recipe_start_time = time.time() before_aggregation_time_spine_join_description = ( metric_input_measure_spec.before_aggregation_time_spine_join_description ) - measure_recipe = self._find_dataflow_recipe( - measure_spec_properties=measure_properties, - time_range_constraint=(cumulative_metric_adjusted_time_constraint or time_range_constraint) - if not before_aggregation_time_spine_join_description - else None, - linkable_spec_set=required_linkable_specs, - ) - logger.info( - f"With {len(self._source_nodes)} source nodes, finding a recipe took " - f"{time.time() - find_recipe_start_time:.2f}s" - ) + + if measure_recipe is None: + logger.info( + f"Looking for a recipe to get:\n" + f"{pformat_big_objects(measure_specs=[measure_spec], required_linkable_set=required_linkable_specs)}" + ) + find_recipe_start_time = time.time() + measure_recipe = self._find_dataflow_recipe( + measure_spec_properties=measure_properties, + time_range_constraint=(cumulative_metric_adjusted_time_constraint or time_range_constraint) + if not before_aggregation_time_spine_join_description + else None, + linkable_spec_set=required_linkable_specs, + ) + logger.info( + f"With {len(self._source_nodes)} source nodes, finding a recipe took " + f"{time.time() - find_recipe_start_time:.2f}s" + ) logger.info(f"Using recipe:\n{pformat_big_objects(measure_recipe=measure_recipe)}") - if not measure_recipe: + if measure_recipe is None: # TODO: Improve for better user understandability. raise UnableToSatisfyQueryError( f"Recipe not found for measure spec: {measure_spec} and linkable specs: {required_linkable_specs}" @@ -1099,7 +1298,7 @@ def _build_aggregated_measure_from_measure_source_node( ) if not extraneous_linkable_specs.is_subset_of(queried_linkable_specs): - # At this point, it's the case that the linkable specs in the extraneous specs are not a subset of the queried + # At this point, it's the case that there are extraneous specs are not a subset of the queried # linkable specs. A filter is needed after, say, a where clause so that the linkable specs in the where clause don't # show up in the final result. # diff --git a/metricflow/model/semantics/linkable_spec_resolver.py b/metricflow/model/semantics/linkable_spec_resolver.py index 60057ec099..e221cecebb 100644 --- a/metricflow/model/semantics/linkable_spec_resolver.py +++ b/metricflow/model/semantics/linkable_spec_resolver.py @@ -501,7 +501,11 @@ def __init__( ): linkable_sets_for_measure.append(self._get_linkable_element_set_for_measure(measure)) elif metric.type is MetricType.CONVERSION: - if measure == metric.conversion_params.base_measure_reference: + conversion_type_params = metric.type_params.conversion_type_params + assert ( + conversion_type_params + ), "A conversion metric should have type_params.conversion_type_params defined." + if measure == conversion_type_params.base_measure.measure_reference: # Only can query against the base measure's linkable elements # as it joins everything back to the base measure data set so # there is no way of getting the conversion elements diff --git a/metricflow/plan_conversion/dataflow_to_sql.py b/metricflow/plan_conversion/dataflow_to_sql.py index 6c48d2c335..b8425a50b2 100644 --- a/metricflow/plan_conversion/dataflow_to_sql.py +++ b/metricflow/plan_conversion/dataflow_to_sql.py @@ -7,6 +7,7 @@ from dbt_semantic_interfaces.enum_extension import assert_values_exhausted from dbt_semantic_interfaces.protocols.metric import MetricInputMeasure, MetricType from dbt_semantic_interfaces.references import MetricModelReference +from dbt_semantic_interfaces.type_enums.conversion_calculation_type import ConversionCalculationType from dbt_semantic_interfaces.validations.unique_valid_name import MetricFlowReservedKeywords from metricflow.aggregation_properties import AggregationState @@ -627,6 +628,40 @@ def visit_compute_metrics_node(self, node: ComputeMetricsNode) -> SqlDataSet: elif metric.type is MetricType.DERIVED: assert metric.type_params.expr metric_expr = SqlStringExpression(sql_expr=metric.type_params.expr) + elif metric.type == MetricType.CONVERSION: + conversion_type_params = metric.type_params.conversion_type_params + assert ( + conversion_type_params + ), "A conversion metric should have type_params.conversion_type_params defined." + base_measure = conversion_type_params.base_measure + conversion_measure = conversion_type_params.conversion_measure + base_measure_column = self._column_association_resolver.resolve_spec( + MeasureSpec(element_name=base_measure.post_aggregation_measure_reference.element_name) + ).column_name + conversion_measure_column = self._column_association_resolver.resolve_spec( + MeasureSpec(element_name=conversion_measure.post_aggregation_measure_reference.element_name) + ).column_name + + calculation_type = conversion_type_params.calculation + conversion_column_reference = SqlColumnReferenceExpression( + SqlColumnReference( + table_alias=from_data_set_alias, + column_name=conversion_measure_column, + ) + ) + base_column_reference = SqlColumnReferenceExpression( + SqlColumnReference( + table_alias=from_data_set_alias, + column_name=base_measure_column, + ) + ) + if calculation_type == ConversionCalculationType.CONVERSION_RATE: + metric_expr = SqlRatioComputationExpression( + numerator=conversion_column_reference, + denominator=base_column_reference, + ) + elif calculation_type == ConversionCalculationType.CONVERSIONS: + metric_expr = conversion_column_reference else: assert_values_exhausted(metric.type) diff --git a/metricflow/specs/specs.py b/metricflow/specs/specs.py index 83c0f7bf50..e112362413 100644 --- a/metricflow/specs/specs.py +++ b/metricflow/specs/specs.py @@ -410,6 +410,11 @@ def qualified_name(self) -> str: # noqa: D date_part=self.date_part, ).qualified_name + @staticmethod + def from_reference(reference: TimeDimensionReference) -> TimeDimensionSpec: + """Initialize from a time dimension reference instance.""" + return TimeDimensionSpec(entity_links=(), element_name=reference.element_name) + @property @override def as_spec_set(self) -> InstanceSpecSet: From deb3940d9610ccd9ec642ac11407b74abeea1001 Mon Sep 17 00:00:00 2001 From: Will Deng Date: Mon, 11 Dec 2023 12:51:23 -0500 Subject: [PATCH 05/14] added constant properties support --- .../dataflow/builder/dataflow_plan_builder.py | 28 +++++++++++++- metricflow/dataflow/dataflow_plan.py | 11 ++++++ .../model/semantics/semantic_model_lookup.py | 29 +++++++++++++- metricflow/plan_conversion/dataflow_to_sql.py | 38 ++++++++++++++++--- metricflow/protocols/semantics.py | 5 +++ metricflow/specs/specs.py | 8 ++++ 6 files changed, 111 insertions(+), 8 deletions(-) diff --git a/metricflow/dataflow/builder/dataflow_plan_builder.py b/metricflow/dataflow/builder/dataflow_plan_builder.py index 2df03bb392..62cdfb382d 100644 --- a/metricflow/dataflow/builder/dataflow_plan_builder.py +++ b/metricflow/dataflow/builder/dataflow_plan_builder.py @@ -9,6 +9,7 @@ from dbt_semantic_interfaces.implementations.metric import PydanticMetricTimeWindow from dbt_semantic_interfaces.pretty_print import pformat_big_objects from dbt_semantic_interfaces.protocols.metric import ( + ConstantPropertyInput, ConversionTypeParams, MetricInputMeasure, MetricTimeWindow, @@ -65,6 +66,7 @@ from metricflow.query.group_by_item.filter_spec_resolution.filter_spec_lookup import FilterSpecResolutionLookUp from metricflow.specs.column_assoc import ColumnAssociationResolver from metricflow.specs.specs import ( + ConstantPropertySpec, CumulativeMeasureDescription, EntitySpec, InstanceSpecSet, @@ -225,6 +227,7 @@ def _build_aggregated_conversion_node( queried_linkable_specs: LinkableSpecSet, where_constraint: Optional[WhereFilterSpec] = None, time_range_constraint: Optional[TimeRangeConstraint] = None, + constant_properties: Optional[Sequence[ConstantPropertyInput]] = None, ) -> BaseOutput: """Builds a node that contains aggregated values of conversions and opportunities.""" # Build measure recipes @@ -263,7 +266,7 @@ def _build_aggregated_conversion_node( # adjusted in the opposite direction. conversion_measure_node = conversion_measure_recipe.source_node - # Generate UUID column to uniquely identify each row + # Generate UUID column for conversion source to uniquely identify each row conversion_measure_node = AddGeneratedUuidColumnNode(parent_node=conversion_measure_node) primary_key_specs = (MetadataSpec.from_name(MetricFlowReservedKeywords.MF_INTERNAL_UUID.value),) @@ -274,6 +277,25 @@ def _build_aggregated_conversion_node( conversion_time_dimension_reference = self._semantic_model_lookup.get_agg_time_dimension_for_measure( conversion_measure_spec.measure_spec.reference ) + + # Filter the source nodes with only the required specs needed for the calculation + constant_property_specs = [] + required_specs = [base_measure_spec.measure_spec, entity_spec, base_time_dimension_spec] + for constant_property in constant_properties or []: + base_property_spec = self._semantic_model_lookup.get_element_spec_for_name(constant_property.base_property) + conversion_property_spec = self._semantic_model_lookup.get_element_spec_for_name( + constant_property.conversion_property + ) + required_specs.append(base_property_spec) + constant_property_specs.append( + ConstantPropertySpec(base_spec=base_property_spec, conversion_spec=conversion_property_spec) + ) + + filtered_base_node = FilterElementsNode( + parent_node=base_measure_recipe.source_node, + include_specs=InstanceSpecSet.from_specs(required_specs).merge(base_required_linkable_specs.as_spec_set), + ) + join_conversion_node = JoinConversionEventsNode( base_node=base_measure_recipe.source_node, base_time_dimension_spec=TimeDimensionSpec.from_reference(base_time_dimension_reference), @@ -283,12 +305,14 @@ def _build_aggregated_conversion_node( conversion_primary_key_specs=primary_key_specs, entity_spec=entity_spec, window=window, + constant_properties=constant_property_specs, ) conversion_measure_recipe = DataflowRecipe( source_node=join_conversion_node, required_local_linkable_specs=base_measure_recipe.required_local_linkable_specs, join_linkable_instances_recipes=base_measure_recipe.join_linkable_instances_recipes, ) + conversion_aggregated_measures_node = self.build_aggregated_measure( metric_input_measure_spec=conversion_measure_spec, queried_linkable_specs=queried_linkable_specs, @@ -331,6 +355,7 @@ def _build_conversion_metric_output_node( f"conversion_measure is:\n{pformat_big_objects(conversion_measure=conversion_measure)}\n" f"entity is:\n{pformat_big_objects(entity_spec=entity_spec)}" ) + aggregated_measures_node = self._build_aggregated_conversion_node( base_measure_spec=base_measure, conversion_measure_spec=conversion_measure, @@ -339,6 +364,7 @@ def _build_conversion_metric_output_node( time_range_constraint=time_range_constraint, entity_spec=entity_spec, window=conversion_type_params.window, + constant_properties=conversion_type_params.constant_properties, ) return self.build_computed_metrics_node( diff --git a/metricflow/dataflow/dataflow_plan.py b/metricflow/dataflow/dataflow_plan.py index 960672f2fb..359d7ae0ea 100644 --- a/metricflow/dataflow/dataflow_plan.py +++ b/metricflow/dataflow/dataflow_plan.py @@ -42,6 +42,7 @@ from metricflow.dataset.sql_dataset import SqlDataSet from metricflow.filters.time_constraint import TimeRangeConstraint from metricflow.specs.specs import ( + ConstantPropertySpec, EntitySpec, InstanceSpec, InstanceSpecSet, @@ -1308,6 +1309,7 @@ def __init__( unique_identifier_keys: Sequence[InstanceSpec], entity_spec: EntitySpec, window: Optional[MetricTimeWindow] = None, + constant_properties: Optional[Sequence[ConstantPropertySpec]] = None, ) -> None: """Constructor. @@ -1320,6 +1322,8 @@ def __init__( unique_identifier_keys: columns to uniquely identify each conversion event. entity_spec: the specific entity in which the conversion is happening for. window: time range bound for when a conversion is still considered valid (default: INF). + constant_properties: optional set of elements (either dimension/entity) to join the base + event to the conversion event. """ self._base_node = base_node self._conversion_node = conversion_node @@ -1329,6 +1333,7 @@ def __init__( self._unique_identifier_keys = unique_identifier_keys self._entity_spec = entity_spec self._window = window + self._constant_properties = constant_properties super().__init__(node_id=self.create_unique_id(), parent_nodes=[base_node, conversion_node]) @classmethod @@ -1370,6 +1375,10 @@ def entity_spec(self) -> EntitySpec: # noqa: D def window(self) -> Optional[MetricTimeWindow]: # noqa: D return self._window + @property + def constant_properties(self) -> Optional[Sequence[ConstantPropertySpec]]: # noqa: D + return self._constant_properties + @property def description(self) -> str: # noqa: D return f"Find conversions for {self.entity_spec.qualified_name} within the range of {f'{self.window.count} {self.window.granularity.value}' if self.window else 'INF'}" @@ -1400,6 +1409,7 @@ def functionally_identical(self, other_node: DataflowPlanNode) -> bool: # noqa: and other_node.unique_identifier_keys == self.unique_identifier_keys and other_node.entity_spec == self.entity_spec and other_node.window == self.window + and other_node.constant_properties == self.constant_properties ) def with_new_parents(self, new_parent_nodes: Sequence[BaseOutput]) -> JoinConversionEventsNode: # noqa: D @@ -1413,6 +1423,7 @@ def with_new_parents(self, new_parent_nodes: Sequence[BaseOutput]) -> JoinConver unique_identifier_keys=self.unique_identifier_keys, entity_spec=self.entity_spec, window=self.window, + constant_properties=self.constant_properties, ) diff --git a/metricflow/model/semantics/semantic_model_lookup.py b/metricflow/model/semantics/semantic_model_lookup.py index 7c459949cd..9aceec4582 100644 --- a/metricflow/model/semantics/semantic_model_lookup.py +++ b/metricflow/model/semantics/semantic_model_lookup.py @@ -28,7 +28,14 @@ from metricflow.model.semantics.element_group import ElementGrouper from metricflow.model.spec_converters import MeasureConverter from metricflow.protocols.semantics import SemanticModelAccessor -from metricflow.specs.specs import MeasureSpec, NonAdditiveDimensionSpec +from metricflow.specs.specs import ( + DimensionSpec, + EntitySpec, + LinkableInstanceSpec, + MeasureSpec, + NonAdditiveDimensionSpec, + TimeDimensionSpec, +) logger = logging.getLogger(__name__) @@ -57,6 +64,9 @@ def __init__( # noqa: D self._entity_ref_to_entity: Dict[EntityReference, Optional[str]] = {} self._semantic_model_names: Set[str] = set() + self._dimension_ref_to_spec: Dict[DimensionReference, DimensionSpec] = {} + self._entity_ref_to_spec: Dict[EntityReference, EntitySpec] = {} + self._semantic_model_to_aggregation_time_dimensions: Dict[ SemanticModelReference, ElementGrouper[TimeDimensionReference, MeasureSpec] ] = {} @@ -242,10 +252,17 @@ def _add_semantic_model(self, semantic_model: SemanticModel) -> None: for dim in semantic_model.dimensions: self._linkable_reference_index[dim.reference].append(semantic_model) self._dimension_index[dim.reference].append(semantic_model) + self._dimension_ref_to_spec[dim.time_dimension_reference or dim.reference] = ( + TimeDimensionSpec.from_name(dim.name) + if dim.type is DimensionType.TIME + else DimensionSpec.from_name(dim.name) + ) + for entity in semantic_model.entities: self._entity_ref_to_entity[entity.reference] = entity.name self._entity_index[entity.name].append(semantic_model) self._linkable_reference_index[entity.reference].append(semantic_model) + self._entity_ref_to_spec[entity.reference] = EntitySpec.from_name(entity.name) self._semantic_model_reference_to_semantic_model[semantic_model.reference] = semantic_model @@ -320,3 +337,13 @@ def entity_links_for_local_elements(semantic_model: SemanticModel) -> Sequence[E possible_entity_links.add(entity.reference) return sorted(possible_entity_links, key=lambda entity_reference: entity_reference.element_name) + + def get_element_spec_for_name(self, element_name: str) -> LinkableInstanceSpec: # noqa: D + if TimeDimensionReference(element_name=element_name) in self._dimension_ref_to_spec: + return self._dimension_ref_to_spec[TimeDimensionReference(element_name=element_name)] + elif DimensionReference(element_name=element_name) in self._dimension_ref_to_spec: + return self._dimension_ref_to_spec[DimensionReference(element_name=element_name)] + elif EntityReference(element_name=element_name) in self._entity_ref_to_spec: + return self._entity_ref_to_spec[EntityReference(element_name=element_name)] + else: + raise ValueError(f"Unable to find linkable element {element_name} in manifest") diff --git a/metricflow/plan_conversion/dataflow_to_sql.py b/metricflow/plan_conversion/dataflow_to_sql.py index b8425a50b2..46dd68ae8d 100644 --- a/metricflow/plan_conversion/dataflow_to_sql.py +++ b/metricflow/plan_conversion/dataflow_to_sql.py @@ -2,7 +2,7 @@ import logging from collections import OrderedDict -from typing import List, Optional, Sequence, Union +from typing import List, Optional, Sequence, Tuple, Union from dbt_semantic_interfaces.enum_extension import assert_values_exhausted from dbt_semantic_interfaces.protocols.metric import MetricInputMeasure, MetricType @@ -1433,6 +1433,16 @@ def visit_join_conversion_events_node(self, node: JoinConversionEventsNode) -> S ).column_name entity_column_name = self._column_association_resolver.resolve_spec(node.entity_spec).column_name + constant_property_column_names: List[Tuple[str, str]] = [] + for constant_property in node.constant_properties or []: + base_property_col_name = self._column_association_resolver.resolve_spec( + constant_property.base_spec + ).column_name + conversion_property_col_name = self._column_association_resolver.resolve_spec( + constant_property.conversion_spec + ).column_name + constant_property_column_names.append((base_property_col_name, conversion_property_col_name)) + # Builds the join conditions that is required for a successful conversion sql_join_description = SqlQueryPlanJoinBuilder.make_join_conversion_join_description( node=node, @@ -1450,7 +1460,11 @@ def visit_join_conversion_events_node(self, node: JoinConversionEventsNode) -> S ColumnEqualityDescription( left_column_alias=entity_column_name, right_column_alias=entity_column_name, - ), # add constant property here + ), + ) + + tuple( + ColumnEqualityDescription(left_column_alias=base_col, right_column_alias=conversion_col) + for base_col, conversion_col in constant_property_column_names ), ) @@ -1458,7 +1472,19 @@ def visit_join_conversion_events_node(self, node: JoinConversionEventsNode) -> S base_sql_column_references = base_data_set.instance_set.transform( CreateSqlColumnReferencesForInstances(base_data_set_alias, self._column_association_resolver) ) - partition_by_columns = (entity_column_name, conversion_time_dimension_column_name) # add constant property here + + conversion_primary_key_col_names = tuple( + self._column_association_resolver.resolve_spec(spec).column_name + for spec in node.conversion_primary_key_specs + ) + partition_by_columns: Tuple[str, ...] = ( + entity_column_name, + conversion_time_dimension_column_name, + ) + conversion_primary_key_col_names + if node.constant_properties: + partition_by_columns += tuple( + conversion_column_name for _, conversion_column_name in constant_property_column_names + ) base_sql_select_columns = tuple( SqlSelectColumn( expr=SqlWindowFunctionExpression( @@ -1507,12 +1533,12 @@ def visit_join_conversion_events_node(self, node: JoinConversionEventsNode) -> S expr=SqlColumnReferenceExpression( SqlColumnReference( table_alias=conversion_data_set_alias, - column_name=self._column_association_resolver.resolve_spec(spec).column_name, + column_name=column_name, ), ), - column_alias=self._column_association_resolver.resolve_spec(spec).column_name, + column_alias=column_name, ) - for spec in node.conversion_primary_key_specs + for column_name in conversion_primary_key_col_names ) additional_conversion_select_columns = conversion_data_set_output_instance_set.transform( CreateSelectColumnsForInstances(conversion_data_set_alias, self._column_association_resolver) diff --git a/metricflow/protocols/semantics.py b/metricflow/protocols/semantics.py index 6e22b9330d..cdaeeaa9a6 100644 --- a/metricflow/protocols/semantics.py +++ b/metricflow/protocols/semantics.py @@ -127,6 +127,11 @@ def entity_links_for_local_elements(semantic_model: SemanticModel) -> Sequence[E """Return the entity prefix that can be used to access dimensions defined in the semantic model.""" raise NotImplementedError + @abstractmethod + def get_element_spec_for_name(self, element_name: str) -> LinkableInstanceSpec: + """Returns the spec for the given name of a linkable element (dimension or entity).""" + raise NotImplementedError + class MetricAccessor(ABC): """Interface for accessing semantic information about a set of metric objects. diff --git a/metricflow/specs/specs.py b/metricflow/specs/specs.py index e112362413..516e5c89eb 100644 --- a/metricflow/specs/specs.py +++ b/metricflow/specs/specs.py @@ -919,6 +919,14 @@ def empty_instance(cls) -> WhereFilterSpec: ) +@dataclass(frozen=True) +class ConstantPropertySpec(SerializableDataclass): + """Includes the specs that are joined for conversion metric's constant properties.""" + + base_spec: LinkableInstanceSpec + conversion_spec: LinkableInstanceSpec + + @dataclass(frozen=True) class JoinToTimeSpineDescription: """Describes how a time spine join should be performed.""" From 849dd06ae1521c1441d0dd3788fa3305118f7339 Mon Sep 17 00:00:00 2001 From: Will Deng Date: Mon, 11 Dec 2023 13:46:56 -0500 Subject: [PATCH 06/14] filter unnecessary columns to avoid needing to distinct select large amount of columns --- .../dataflow/builder/dataflow_plan_builder.py | 87 +++++++++++-------- 1 file changed, 52 insertions(+), 35 deletions(-) diff --git a/metricflow/dataflow/builder/dataflow_plan_builder.py b/metricflow/dataflow/builder/dataflow_plan_builder.py index 62cdfb382d..574200d27e 100644 --- a/metricflow/dataflow/builder/dataflow_plan_builder.py +++ b/metricflow/dataflow/builder/dataflow_plan_builder.py @@ -248,83 +248,100 @@ def _build_aggregated_conversion_node( logger.info( f"Recipe for conversion measure aggregation:\n{pformat_big_objects(measure_recipe=conversion_measure_recipe)}" ) - if base_measure_recipe is None or conversion_measure_recipe is None: - # TODO: Better error message - raise UnableToSatisfyQueryError("Unable to get measure recipe") + if base_measure_recipe is None: + raise UnableToSatisfyQueryError( + f"Recipe not found for measure spec: {base_measure_spec.measure_spec} and linkable specs: {base_required_linkable_specs}" + ) + if conversion_measure_recipe is None: + raise UnableToSatisfyQueryError( + f"Recipe not found for measure spec: {conversion_measure_spec.measure_spec}" + ) # Gets the aggregated opportunities - base_aggregated_measures_node = self.build_aggregated_measure( + aggregated_base_measure_node = self.build_aggregated_measure( metric_input_measure_spec=base_measure_spec, queried_linkable_specs=queried_linkable_specs, where_constraint=where_constraint, time_range_constraint=time_range_constraint, ) - # Gets the successful conversions using JoinConversionEventsNode - # The conversion events are joined by the base events which are already time constrained. However, this could - # be still be constrained, where we adjust the time range to the window size similar to cumulative, but - # adjusted in the opposite direction. - conversion_measure_node = conversion_measure_recipe.source_node - + # Build unaggregated conversions source node # Generate UUID column for conversion source to uniquely identify each row - conversion_measure_node = AddGeneratedUuidColumnNode(parent_node=conversion_measure_node) + unaggregated_conversion_measure_node = AddGeneratedUuidColumnNode( + parent_node=conversion_measure_recipe.source_node + ) primary_key_specs = (MetadataSpec.from_name(MetricFlowReservedKeywords.MF_INTERNAL_UUID.value),) - # Get the agg time dimension for each measure - base_time_dimension_reference = self._semantic_model_lookup.get_agg_time_dimension_for_measure( - base_measure_spec.measure_spec.reference + # Get the agg time dimension for each measure used for matching conversion time windows + base_time_dimension_spec = TimeDimensionSpec.from_reference( + self._semantic_model_lookup.get_agg_time_dimension_for_measure(base_measure_spec.measure_spec.reference) ) - conversion_time_dimension_reference = self._semantic_model_lookup.get_agg_time_dimension_for_measure( - conversion_measure_spec.measure_spec.reference + conversion_time_dimension_spec = TimeDimensionSpec.from_reference( + self._semantic_model_lookup.get_agg_time_dimension_for_measure( + conversion_measure_spec.measure_spec.reference + ) ) # Filter the source nodes with only the required specs needed for the calculation constant_property_specs = [] - required_specs = [base_measure_spec.measure_spec, entity_spec, base_time_dimension_spec] + required_local_specs = [base_measure_spec.measure_spec, entity_spec, base_time_dimension_spec] + list( + base_measure_recipe.required_local_linkable_specs + ) for constant_property in constant_properties or []: base_property_spec = self._semantic_model_lookup.get_element_spec_for_name(constant_property.base_property) conversion_property_spec = self._semantic_model_lookup.get_element_spec_for_name( constant_property.conversion_property ) - required_specs.append(base_property_spec) + required_local_specs.append(base_property_spec) constant_property_specs.append( ConstantPropertySpec(base_spec=base_property_spec, conversion_spec=conversion_property_spec) ) - filtered_base_node = FilterElementsNode( - parent_node=base_measure_recipe.source_node, - include_specs=InstanceSpecSet.from_specs(required_specs).merge(base_required_linkable_specs.as_spec_set), + # Build the unaggregated base measure node for computing conversions + unaggregated_base_measure_node = base_measure_recipe.source_node + if base_measure_recipe.join_targets: + unaggregated_base_measure_node = JoinToBaseOutputNode( + left_node=unaggregated_base_measure_node, join_targets=base_measure_recipe.join_targets + ) + filtered_unaggregated_base_node = FilterElementsNode( + parent_node=unaggregated_base_measure_node, + include_specs=InstanceSpecSet.from_specs(required_local_specs) + .merge(base_required_linkable_specs.as_spec_set) + .dedupe(), ) + # Gets the successful conversions using JoinConversionEventsNode + # The conversion events are joined by the base events which are already time constrained. However, this could + # be still be constrained, where we adjust the time range to the window size similar to cumulative, but + # adjusted in the opposite direction. join_conversion_node = JoinConversionEventsNode( - base_node=base_measure_recipe.source_node, - base_time_dimension_spec=TimeDimensionSpec.from_reference(base_time_dimension_reference), - conversion_node=conversion_measure_node, + base_node=filtered_unaggregated_base_node, + base_time_dimension_spec=base_time_dimension_spec, + conversion_node=unaggregated_conversion_measure_node, conversion_measure_spec=conversion_measure_spec.measure_spec, - conversion_time_dimension_spec=TimeDimensionSpec.from_reference(conversion_time_dimension_reference), + conversion_time_dimension_spec=conversion_time_dimension_spec, conversion_primary_key_specs=primary_key_specs, entity_spec=entity_spec, window=window, constant_properties=constant_property_specs, ) - conversion_measure_recipe = DataflowRecipe( + + # Aggregate the conversion events with the JoinConversionEventsNode as the source node + recipe_with_join_conversion_source_node = DataflowRecipe( source_node=join_conversion_node, required_local_linkable_specs=base_measure_recipe.required_local_linkable_specs, join_linkable_instances_recipes=base_measure_recipe.join_linkable_instances_recipes, ) - - conversion_aggregated_measures_node = self.build_aggregated_measure( + aggregated_conversions_node = self.build_aggregated_measure( metric_input_measure_spec=conversion_measure_spec, queried_linkable_specs=queried_linkable_specs, where_constraint=where_constraint, time_range_constraint=time_range_constraint, - measure_recipe=conversion_measure_recipe, + measure_recipe=recipe_with_join_conversion_source_node, ) - # Combine the aggregated opportunities and conversion values - return CombineAggregatedOutputsNode( - parent_nodes=(base_aggregated_measures_node, conversion_aggregated_measures_node) - ) + # Combine the aggregated opportunities and conversion data sets + return CombineAggregatedOutputsNode(parent_nodes=(aggregated_base_measure_node, aggregated_conversions_node)) def _build_conversion_metric_output_node( self, @@ -343,7 +360,7 @@ def _build_conversion_metric_output_node( metric = self._metric_lookup.get_metric(metric_spec.reference) conversion_type_params = metric.type_params.conversion_type_params assert conversion_type_params, "A conversion metric should have type_params.conversion_type_params defined." - base_measure, conversion_measure = self._build_input_measure_spec_for_conversion_metric( + base_measure, conversion_measure = self._build_input_measure_specs_for_conversion_metric( metric_reference=metric_spec.reference, conversion_type_params=conversion_type_params, column_association_resolver=self._column_association_resolver, @@ -937,7 +954,7 @@ def build_computed_metrics_node( metric_specs=[metric_spec], ) - def _build_input_measure_spec_for_conversion_metric( + def _build_input_measure_specs_for_conversion_metric( self, metric_reference: MetricReference, conversion_type_params: ConversionTypeParams, From daae75688b869293d821636e1605ade43264a98f Mon Sep 17 00:00:00 2001 From: Will Deng Date: Thu, 7 Dec 2023 15:55:53 -0500 Subject: [PATCH 07/14] bump DSI version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index cc89d74116..9f77994289 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,7 +30,7 @@ dependencies = [ "PyYAML~=6.0", "click>=7.1.2", "dbt-core~=1.7.0", - "dbt-semantic-interfaces==0.4.2.dev0", + "dbt-semantic-interfaces~=0.4.2", "graphviz>=0.18.2, <0.21", "halo~=0.0.31", "more-itertools>=8.10.0, <10.2.0", From 4cfd50499c789c95a590231063e8cd2f360d4f55 Mon Sep 17 00:00:00 2001 From: Will Deng Date: Sun, 10 Dec 2023 16:56:40 -0500 Subject: [PATCH 08/14] changelog --- .changes/unreleased/Features-20231210-165636.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changes/unreleased/Features-20231210-165636.yaml diff --git a/.changes/unreleased/Features-20231210-165636.yaml b/.changes/unreleased/Features-20231210-165636.yaml new file mode 100644 index 0000000000..234303c7cc --- /dev/null +++ b/.changes/unreleased/Features-20231210-165636.yaml @@ -0,0 +1,6 @@ +kind: Features +body: Support for Conversion Metrics +time: 2023-12-10T16:56:36.680817-05:00 +custom: + Author: WilliamDee + Issue: "252" From 01d076f169128ffce3a11264c8b29227347cb787 Mon Sep 17 00:00:00 2001 From: Will Deng Date: Mon, 4 Dec 2023 14:21:04 -0500 Subject: [PATCH 09/14] added fixtures and tests --- .../simple_manifest/metrics.yaml | 52 + .../semantic_models/buys_source.yaml | 34 + .../semantic_models/visits_source.yaml | 37 + .../simple_model/fct_buys.yaml | 18 + .../simple_model/fct_visits.yaml | 28 + .../test_cases/itest_conversion_metric.yaml | 352 +++++ .../test/integration/test_configured_cases.py | 8 + .../model/test_semantic_model_container.py | 2 +- .../test_conversion_metrics_to_sql.py | 170 +++ .../DuckDB/test_conversion_metric__plan0.sql | 350 +++++ ...est_conversion_metric__plan0_optimized.sql | 83 ++ .../test_conversion_metric__plan0.xml | 1206 +++++++++++++++++ 12 files changed, 2339 insertions(+), 1 deletion(-) create mode 100644 metricflow/test/fixtures/semantic_manifest_yamls/simple_manifest/semantic_models/buys_source.yaml create mode 100644 metricflow/test/fixtures/semantic_manifest_yamls/simple_manifest/semantic_models/visits_source.yaml create mode 100644 metricflow/test/fixtures/source_table_snapshots/simple_model/fct_buys.yaml create mode 100644 metricflow/test/fixtures/source_table_snapshots/simple_model/fct_visits.yaml create mode 100644 metricflow/test/integration/test_cases/itest_conversion_metric.yaml create mode 100644 metricflow/test/plan_conversion/dataflow_to_sql/test_conversion_metrics_to_sql.py create mode 100644 metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_conversion_metric__plan0.sql create mode 100644 metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_conversion_metric__plan0_optimized.sql create mode 100644 metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_conversion_metric__plan0.xml diff --git a/metricflow/test/fixtures/semantic_manifest_yamls/simple_manifest/metrics.yaml b/metricflow/test/fixtures/semantic_manifest_yamls/simple_manifest/metrics.yaml index fcc08c244d..ce45c49176 100644 --- a/metricflow/test/fixtures/semantic_manifest_yamls/simple_manifest/metrics.yaml +++ b/metricflow/test/fixtures/semantic_manifest_yamls/simple_manifest/metrics.yaml @@ -525,6 +525,58 @@ metric: name: bookings join_to_timespine: true --- +metric: + name: visit_buy_conversion_rate_7days + description: conversion rate on visits-buys on a 7 day window + type: conversion + type_params: + conversion_type_params: + base_measure: visits + conversion_measure: buys + window: 7 days + entity: user + calculation: conversion_rate +--- +metric: + name: visit_buy_conversion_rate + description: conversion rate on visits-buys + type: conversion + type_params: + conversion_type_params: + base_measure: visits + conversion_measure: buys + entity: user + calculation: conversion_rate +--- +metric: + name: visit_buy_conversions + description: conversion count on visits-buys on a 7 day window + type: conversion + type_params: + conversion_type_params: + base_measure: visits + conversion_measure: + name: buys + fill_nulls_with: 0 + window: 7 days + entity: user + calculation: conversions +--- +metric: + name: visit_buy_conversion_rate_by_session + description: conversion rate on visits-buys on a 7 day window held by a constant session_id + type: conversion + type_params: + conversion_type_params: + base_measure: visits + conversion_measure: buys + window: 7 days + entity: user + calculation: conversion_rate + constant_properties: + - base_property: session + conversion_property: session_id +--- metric: name: bookings_fill_nulls_with_0_without_time_spine description: Simple metric filling 0 without time spine. Not a commonly expected scenario. diff --git a/metricflow/test/fixtures/semantic_manifest_yamls/simple_manifest/semantic_models/buys_source.yaml b/metricflow/test/fixtures/semantic_manifest_yamls/simple_manifest/semantic_models/buys_source.yaml new file mode 100644 index 0000000000..fd0eb1d2f2 --- /dev/null +++ b/metricflow/test/fixtures/semantic_manifest_yamls/simple_manifest/semantic_models/buys_source.yaml @@ -0,0 +1,34 @@ +--- +semantic_model: + name: buys_source + description: buys_source + + node_relation: + schema_name: $source_schema + alias: fct_buys + + defaults: + agg_time_dimension: ds + + measures: + - name: buys + expr: 1 + agg: count + - name: buyers + expr: user_id + agg: count_distinct + + dimensions: + - name: ds + type: time + type_params: + time_granularity: day + + primary_entity: buy + + entities: + - name: user + type: foreign + expr: user_id + - name: session_id + type: foreign diff --git a/metricflow/test/fixtures/semantic_manifest_yamls/simple_manifest/semantic_models/visits_source.yaml b/metricflow/test/fixtures/semantic_manifest_yamls/simple_manifest/semantic_models/visits_source.yaml new file mode 100644 index 0000000000..158314f25f --- /dev/null +++ b/metricflow/test/fixtures/semantic_manifest_yamls/simple_manifest/semantic_models/visits_source.yaml @@ -0,0 +1,37 @@ +--- +semantic_model: + name: visits_source + description: visits_source + + node_relation: + schema_name: $source_schema + alias: fct_visits + + defaults: + agg_time_dimension: ds + + measures: + - name: visits + expr: 1 + agg: count + - name: visitors + expr: user_id + agg: count_distinct + + dimensions: + - name: ds + type: time + type_params: + time_granularity: day + - name: referrer_id + type: categorical + + primary_entity: visit + + entities: + - name: user + type: foreign + expr: user_id + - name: session + type: foreign + expr: session_id diff --git a/metricflow/test/fixtures/source_table_snapshots/simple_model/fct_buys.yaml b/metricflow/test/fixtures/source_table_snapshots/simple_model/fct_buys.yaml new file mode 100644 index 0000000000..75e198829c --- /dev/null +++ b/metricflow/test/fixtures/source_table_snapshots/simple_model/fct_buys.yaml @@ -0,0 +1,18 @@ +table_snapshot: + table_name: fct_buys + column_definitions: + - name: ds + type: TIME + - name: user_id + type: STRING + - name: session_id + type: STRING + rows: + - ["2020-01-02", "u0004114", "s1"] + - ["2020-01-03", "u0042324", "s9"] + - ["2020-01-04", "u0005432", "s6"] + - ["2020-01-04", "u0003452", "s7"] + - ["2020-01-07", "u1612112", "s123"] + - ["2020-01-07", "u0004114", "s14"] + - ["2020-01-07", "u0003141", "s3"] + - ["2020-01-10", "u0004117", "s15"] diff --git a/metricflow/test/fixtures/source_table_snapshots/simple_model/fct_visits.yaml b/metricflow/test/fixtures/source_table_snapshots/simple_model/fct_visits.yaml new file mode 100644 index 0000000000..9104d50cc2 --- /dev/null +++ b/metricflow/test/fixtures/source_table_snapshots/simple_model/fct_visits.yaml @@ -0,0 +1,28 @@ +table_snapshot: + table_name: fct_visits + column_definitions: + - name: user_id + type: STRING + - name: ds + type: TIME + - name: referrer_id + type: STRING + - name: session_id + type: STRING + rows: + - ["u0004114", "2020-01-01", "fb_ad_1", "s1"] + - ["u0004214", "2020-01-01", "fb_ad_2", "s2"] + - ["u0003141", "2020-01-01", "homepage_1", "s3"] + - ["u0003154", "2020-01-01", "homepage_2", "s4"] + - ["u1612112", "2020-01-02", "homepage_1", "s5"] + - ["u0005432", "2020-01-02", "fb_ad_3", "s6"] + - ["u0003452", "2020-01-02", "fb_ad_1", "s7"] + - ["u0003452", "2020-01-02", "user_2", "s8"] + - ["u0042324", "2020-01-03", "fb_ad_1", "s9"] + - ["u0005432", "2020-01-03", "google_ad_1", "s10"] + - ["u0005472", "2020-01-03", "google_ad_2", "s11"] + - ["u0005414", "2020-01-04", "google_ad_1", "s12"] + - ["u0004114", "2020-01-06", "homepage_1", "s13"] + - ["u0004114", "2020-01-07", "fb_ad_2", "s14"] + - ["u0004117", "2020-01-10", "google_ad_1", "s15"] + - ["u0003141", "2020-01-12", "user_1", "s16"] diff --git a/metricflow/test/integration/test_cases/itest_conversion_metric.yaml b/metricflow/test/integration/test_cases/itest_conversion_metric.yaml new file mode 100644 index 0000000000..085a37a777 --- /dev/null +++ b/metricflow/test/integration/test_cases/itest_conversion_metric.yaml @@ -0,0 +1,352 @@ +--- +integration_test: + name: conversion_rate_metric_infinite_window + description: Query a conversion metric that calculates the conversion rate + model: SIMPLE_MODEL + metrics: ["visit_buy_conversion_rate"] + group_bys: ["metric_time"] + check_query: | + SELECT + opportunities.metric_time AS metric_time__day + , CAST(conversions.buys AS {{ double_data_type_name }}) / CAST(NULLIF(opportunities.visits, 0) AS {{ double_data_type_name }}) AS visit_buy_conversion_rate + FROM ( + SELECT + metric_time, SUM(a.visits) AS visits + FROM ( + SELECT + ds AS metric_time, 1 AS visits + FROM {{ source_schema }}.fct_visits visits + ) a + GROUP BY + a.metric_time + ) opportunities + FULL OUTER JOIN ( + SELECT + b.ds AS metric_time, SUM(b.buys) AS buys + FROM ( + SELECT DISTINCT + first_value(v.ds) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC) AS ds + , first_value(v.user_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC) AS user_id + , first_value(v.referrer_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC) AS referrer_id + , buy_source.uuid + , 1 AS buys + FROM {{ source_schema }}.fct_visits v + INNER JOIN + ( + SELECT *, {{ generate_random_uuid() }} AS uuid FROM {{ source_schema }}.fct_buys + ) buy_source + ON + v.user_id = buy_source.user_id AND v.ds <= buy_source.ds + ) b + GROUP BY + b.ds + ) conversions + ON opportunities.metric_time = conversions.metric_time +--- +integration_test: + name: conversion_rate_metric_no_group_by + description: Query a conversion metric that calculates the conversion rate with no group bys + model: SIMPLE_MODEL + metrics: ["visit_buy_conversion_rate_7days"] + check_query: | + SELECT + CAST(conversions.buys AS {{ double_data_type_name }}) / CAST(NULLIF(opportunities.visits, 0) AS {{ double_data_type_name }}) AS visit_buy_conversion_rate_7days + FROM ( + SELECT + SUM(a.visits) AS visits + FROM ( + SELECT + 1 AS visits + FROM {{ source_schema }}.fct_visits visits + ) a + ) opportunities + CROSS JOIN ( + SELECT + SUM(b.buys) AS buys + FROM ( + SELECT DISTINCT + first_value(v.user_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC) AS user_id + , first_value(v.referrer_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC) AS referrer_id + , buy_source.uuid + , 1 AS buys + FROM {{ source_schema }}.fct_visits v + INNER JOIN + ( + SELECT *, {{ generate_random_uuid() }} AS uuid FROM {{ source_schema }}.fct_buys + ) buy_source + ON + v.user_id = buy_source.user_id AND v.ds <= buy_source.ds + ) b + ) conversions +--- +integration_test: + name: conversion_rate_metric + description: Query a conversion metric that calculates the conversion rate + model: SIMPLE_MODEL + metrics: ["visit_buy_conversion_rate_7days"] + group_bys: ["metric_time"] + check_query: | + SELECT + opportunities.metric_time AS metric_time__day + , CAST(conversions.buys AS {{ double_data_type_name }}) / CAST(NULLIF(opportunities.visits, 0) AS {{ double_data_type_name }}) AS visit_buy_conversion_rate_7days + FROM ( + SELECT + metric_time, SUM(a.visits) AS visits + FROM ( + SELECT + ds AS metric_time, 1 AS visits + FROM {{ source_schema }}.fct_visits visits + ) a + GROUP BY + a.metric_time + ) opportunities + FULL OUTER JOIN ( + SELECT + b.ds AS metric_time, SUM(b.buys) AS buys + FROM ( + SELECT DISTINCT + first_value(v.ds) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC) AS ds + , first_value(v.user_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC) AS user_id + , first_value(v.referrer_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC) AS referrer_id + , buy_source.uuid + , 1 AS buys + FROM {{ source_schema }}.fct_visits v + INNER JOIN + ( + SELECT *, {{ generate_random_uuid() }} AS uuid FROM {{ source_schema }}.fct_buys + ) buy_source + ON + v.user_id = buy_source.user_id AND v.ds <= buy_source.ds AND v.ds > {{ render_date_sub("buy_source", "ds", 7, TimeGranularity.DAY) }} + ) b + GROUP BY + b.ds + ) conversions + ON opportunities.metric_time = conversions.metric_time +--- +integration_test: + name: conversion_rate_metric_with_dimension + description: Query a conversion metric that calculates the conversion rate without time dimension + model: SIMPLE_MODEL + metrics: ["visit_buy_conversion_rate_7days"] + group_bys: ["visit__referrer_id"] + check_query: | + SELECT + opportunities.referrer_id AS visit__referrer_id + , CAST(conversions.buys AS {{ double_data_type_name }}) / CAST(NULLIF(opportunities.visits, 0) AS {{ double_data_type_name }}) AS visit_buy_conversion_rate_7days + FROM ( + SELECT + referrer_id, SUM(a.visits) AS visits + FROM ( + SELECT + referrer_id, 1 AS visits + FROM {{ source_schema }}.fct_visits visits + ) a + GROUP BY + a.referrer_id + ) opportunities + FULL OUTER JOIN ( + SELECT + referrer_id AS referrer_id, SUM(b.buys) AS buys + FROM ( + SELECT DISTINCT + first_value(v.ds) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC) AS ds + , first_value(v.user_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC) AS user_id + , first_value(v.referrer_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC) AS referrer_id + , buy_source.uuid + , 1 AS buys + FROM {{ source_schema }}.fct_visits v + INNER JOIN + ( + SELECT *, {{ generate_random_uuid() }} AS uuid FROM {{ source_schema }}.fct_buys + ) buy_source + ON + v.user_id = buy_source.user_id AND v.ds <= buy_source.ds AND v.ds > {{ render_date_sub("buy_source", "ds", 7, TimeGranularity.DAY) }} + ) b + GROUP BY + b.referrer_id + ) conversions + ON opportunities.referrer_id = conversions.referrer_id +# TODO: the ordering logic is different in databricks which produces a different, but still correct answer. +# --- +# integration_test: +# name: conversion_rate_metric_with_multiple_dimension +# description: Query a conversion metric that calculates the conversion rate with multiple dimension +# model: SIMPLE_MODEL +# metrics: ["visit_buy_conversion_rate_7days"] +# group_bys: ["metric_time", "visit__referrer_id"] +# check_query: | +# SELECT +# opportunities.referrer_id AS visit__referrer_id +# , opportunities.metric_time AS metric_time__day +# , CAST(conversions.buys AS {{ double_data_type_name }}) / CAST(NULLIF(opportunities.visits, 0) AS {{ double_data_type_name }}) AS visit_buy_conversion_rate_7days +# FROM ( +# SELECT +# metric_time, referrer_id, SUM(a.visits) AS visits +# FROM ( +# SELECT +# ds AS metric_time, referrer_id, 1 AS visits +# FROM {{ source_schema }}.fct_visits visits +# ) a +# GROUP BY +# a.referrer_id, a.metric_time +# ) opportunities +# FULL OUTER JOIN ( +# SELECT +# b.ds AS metric_time, referrer_id AS referrer_id, SUM(b.buys) AS buys +# FROM ( +# SELECT DISTINCT +# first_value(v.ds) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC) AS ds +# , first_value(v.user_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC) AS user_id +# , first_value(v.referrer_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC) AS referrer_id +# , buy_source.uuid +# , 1 AS buys +# FROM {{ source_schema }}.fct_visits v +# INNER JOIN +# ( +# SELECT *, {{ generate_random_uuid() }} AS uuid FROM {{ source_schema }}.fct_buys +# ) buy_source +# ON +# v.user_id = buy_source.user_id AND v.ds <= buy_source.ds AND v.ds > {{ render_date_sub("buy_source", "ds", 7, TimeGranularity.DAY) }} +# ) b +# GROUP BY +# b.referrer_id, b.ds +# ) conversions +# ON opportunities.referrer_id = conversions.referrer_id AND opportunities.metric_time = conversions.metric_time +# --- +# integration_test: +# name: conversion_count_metric_with_multiple_dimension +# description: Query a conversion metric that calculates the conversion count with multiple dimension +# model: SIMPLE_MODEL +# metrics: ["visit_buy_conversions"] +# group_bys: ["metric_time", "visit__referrer_id"] +# check_query: | +# SELECT +# opportunities.referrer_id AS visit__referrer_id +# , opportunities.metric_time AS metric_time__day +# , COALESCE(conversions.buys, 0) AS visit_buy_conversions +# FROM ( +# SELECT +# metric_time, referrer_id, SUM(a.visits) AS visits +# FROM ( +# SELECT +# ds AS metric_time, referrer_id, 1 AS visits +# FROM {{ source_schema }}.fct_visits visits +# ) a +# GROUP BY +# a.referrer_id, a.metric_time +# ) opportunities +# FULL OUTER JOIN ( +# SELECT +# b.ds AS metric_time, referrer_id AS referrer_id, SUM(b.buys) AS buys +# FROM ( +# SELECT DISTINCT +# first_value(v.ds) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC) AS ds +# , first_value(v.user_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC) AS user_id +# , first_value(v.referrer_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC) AS referrer_id +# , buy_source.uuid +# , 1 AS buys +# FROM {{ source_schema }}.fct_visits v +# INNER JOIN +# ( +# SELECT *, {{ generate_random_uuid() }} AS uuid FROM {{ source_schema }}.fct_buys +# ) buy_source +# ON +# v.user_id = buy_source.user_id AND v.ds <= buy_source.ds AND v.ds > {{ render_date_sub("buy_source", "ds", 7, TimeGranularity.DAY) }} +# ) b +# GROUP BY +# b.referrer_id, b.ds +# ) conversions +# ON opportunities.referrer_id = conversions.referrer_id AND opportunities.metric_time = conversions.metric_time +--- +integration_test: + name: conversion_rate_metric_with_constant_property + description: Query a conversion metric that calculates the conversion rate held by a constant property + model: SIMPLE_MODEL + metrics: ["visit_buy_conversion_rate_by_session"] + group_bys: ["metric_time"] + check_query: | + SELECT + opportunities.metric_time AS metric_time__day + , CAST(conversions.buys AS {{ double_data_type_name }}) / CAST(NULLIF(opportunities.visits, 0) AS {{ double_data_type_name }}) AS visit_buy_conversion_rate_by_session + FROM ( + SELECT + metric_time, SUM(a.visits) AS visits + FROM ( + SELECT + ds AS metric_time, 1 AS visits + FROM {{ source_schema }}.fct_visits visits + ) a + GROUP BY + a.metric_time + ) opportunities + FULL OUTER JOIN ( + SELECT + b.ds AS metric_time, SUM(b.buys) AS buys + FROM ( + SELECT DISTINCT + first_value(v.ds) OVER (PARTITION BY buy_source.ds, buy_source.user_id, buy_source.session_id ORDER BY v.ds DESC) AS ds + , first_value(v.user_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id, buy_source.session_id ORDER BY v.ds DESC) AS user_id + , first_value(v.referrer_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id, buy_source.session_id ORDER BY v.ds DESC) AS referrer_id + , buy_source.uuid + , 1 AS buys + FROM {{ source_schema }}.fct_visits v + INNER JOIN + ( + SELECT *, {{ generate_random_uuid() }} AS uuid FROM {{ source_schema }}.fct_buys + ) buy_source + ON + v.user_id = buy_source.user_id + AND v.ds <= buy_source.ds AND v.ds > {{ render_date_sub("buy_source", "ds", 7, TimeGranularity.DAY) }} + AND buy_source.session_id = v.session_id + ) b + GROUP BY + b.ds + ) conversions + ON opportunities.metric_time = conversions.metric_time +--- +integration_test: + name: conversion_rate_metric_with_constant_property_multiple_dimensions + description: Query a conversion metric that calculates the conversion rate held by a constant property + model: SIMPLE_MODEL + metrics: ["visit_buy_conversion_rate_by_session"] + group_bys: ["metric_time", "visit__referrer_id"] + check_query: | + SELECT + opportunities.referrer_id AS visit__referrer_id + , opportunities.metric_time AS metric_time__day + , CAST(conversions.buys AS {{ double_data_type_name }}) / CAST(NULLIF(opportunities.visits, 0) AS {{ double_data_type_name }}) AS visit_buy_conversion_rate_by_session + FROM ( + SELECT + metric_time, referrer_id, SUM(a.visits) AS visits + FROM ( + SELECT + ds AS metric_time, referrer_id, 1 AS visits + FROM {{ source_schema }}.fct_visits visits + ) a + GROUP BY + a.referrer_id, a.metric_time + ) opportunities + FULL OUTER JOIN ( + SELECT + b.ds AS metric_time, referrer_id AS referrer_id, SUM(b.buys) AS buys + FROM ( + SELECT DISTINCT + first_value(v.ds) OVER (PARTITION BY buy_source.ds, buy_source.user_id, buy_source.session_id ORDER BY v.ds DESC) AS ds + , first_value(v.user_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id, buy_source.session_id ORDER BY v.ds DESC) AS user_id + , first_value(v.referrer_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id, buy_source.session_id ORDER BY v.ds DESC) AS referrer_id + , buy_source.uuid + , 1 AS buys + FROM {{ source_schema }}.fct_visits v + INNER JOIN + ( + SELECT *, {{ generate_random_uuid() }} AS uuid FROM {{ source_schema }}.fct_buys + ) buy_source + ON + v.user_id = buy_source.user_id + AND v.ds <= buy_source.ds AND v.ds > {{ render_date_sub("buy_source", "ds", 7, TimeGranularity.DAY) }} + AND buy_source.session_id = v.session_id + ) b + GROUP BY + b.referrer_id, b.ds + ) conversions + ON opportunities.referrer_id = conversions.referrer_id AND opportunities.metric_time = conversions.metric_time diff --git a/metricflow/test/integration/test_configured_cases.py b/metricflow/test/integration/test_configured_cases.py index 7e3640e977..b8a8420df2 100644 --- a/metricflow/test/integration/test_configured_cases.py +++ b/metricflow/test/integration/test_configured_cases.py @@ -28,6 +28,7 @@ SqlColumnReferenceExpression, SqlDateTruncExpression, SqlExtractExpression, + SqlGenerateUuidExpression, SqlPercentileExpression, SqlPercentileExpressionArgument, SqlPercentileFunctionType, @@ -173,6 +174,11 @@ def render_time_dimension_template( else: return f"{{{{ TimeDimension('{time_dimension_name}', entity_path={repr(entity_path)}) }}}}" + def generate_random_uuid(self) -> str: + """Returns the generate random UUID SQL function.""" + expr = SqlGenerateUuidExpression() + return self._sql_client.sql_query_plan_renderer.expr_renderer.render_sql_expr(expr).sql + def filter_not_supported_features( sql_client: SqlClient, required_features: Tuple[RequiredDwEngineFeatures, ...] @@ -295,6 +301,7 @@ def test_case( render_dimension_template=check_query_helpers.render_dimension_template, render_entity_template=check_query_helpers.render_entity_template, render_time_dimension_template=check_query_helpers.render_time_dimension_template, + generate_random_uuid=check_query_helpers.generate_random_uuid, ) if case.where_filter else None, @@ -319,6 +326,7 @@ def test_case( render_percentile_expr=check_query_helpers.render_percentile_expr, mf_time_spine_source=semantic_manifest_lookup.time_spine_source.spine_table.sql, double_data_type_name=check_query_helpers.double_data_type_name, + generate_random_uuid=check_query_helpers.generate_random_uuid, ) ) # If we sort, it's effectively not checking the order whatever order that the output was would be overwritten. diff --git a/metricflow/test/model/test_semantic_model_container.py b/metricflow/test/model/test_semantic_model_container.py index 7dfb6685b7..80ec27d5c7 100644 --- a/metricflow/test/model/test_semantic_model_container.py +++ b/metricflow/test/model/test_semantic_model_container.py @@ -115,7 +115,7 @@ def test_local_linked_elements_for_metric( # noqa: D def test_get_semantic_models_for_entity(semantic_model_lookup: SemanticModelLookup) -> None: # noqa: D entity_reference = EntityReference(element_name="user") linked_semantic_models = semantic_model_lookup.get_semantic_models_for_entity(entity_reference=entity_reference) - assert len(linked_semantic_models) == 8 + assert len(linked_semantic_models) == 10 def test_linkable_set( # noqa: D diff --git a/metricflow/test/plan_conversion/dataflow_to_sql/test_conversion_metrics_to_sql.py b/metricflow/test/plan_conversion/dataflow_to_sql/test_conversion_metrics_to_sql.py new file mode 100644 index 0000000000..0c19952ada --- /dev/null +++ b/metricflow/test/plan_conversion/dataflow_to_sql/test_conversion_metrics_to_sql.py @@ -0,0 +1,170 @@ +from __future__ import annotations + +import pytest +from _pytest.fixtures import FixtureRequest +from dbt_semantic_interfaces.references import EntityReference +from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity + +from metricflow.dataflow.builder.dataflow_plan_builder import DataflowPlanBuilder +from metricflow.plan_conversion.dataflow_to_sql import DataflowToSqlQueryPlanConverter +from metricflow.protocols.sql_client import SqlClient +from metricflow.specs.specs import ( + DimensionSpec, + MetricFlowQuerySpec, + MetricSpec, + TimeDimensionSpec, +) +from metricflow.test.fixtures.setup_fixtures import MetricFlowTestSessionState +from metricflow.test.plan_conversion.test_dataflow_to_sql_plan import convert_and_check + + +@pytest.mark.sql_engine_snapshot +def test_conversion_rate( + request: FixtureRequest, + mf_test_session_state: MetricFlowTestSessionState, + dataflow_plan_builder: DataflowPlanBuilder, + dataflow_to_sql_converter: DataflowToSqlQueryPlanConverter, + sql_client: SqlClient, +) -> None: + """Test conversion metric data flow plan rendering.""" + dimension_spec = DimensionSpec( + element_name="referrer_id", + entity_links=(EntityReference(element_name="visit"),), + ) + metric_spec = MetricSpec(element_name="visit_buy_conversion_rate") + + dataflow_plan = dataflow_plan_builder.build_plan( + query_spec=MetricFlowQuerySpec( + metric_specs=(metric_spec,), + dimension_specs=(dimension_spec,), + ), + ) + + convert_and_check( + request=request, + mf_test_session_state=mf_test_session_state, + dataflow_to_sql_converter=dataflow_to_sql_converter, + sql_client=sql_client, + node=dataflow_plan.sink_output_nodes[0].parent_node, + ) + + +@pytest.mark.sql_engine_snapshot +def test_conversion_rate_with_window( + request: FixtureRequest, + mf_test_session_state: MetricFlowTestSessionState, + dataflow_plan_builder: DataflowPlanBuilder, + dataflow_to_sql_converter: DataflowToSqlQueryPlanConverter, + sql_client: SqlClient, +) -> None: + """Test conversion metric with a window data flow plan rendering.""" + dimension_spec = DimensionSpec( + element_name="referrer_id", + entity_links=(EntityReference(element_name="visit"),), + ) + metric_time_spec = TimeDimensionSpec( + element_name="metric_time", entity_links=(), time_granularity=TimeGranularity.DAY + ) + metric_spec = MetricSpec(element_name="visit_buy_conversion_rate_7days") + + dataflow_plan = dataflow_plan_builder.build_plan( + query_spec=MetricFlowQuerySpec( + metric_specs=(metric_spec,), + dimension_specs=(dimension_spec,), + time_dimension_specs=(metric_time_spec,), + ), + ) + + convert_and_check( + request=request, + mf_test_session_state=mf_test_session_state, + dataflow_to_sql_converter=dataflow_to_sql_converter, + sql_client=sql_client, + node=dataflow_plan.sink_output_nodes[0].parent_node, + ) + + +@pytest.mark.sql_engine_snapshot +def test_conversion_rate_with_no_group_by( + request: FixtureRequest, + mf_test_session_state: MetricFlowTestSessionState, + dataflow_plan_builder: DataflowPlanBuilder, + dataflow_to_sql_converter: DataflowToSqlQueryPlanConverter, + sql_client: SqlClient, +) -> None: + """Test conversion metric with no group by data flow plan rendering.""" + metric_spec = MetricSpec(element_name="visit_buy_conversion_rate_7days") + + dataflow_plan = dataflow_plan_builder.build_plan( + query_spec=MetricFlowQuerySpec( + metric_specs=(metric_spec,), + ), + ) + + convert_and_check( + request=request, + mf_test_session_state=mf_test_session_state, + dataflow_to_sql_converter=dataflow_to_sql_converter, + sql_client=sql_client, + node=dataflow_plan.sink_output_nodes[0].parent_node, + ) + + +@pytest.mark.sql_engine_snapshot +def test_conversion_count_with_no_group_by( + request: FixtureRequest, + mf_test_session_state: MetricFlowTestSessionState, + dataflow_plan_builder: DataflowPlanBuilder, + dataflow_to_sql_converter: DataflowToSqlQueryPlanConverter, + sql_client: SqlClient, +) -> None: + """Test conversion metric with no group by data flow plan rendering.""" + metric_spec = MetricSpec(element_name="visit_buy_conversions") + + dataflow_plan = dataflow_plan_builder.build_plan( + query_spec=MetricFlowQuerySpec( + metric_specs=(metric_spec,), + ), + ) + + convert_and_check( + request=request, + mf_test_session_state=mf_test_session_state, + dataflow_to_sql_converter=dataflow_to_sql_converter, + sql_client=sql_client, + node=dataflow_plan.sink_output_nodes[0].parent_node, + ) + + +@pytest.mark.sql_engine_snapshot +def test_conversion_rate_with_constant_properties( + request: FixtureRequest, + mf_test_session_state: MetricFlowTestSessionState, + dataflow_plan_builder: DataflowPlanBuilder, + dataflow_to_sql_converter: DataflowToSqlQueryPlanConverter, + sql_client: SqlClient, +) -> None: + """Test conversion metric with constant properties by data flow plan rendering.""" + metric_spec = MetricSpec(element_name="visit_buy_conversion_rate_by_session") + dimension_spec = DimensionSpec( + element_name="referrer_id", + entity_links=(EntityReference(element_name="visit"),), + ) + metric_time_spec = TimeDimensionSpec( + element_name="metric_time", entity_links=(), time_granularity=TimeGranularity.DAY + ) + dataflow_plan = dataflow_plan_builder.build_plan( + query_spec=MetricFlowQuerySpec( + metric_specs=(metric_spec,), + dimension_specs=(dimension_spec,), + time_dimension_specs=(metric_time_spec,), + ), + ) + + convert_and_check( + request=request, + mf_test_session_state=mf_test_session_state, + dataflow_to_sql_converter=dataflow_to_sql_converter, + sql_client=sql_client, + node=dataflow_plan.sink_output_nodes[0].parent_node, + ) diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_conversion_metric__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_conversion_metric__plan0.sql new file mode 100644 index 0000000000..0a56dd7299 --- /dev/null +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_conversion_metric__plan0.sql @@ -0,0 +1,350 @@ +-- Compute Metrics via Expressions +SELECT + subq_15.visit__referrer_id + , CAST(subq_15.buys AS DOUBLE) / CAST(NULLIF(subq_15.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate +FROM ( + -- Combine Metrics + SELECT + COALESCE(subq_3.visit__referrer_id, subq_14.visit__referrer_id) AS visit__referrer_id + , MAX(subq_3.visits) AS visits + , MAX(subq_14.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + subq_2.visit__referrer_id + , SUM(subq_2.visits) AS visits + FROM ( + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id'] + SELECT + subq_1.visit__referrer_id + , subq_1.visits + 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.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__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.user + , subq_0.visit__user + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.user_id AS visit__user + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_0 + ) subq_1 + ) subq_2 + GROUP BY + subq_2.visit__referrer_id + ) subq_3 + FULL OUTER JOIN ( + -- Aggregate Measures + SELECT + subq_13.visit__referrer_id + , SUM(subq_13.buys) AS buys + FROM ( + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id'] + SELECT + subq_12.visit__referrer_id + , subq_12.buys + FROM ( + -- Find conversions for EntitySpec(element_name='user', entity_links=()) within the range of count=7 granularity=TimeGranularity.DAY + SELECT + subq_11.visit__referrer_id + , subq_11.buys + , subq_11.visits + FROM ( + -- Dedupe the fanout on (MetadataSpec(element_name='mf_internal_uuid'),) in the conversion data set + SELECT DISTINCT + first_value(subq_6.visits) OVER (PARTITION BY subq_10.user, subq_10.ds__day ORDER BY subq_6.ds__day DESC) AS visits + , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_10.user, subq_10.ds__day ORDER BY subq_6.ds__day DESC) AS visit__referrer_id + , subq_10.mf_internal_uuid AS mf_internal_uuid + , subq_10.buys AS buys + FROM ( + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id'] + SELECT + subq_5.visit__referrer_id + , subq_5.visits + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.visit__ds__day + , subq_4.visit__ds__week + , subq_4.visit__ds__month + , subq_4.visit__ds__quarter + , subq_4.visit__ds__year + , subq_4.visit__ds__extract_year + , subq_4.visit__ds__extract_quarter + , subq_4.visit__ds__extract_month + , subq_4.visit__ds__extract_day + , subq_4.visit__ds__extract_dow + , subq_4.visit__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.visit__user + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.visits + , subq_4.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.user_id AS visit__user + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_4 + ) subq_5 + ) subq_6 + INNER JOIN ( + -- Pass Only Elements: + -- ['buys', 'mf_internal_uuid'] + SELECT + subq_9.buys + , subq_9.mf_internal_uuid + FROM ( + -- Add column with generated UUID + 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.buy__ds__day + , subq_8.buy__ds__week + , subq_8.buy__ds__month + , subq_8.buy__ds__quarter + , subq_8.buy__ds__year + , subq_8.buy__ds__extract_year + , subq_8.buy__ds__extract_quarter + , subq_8.buy__ds__extract_month + , subq_8.buy__ds__extract_day + , subq_8.buy__ds__extract_dow + , subq_8.buy__ds__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.user + , subq_8.buy__user + , subq_8.buys + , subq_8.buyers + , GEN_RANDOM_UUID() AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.buy__ds__day + , subq_7.buy__ds__week + , subq_7.buy__ds__month + , subq_7.buy__ds__quarter + , subq_7.buy__ds__year + , subq_7.buy__ds__extract_year + , subq_7.buy__ds__extract_quarter + , subq_7.buy__ds__extract_month + , subq_7.buy__ds__extract_day + , subq_7.buy__ds__extract_dow + , subq_7.buy__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.buy__user + , subq_7.buys + , subq_7.buyers + FROM ( + -- Read Elements From Semantic Model 'buys_source' + SELECT + 1 AS buys + , buys_source_src_10002.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_10002.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS ds__extract_day + , EXTRACT(isodow FROM buys_source_src_10002.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_10002.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS buy__ds__extract_day + , EXTRACT(isodow FROM buys_source_src_10002.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS buy__ds__extract_doy + , buys_source_src_10002.user_id AS user + , buys_source_src_10002.user_id AS buy__user + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_7 + ) subq_8 + ) subq_9 + ) subq_10 + ON + ( + subq_6.user = subq_10.user + ) AND ( + ( + subq_6.ds__day <= subq_10.ds__day + ) AND ( + subq_6.ds__day > subq_10.ds__day - INTERVAL 7 day + ) + ) + ) subq_11 + ) subq_12 + ) subq_13 + GROUP BY + subq_13.visit__referrer_id + ) subq_14 + ON + subq_3.visit__referrer_id = subq_14.visit__referrer_id + GROUP BY + COALESCE(subq_3.visit__referrer_id, subq_14.visit__referrer_id) +) subq_15 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_conversion_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_conversion_metric__plan0_optimized.sql new file mode 100644 index 0000000000..f340be4a39 --- /dev/null +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_conversion_metric__plan0_optimized.sql @@ -0,0 +1,83 @@ +-- Compute Metrics via Expressions +SELECT + visit__referrer_id + , CAST(buys AS DOUBLE) / CAST(NULLIF(visits, 0) AS DOUBLE) AS visit_buy_conversion_rate +FROM ( + -- Combine Metrics + SELECT + COALESCE(subq_19.visit__referrer_id, subq_30.visit__referrer_id) AS visit__referrer_id + , MAX(subq_19.visits) AS visits + , MAX(subq_30.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + visit__referrer_id + , SUM(visits) AS visits + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id'] + SELECT + referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_18 + GROUP BY + visit__referrer_id + ) subq_19 + FULL OUTER JOIN ( + -- Find conversions for EntitySpec(element_name='user', entity_links=()) within the range of count=7 granularity=TimeGranularity.DAY + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id'] + -- Aggregate Measures + SELECT + visit__referrer_id + , SUM(buys) AS buys + FROM ( + -- Dedupe the fanout on (MetadataSpec(element_name='mf_internal_uuid'),) in the conversion data set + SELECT DISTINCT + first_value(subq_22.visits) OVER (PARTITION BY subq_26.user, subq_26.ds__day ORDER BY subq_22.ds__day DESC) AS visits + , first_value(subq_22.visit__referrer_id) OVER (PARTITION BY subq_26.user, subq_26.ds__day ORDER BY subq_22.ds__day DESC) AS visit__referrer_id + , subq_26.mf_internal_uuid AS mf_internal_uuid + , subq_26.buys AS buys + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id'] + SELECT + referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_22 + INNER JOIN ( + -- Read Elements From Semantic Model 'buys_source' + -- Metric Time Dimension 'ds' + -- Add column with generated UUID + -- Pass Only Elements: + -- ['buys', 'mf_internal_uuid'] + SELECT + 1 AS buys + , GEN_RANDOM_UUID() AS mf_internal_uuid + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_26 + ON + ( + subq_22.user = subq_26.user + ) AND ( + ( + subq_22.ds__day <= subq_26.ds__day + ) AND ( + subq_22.ds__day > subq_26.ds__day - INTERVAL 7 day + ) + ) + ) subq_27 + GROUP BY + visit__referrer_id + ) subq_30 + ON + subq_19.visit__referrer_id = subq_30.visit__referrer_id + GROUP BY + COALESCE(subq_19.visit__referrer_id, subq_30.visit__referrer_id) +) subq_31 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_conversion_metric__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_conversion_metric__plan0.xml new file mode 100644 index 0000000000..ebfbf27b26 --- /dev/null +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_conversion_metric__plan0.xml @@ -0,0 +1,1206 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 549290ba7c4b49b8de11940956ec6489b6cd774c Mon Sep 17 00:00:00 2001 From: Will Deng Date: Fri, 15 Dec 2023 00:44:13 -0500 Subject: [PATCH 10/14] updated conversion metric snapshots --- ...nversion_count_with_no_group_by__plan0.sql | 346 +++++ ...ount_with_no_group_by__plan0_optimized.sql | 63 + .../BigQuery/test_conversion_rate__plan0.sql | 355 +++++ .../test_conversion_rate__plan0_optimized.sql | 83 + ...n_rate_with_constant_properties__plan0.sql | 389 +++++ ...h_constant_properties__plan0_optimized.sql | 111 ++ ...onversion_rate_with_no_group_by__plan0.sql | 346 +++++ ...rate_with_no_group_by__plan0_optimized.sql | 63 + ...est_conversion_rate_with_window__plan0.sql | 379 +++++ ...sion_rate_with_window__plan0_optimized.sql | 101 ++ ...nversion_count_with_no_group_by__plan0.sql | 346 +++++ ...ount_with_no_group_by__plan0_optimized.sql | 63 + .../test_conversion_rate__plan0.sql | 355 +++++ .../test_conversion_rate__plan0_optimized.sql | 83 + ...n_rate_with_constant_properties__plan0.sql | 389 +++++ ...h_constant_properties__plan0_optimized.sql | 111 ++ ...onversion_rate_with_no_group_by__plan0.sql | 346 +++++ ...rate_with_no_group_by__plan0_optimized.sql | 63 + ...est_conversion_rate_with_window__plan0.sql | 379 +++++ ...sion_rate_with_window__plan0_optimized.sql | 101 ++ ...nversion_count_with_no_group_by__plan0.sql | 346 +++++ ...ount_with_no_group_by__plan0_optimized.sql | 63 + .../DuckDB/test_conversion_rate__plan0.sql | 355 +++++ .../test_conversion_rate__plan0_optimized.sql | 83 + ...n_rate_with_constant_properties__plan0.sql | 389 +++++ ...h_constant_properties__plan0_optimized.sql | 111 ++ ...onversion_rate_with_no_group_by__plan0.sql | 346 +++++ ...rate_with_no_group_by__plan0_optimized.sql | 63 + ...est_conversion_rate_with_window__plan0.sql | 379 +++++ ...sion_rate_with_window__plan0_optimized.sql | 101 ++ ...nversion_count_with_no_group_by__plan0.sql | 346 +++++ ...ount_with_no_group_by__plan0_optimized.sql | 63 + .../Postgres/test_conversion_rate__plan0.sql | 355 +++++ .../test_conversion_rate__plan0_optimized.sql | 83 + ...n_rate_with_constant_properties__plan0.sql | 389 +++++ ...h_constant_properties__plan0_optimized.sql | 111 ++ ...onversion_rate_with_no_group_by__plan0.sql | 346 +++++ ...rate_with_no_group_by__plan0_optimized.sql | 63 + ...est_conversion_rate_with_window__plan0.sql | 379 +++++ ...sion_rate_with_window__plan0_optimized.sql | 101 ++ ...nversion_count_with_no_group_by__plan0.sql | 346 +++++ ...ount_with_no_group_by__plan0_optimized.sql | 63 + .../Redshift/test_conversion_rate__plan0.sql | 355 +++++ .../test_conversion_rate__plan0_optimized.sql | 83 + ...n_rate_with_constant_properties__plan0.sql | 389 +++++ ...h_constant_properties__plan0_optimized.sql | 111 ++ ...onversion_rate_with_no_group_by__plan0.sql | 346 +++++ ...rate_with_no_group_by__plan0_optimized.sql | 63 + ...est_conversion_rate_with_window__plan0.sql | 379 +++++ ...sion_rate_with_window__plan0_optimized.sql | 101 ++ ...nversion_count_with_no_group_by__plan0.sql | 346 +++++ ...ount_with_no_group_by__plan0_optimized.sql | 63 + .../Snowflake/test_conversion_rate__plan0.sql | 355 +++++ .../test_conversion_rate__plan0_optimized.sql | 83 + ...n_rate_with_constant_properties__plan0.sql | 389 +++++ ...h_constant_properties__plan0_optimized.sql | 111 ++ ...onversion_rate_with_no_group_by__plan0.sql | 346 +++++ ...rate_with_no_group_by__plan0_optimized.sql | 63 + ...est_conversion_rate_with_window__plan0.sql | 379 +++++ ...sion_rate_with_window__plan0_optimized.sql | 101 ++ ...nversion_count_with_no_group_by__plan0.xml | 1220 +++++++++++++++ .../test_conversion_rate__plan0.xml | 1268 ++++++++++++++++ ...n_rate_with_constant_properties__plan0.xml | 1333 +++++++++++++++++ ...onversion_rate_with_no_group_by__plan0.xml | 1220 +++++++++++++++ ...est_conversion_rate_with_window__plan0.xml | 1316 ++++++++++++++++ 65 files changed, 19773 insertions(+) create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_count_with_no_group_by__plan0.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_count_with_no_group_by__plan0_optimized.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate__plan0.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate__plan0_optimized.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_constant_properties__plan0.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_constant_properties__plan0_optimized.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_no_group_by__plan0.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_no_group_by__plan0_optimized.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_window__plan0.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_window__plan0_optimized.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_count_with_no_group_by__plan0.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_count_with_no_group_by__plan0_optimized.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate__plan0.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate__plan0_optimized.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_constant_properties__plan0.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_constant_properties__plan0_optimized.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_no_group_by__plan0.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_no_group_by__plan0_optimized.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_window__plan0.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_window__plan0_optimized.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_count_with_no_group_by__plan0.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_count_with_no_group_by__plan0_optimized.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate__plan0.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate__plan0_optimized.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_constant_properties__plan0.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_constant_properties__plan0_optimized.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_no_group_by__plan0.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_no_group_by__plan0_optimized.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_window__plan0.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_window__plan0_optimized.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_count_with_no_group_by__plan0.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_count_with_no_group_by__plan0_optimized.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate__plan0.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate__plan0_optimized.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_constant_properties__plan0.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_constant_properties__plan0_optimized.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_no_group_by__plan0.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_no_group_by__plan0_optimized.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_window__plan0.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_window__plan0_optimized.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_count_with_no_group_by__plan0.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_count_with_no_group_by__plan0_optimized.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate__plan0.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate__plan0_optimized.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_constant_properties__plan0.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_constant_properties__plan0_optimized.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_no_group_by__plan0.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_no_group_by__plan0_optimized.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_window__plan0.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_window__plan0_optimized.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_count_with_no_group_by__plan0.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_count_with_no_group_by__plan0_optimized.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate__plan0.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate__plan0_optimized.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_constant_properties__plan0.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_constant_properties__plan0_optimized.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_no_group_by__plan0.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_no_group_by__plan0_optimized.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_window__plan0.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_window__plan0_optimized.sql create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_count_with_no_group_by__plan0.xml create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate__plan0.xml create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_constant_properties__plan0.xml create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_no_group_by__plan0.xml create mode 100644 metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_window__plan0.xml diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_count_with_no_group_by__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_count_with_no_group_by__plan0.sql new file mode 100644 index 0000000000..77762c55b5 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_count_with_no_group_by__plan0.sql @@ -0,0 +1,346 @@ +-- Compute Metrics via Expressions +SELECT + subq_14.buys AS visit_buy_conversions +FROM ( + -- Combine Aggregated Outputs + SELECT + MAX(subq_3.visits) AS visits + , COALESCE(MAX(subq_13.buys), 0) AS buys + FROM ( + -- Aggregate Measures + SELECT + SUM(subq_2.visits) AS visits + FROM ( + -- Pass Only Elements: + -- ['visits'] + SELECT + subq_1.visits + 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.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__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.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC(visits_source_src_10011.ds, day) AS ds__day + , DATE_TRUNC(visits_source_src_10011.ds, isoweek) AS ds__week + , DATE_TRUNC(visits_source_src_10011.ds, month) AS ds__month + , DATE_TRUNC(visits_source_src_10011.ds, quarter) AS ds__quarter + , DATE_TRUNC(visits_source_src_10011.ds, year) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_10011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_10011.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC(visits_source_src_10011.ds, day) AS visit__ds__day + , DATE_TRUNC(visits_source_src_10011.ds, isoweek) AS visit__ds__week + , DATE_TRUNC(visits_source_src_10011.ds, month) AS visit__ds__month + , DATE_TRUNC(visits_source_src_10011.ds, quarter) AS visit__ds__quarter + , DATE_TRUNC(visits_source_src_10011.ds, year) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_10011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_10011.ds) - 1) AS visit__ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_0 + ) subq_1 + ) subq_2 + ) subq_3 + CROSS JOIN ( + -- Aggregate Measures + SELECT + SUM(subq_12.buys) AS buys + FROM ( + -- Pass Only Elements: + -- ['buys'] + SELECT + subq_11.buys + FROM ( + -- Find conversions for user within the range of 7 day + SELECT + subq_10.ds__day + , subq_10.user + , subq_10.buys + , subq_10.visits + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_9.mf_internal_uuid AS mf_internal_uuid + , subq_9.buys AS buys + FROM ( + -- Pass Only Elements: + -- ['visits', 'ds__day', 'user'] + SELECT + subq_5.ds__day + , subq_5.user + , subq_5.visits + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.visit__ds__day + , subq_4.visit__ds__week + , subq_4.visit__ds__month + , subq_4.visit__ds__quarter + , subq_4.visit__ds__year + , subq_4.visit__ds__extract_year + , subq_4.visit__ds__extract_quarter + , subq_4.visit__ds__extract_month + , subq_4.visit__ds__extract_day + , subq_4.visit__ds__extract_dow + , subq_4.visit__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.session + , subq_4.visit__user + , subq_4.visit__session + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.visits + , subq_4.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC(visits_source_src_10011.ds, day) AS ds__day + , DATE_TRUNC(visits_source_src_10011.ds, isoweek) AS ds__week + , DATE_TRUNC(visits_source_src_10011.ds, month) AS ds__month + , DATE_TRUNC(visits_source_src_10011.ds, quarter) AS ds__quarter + , DATE_TRUNC(visits_source_src_10011.ds, year) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_10011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_10011.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC(visits_source_src_10011.ds, day) AS visit__ds__day + , DATE_TRUNC(visits_source_src_10011.ds, isoweek) AS visit__ds__week + , DATE_TRUNC(visits_source_src_10011.ds, month) AS visit__ds__month + , DATE_TRUNC(visits_source_src_10011.ds, quarter) AS visit__ds__quarter + , DATE_TRUNC(visits_source_src_10011.ds, year) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_10011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_10011.ds) - 1) AS visit__ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_4 + ) subq_5 + ) subq_6 + INNER JOIN ( + -- Add column with generated UUID + 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.buy__ds__day + , subq_8.buy__ds__week + , subq_8.buy__ds__month + , subq_8.buy__ds__quarter + , subq_8.buy__ds__year + , subq_8.buy__ds__extract_year + , subq_8.buy__ds__extract_quarter + , subq_8.buy__ds__extract_month + , subq_8.buy__ds__extract_day + , subq_8.buy__ds__extract_dow + , subq_8.buy__ds__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.user + , subq_8.session_id + , subq_8.buy__user + , subq_8.buy__session_id + , subq_8.buys + , subq_8.buyers + , GENERATE_UUID() AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.buy__ds__day + , subq_7.buy__ds__week + , subq_7.buy__ds__month + , subq_7.buy__ds__quarter + , subq_7.buy__ds__year + , subq_7.buy__ds__extract_year + , subq_7.buy__ds__extract_quarter + , subq_7.buy__ds__extract_month + , subq_7.buy__ds__extract_day + , subq_7.buy__ds__extract_dow + , subq_7.buy__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.session_id + , subq_7.buy__user + , subq_7.buy__session_id + , subq_7.buys + , subq_7.buyers + FROM ( + -- Read Elements From Semantic Model 'buys_source' + SELECT + 1 AS buys + , buys_source_src_10002.user_id AS buyers + , DATE_TRUNC(buys_source_src_10002.ds, day) AS ds__day + , DATE_TRUNC(buys_source_src_10002.ds, isoweek) AS ds__week + , DATE_TRUNC(buys_source_src_10002.ds, month) AS ds__month + , DATE_TRUNC(buys_source_src_10002.ds, quarter) AS ds__quarter + , DATE_TRUNC(buys_source_src_10002.ds, year) AS ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM buys_source_src_10002.ds) = 1, 7, EXTRACT(dayofweek FROM buys_source_src_10002.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM buys_source_src_10002.ds) AS ds__extract_doy + , DATE_TRUNC(buys_source_src_10002.ds, day) AS buy__ds__day + , DATE_TRUNC(buys_source_src_10002.ds, isoweek) AS buy__ds__week + , DATE_TRUNC(buys_source_src_10002.ds, month) AS buy__ds__month + , DATE_TRUNC(buys_source_src_10002.ds, quarter) AS buy__ds__quarter + , DATE_TRUNC(buys_source_src_10002.ds, year) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS buy__ds__extract_day + , IF(EXTRACT(dayofweek FROM buys_source_src_10002.ds) = 1, 7, EXTRACT(dayofweek FROM buys_source_src_10002.ds) - 1) AS buy__ds__extract_dow + , EXTRACT(dayofyear FROM buys_source_src_10002.ds) AS buy__ds__extract_doy + , buys_source_src_10002.user_id AS user + , buys_source_src_10002.session_id + , buys_source_src_10002.user_id AS buy__user + , buys_source_src_10002.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_7 + ) subq_8 + ) subq_9 + ON + ( + subq_6.user = subq_9.user + ) AND ( + ( + subq_6.ds__day <= subq_9.ds__day + ) AND ( + subq_6.ds__day > DATE_SUB(CAST(subq_9.ds__day AS DATETIME), INTERVAL 7 day) + ) + ) + ) subq_10 + ) subq_11 + ) subq_12 + ) subq_13 +) subq_14 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_count_with_no_group_by__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_count_with_no_group_by__plan0_optimized.sql new file mode 100644 index 0000000000..b01d55a4a7 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_count_with_no_group_by__plan0_optimized.sql @@ -0,0 +1,63 @@ +-- Combine Aggregated Outputs +-- Compute Metrics via Expressions +SELECT + COALESCE(MAX(subq_28.buys), 0) AS visit_buy_conversions +FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits'] + -- Aggregate Measures + SELECT + SUM(1) AS visits + FROM ***************************.fct_visits visits_source_src_10011 +) subq_18 +CROSS JOIN ( + -- Find conversions for user within the range of 7 day + -- Pass Only Elements: + -- ['buys'] + -- Aggregate Measures + SELECT + SUM(buys) AS buys + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_24.mf_internal_uuid AS mf_internal_uuid + , subq_24.buys AS buys + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'ds__day', 'user'] + SELECT + DATE_TRUNC(ds, day) AS ds__day + , user_id AS user + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_21 + INNER JOIN ( + -- Read Elements From Semantic Model 'buys_source' + -- Metric Time Dimension 'ds' + -- Add column with generated UUID + SELECT + DATE_TRUNC(ds, day) AS ds__day + , user_id AS user + , 1 AS buys + , GENERATE_UUID() AS mf_internal_uuid + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_24 + ON + ( + subq_21.user = subq_24.user + ) AND ( + ( + subq_21.ds__day <= subq_24.ds__day + ) AND ( + subq_21.ds__day > DATE_SUB(CAST(subq_24.ds__day AS DATETIME), INTERVAL 7 day) + ) + ) + ) subq_25 +) subq_28 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate__plan0.sql new file mode 100644 index 0000000000..3dbd424e23 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate__plan0.sql @@ -0,0 +1,355 @@ +-- Compute Metrics via Expressions +SELECT + subq_14.visit__referrer_id + , CAST(subq_14.buys AS FLOAT64) / CAST(NULLIF(subq_14.visits, 0) AS FLOAT64) AS visit_buy_conversion_rate +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id + , MAX(subq_3.visits) AS visits + , MAX(subq_13.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + subq_2.visit__referrer_id + , SUM(subq_2.visits) AS visits + FROM ( + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id'] + SELECT + subq_1.visit__referrer_id + , subq_1.visits + 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.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__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.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC(visits_source_src_10011.ds, day) AS ds__day + , DATE_TRUNC(visits_source_src_10011.ds, isoweek) AS ds__week + , DATE_TRUNC(visits_source_src_10011.ds, month) AS ds__month + , DATE_TRUNC(visits_source_src_10011.ds, quarter) AS ds__quarter + , DATE_TRUNC(visits_source_src_10011.ds, year) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_10011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_10011.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC(visits_source_src_10011.ds, day) AS visit__ds__day + , DATE_TRUNC(visits_source_src_10011.ds, isoweek) AS visit__ds__week + , DATE_TRUNC(visits_source_src_10011.ds, month) AS visit__ds__month + , DATE_TRUNC(visits_source_src_10011.ds, quarter) AS visit__ds__quarter + , DATE_TRUNC(visits_source_src_10011.ds, year) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_10011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_10011.ds) - 1) AS visit__ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_0 + ) subq_1 + ) subq_2 + GROUP BY + visit__referrer_id + ) subq_3 + FULL OUTER JOIN ( + -- Aggregate Measures + SELECT + subq_12.visit__referrer_id + , SUM(subq_12.buys) AS buys + FROM ( + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id'] + SELECT + subq_11.visit__referrer_id + , subq_11.buys + FROM ( + -- Find conversions for user within the range of INF + SELECT + subq_10.ds__day + , subq_10.user + , subq_10.visit__referrer_id + , subq_10.buys + , subq_10.visits + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_9.mf_internal_uuid AS mf_internal_uuid + , subq_9.buys AS buys + FROM ( + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'ds__day', 'user'] + SELECT + subq_5.ds__day + , subq_5.user + , subq_5.visit__referrer_id + , subq_5.visits + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.visit__ds__day + , subq_4.visit__ds__week + , subq_4.visit__ds__month + , subq_4.visit__ds__quarter + , subq_4.visit__ds__year + , subq_4.visit__ds__extract_year + , subq_4.visit__ds__extract_quarter + , subq_4.visit__ds__extract_month + , subq_4.visit__ds__extract_day + , subq_4.visit__ds__extract_dow + , subq_4.visit__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.session + , subq_4.visit__user + , subq_4.visit__session + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.visits + , subq_4.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC(visits_source_src_10011.ds, day) AS ds__day + , DATE_TRUNC(visits_source_src_10011.ds, isoweek) AS ds__week + , DATE_TRUNC(visits_source_src_10011.ds, month) AS ds__month + , DATE_TRUNC(visits_source_src_10011.ds, quarter) AS ds__quarter + , DATE_TRUNC(visits_source_src_10011.ds, year) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_10011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_10011.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC(visits_source_src_10011.ds, day) AS visit__ds__day + , DATE_TRUNC(visits_source_src_10011.ds, isoweek) AS visit__ds__week + , DATE_TRUNC(visits_source_src_10011.ds, month) AS visit__ds__month + , DATE_TRUNC(visits_source_src_10011.ds, quarter) AS visit__ds__quarter + , DATE_TRUNC(visits_source_src_10011.ds, year) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_10011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_10011.ds) - 1) AS visit__ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_4 + ) subq_5 + ) subq_6 + INNER JOIN ( + -- Add column with generated UUID + 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.buy__ds__day + , subq_8.buy__ds__week + , subq_8.buy__ds__month + , subq_8.buy__ds__quarter + , subq_8.buy__ds__year + , subq_8.buy__ds__extract_year + , subq_8.buy__ds__extract_quarter + , subq_8.buy__ds__extract_month + , subq_8.buy__ds__extract_day + , subq_8.buy__ds__extract_dow + , subq_8.buy__ds__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.user + , subq_8.session_id + , subq_8.buy__user + , subq_8.buy__session_id + , subq_8.buys + , subq_8.buyers + , GENERATE_UUID() AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.buy__ds__day + , subq_7.buy__ds__week + , subq_7.buy__ds__month + , subq_7.buy__ds__quarter + , subq_7.buy__ds__year + , subq_7.buy__ds__extract_year + , subq_7.buy__ds__extract_quarter + , subq_7.buy__ds__extract_month + , subq_7.buy__ds__extract_day + , subq_7.buy__ds__extract_dow + , subq_7.buy__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.session_id + , subq_7.buy__user + , subq_7.buy__session_id + , subq_7.buys + , subq_7.buyers + FROM ( + -- Read Elements From Semantic Model 'buys_source' + SELECT + 1 AS buys + , buys_source_src_10002.user_id AS buyers + , DATE_TRUNC(buys_source_src_10002.ds, day) AS ds__day + , DATE_TRUNC(buys_source_src_10002.ds, isoweek) AS ds__week + , DATE_TRUNC(buys_source_src_10002.ds, month) AS ds__month + , DATE_TRUNC(buys_source_src_10002.ds, quarter) AS ds__quarter + , DATE_TRUNC(buys_source_src_10002.ds, year) AS ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM buys_source_src_10002.ds) = 1, 7, EXTRACT(dayofweek FROM buys_source_src_10002.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM buys_source_src_10002.ds) AS ds__extract_doy + , DATE_TRUNC(buys_source_src_10002.ds, day) AS buy__ds__day + , DATE_TRUNC(buys_source_src_10002.ds, isoweek) AS buy__ds__week + , DATE_TRUNC(buys_source_src_10002.ds, month) AS buy__ds__month + , DATE_TRUNC(buys_source_src_10002.ds, quarter) AS buy__ds__quarter + , DATE_TRUNC(buys_source_src_10002.ds, year) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS buy__ds__extract_day + , IF(EXTRACT(dayofweek FROM buys_source_src_10002.ds) = 1, 7, EXTRACT(dayofweek FROM buys_source_src_10002.ds) - 1) AS buy__ds__extract_dow + , EXTRACT(dayofyear FROM buys_source_src_10002.ds) AS buy__ds__extract_doy + , buys_source_src_10002.user_id AS user + , buys_source_src_10002.session_id + , buys_source_src_10002.user_id AS buy__user + , buys_source_src_10002.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_7 + ) subq_8 + ) subq_9 + ON + (subq_6.user = subq_9.user) AND ((subq_6.ds__day <= subq_9.ds__day)) + ) subq_10 + ) subq_11 + ) subq_12 + GROUP BY + visit__referrer_id + ) subq_13 + ON + subq_3.visit__referrer_id = subq_13.visit__referrer_id + GROUP BY + visit__referrer_id +) subq_14 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate__plan0_optimized.sql new file mode 100644 index 0000000000..861b591851 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate__plan0_optimized.sql @@ -0,0 +1,83 @@ +-- Compute Metrics via Expressions +SELECT + visit__referrer_id + , CAST(buys AS FLOAT64) / CAST(NULLIF(visits, 0) AS FLOAT64) AS visit_buy_conversion_rate +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id + , MAX(subq_18.visits) AS visits + , MAX(subq_28.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + visit__referrer_id + , SUM(visits) AS visits + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id'] + SELECT + referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_17 + GROUP BY + visit__referrer_id + ) subq_18 + FULL OUTER JOIN ( + -- Find conversions for user within the range of INF + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id'] + -- Aggregate Measures + SELECT + visit__referrer_id + , SUM(buys) AS buys + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_24.mf_internal_uuid AS mf_internal_uuid + , subq_24.buys AS buys + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'ds__day', 'user'] + SELECT + DATE_TRUNC(ds, day) AS ds__day + , user_id AS user + , referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_21 + INNER JOIN ( + -- Read Elements From Semantic Model 'buys_source' + -- Metric Time Dimension 'ds' + -- Add column with generated UUID + SELECT + DATE_TRUNC(ds, day) AS ds__day + , user_id AS user + , 1 AS buys + , GENERATE_UUID() AS mf_internal_uuid + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_24 + ON + ( + subq_21.user = subq_24.user + ) AND ( + (subq_21.ds__day <= subq_24.ds__day) + ) + ) subq_25 + GROUP BY + visit__referrer_id + ) subq_28 + ON + subq_18.visit__referrer_id = subq_28.visit__referrer_id + GROUP BY + visit__referrer_id +) subq_29 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_constant_properties__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_constant_properties__plan0.sql new file mode 100644 index 0000000000..334fd7f44c --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_constant_properties__plan0.sql @@ -0,0 +1,389 @@ +-- Compute Metrics via Expressions +SELECT + subq_14.metric_time__day + , subq_14.visit__referrer_id + , CAST(subq_14.buys AS FLOAT64) / CAST(NULLIF(subq_14.visits, 0) AS FLOAT64) AS visit_buy_conversion_rate_by_session +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) AS metric_time__day + , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id + , MAX(subq_3.visits) AS visits + , MAX(subq_13.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + subq_2.metric_time__day + , subq_2.visit__referrer_id + , SUM(subq_2.visits) AS visits + FROM ( + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'metric_time__day'] + SELECT + subq_1.metric_time__day + , subq_1.visit__referrer_id + , subq_1.visits + 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.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__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.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC(visits_source_src_10011.ds, day) AS ds__day + , DATE_TRUNC(visits_source_src_10011.ds, isoweek) AS ds__week + , DATE_TRUNC(visits_source_src_10011.ds, month) AS ds__month + , DATE_TRUNC(visits_source_src_10011.ds, quarter) AS ds__quarter + , DATE_TRUNC(visits_source_src_10011.ds, year) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_10011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_10011.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC(visits_source_src_10011.ds, day) AS visit__ds__day + , DATE_TRUNC(visits_source_src_10011.ds, isoweek) AS visit__ds__week + , DATE_TRUNC(visits_source_src_10011.ds, month) AS visit__ds__month + , DATE_TRUNC(visits_source_src_10011.ds, quarter) AS visit__ds__quarter + , DATE_TRUNC(visits_source_src_10011.ds, year) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_10011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_10011.ds) - 1) AS visit__ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_0 + ) subq_1 + ) subq_2 + GROUP BY + metric_time__day + , visit__referrer_id + ) subq_3 + FULL OUTER JOIN ( + -- Aggregate Measures + SELECT + subq_12.metric_time__day + , subq_12.visit__referrer_id + , SUM(subq_12.buys) AS buys + FROM ( + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id', 'metric_time__day'] + SELECT + subq_11.metric_time__day + , subq_11.visit__referrer_id + , subq_11.buys + FROM ( + -- Find conversions for user within the range of 7 day + SELECT + subq_10.ds__day + , subq_10.metric_time__day + , subq_10.user + , subq_10.session + , subq_10.visit__referrer_id + , subq_10.buys + , subq_10.visits + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_6.metric_time__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , first_value(subq_6.session) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session + , subq_9.mf_internal_uuid AS mf_internal_uuid + , subq_9.buys AS buys + FROM ( + -- Pass Only Elements: + -- ['visits', + -- 'visit__referrer_id', + -- 'ds__day', + -- 'metric_time__day', + -- 'user', + -- 'session'] + SELECT + subq_5.ds__day + , subq_5.metric_time__day + , subq_5.user + , subq_5.session + , subq_5.visit__referrer_id + , subq_5.visits + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.visit__ds__day + , subq_4.visit__ds__week + , subq_4.visit__ds__month + , subq_4.visit__ds__quarter + , subq_4.visit__ds__year + , subq_4.visit__ds__extract_year + , subq_4.visit__ds__extract_quarter + , subq_4.visit__ds__extract_month + , subq_4.visit__ds__extract_day + , subq_4.visit__ds__extract_dow + , subq_4.visit__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.session + , subq_4.visit__user + , subq_4.visit__session + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.visits + , subq_4.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC(visits_source_src_10011.ds, day) AS ds__day + , DATE_TRUNC(visits_source_src_10011.ds, isoweek) AS ds__week + , DATE_TRUNC(visits_source_src_10011.ds, month) AS ds__month + , DATE_TRUNC(visits_source_src_10011.ds, quarter) AS ds__quarter + , DATE_TRUNC(visits_source_src_10011.ds, year) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_10011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_10011.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC(visits_source_src_10011.ds, day) AS visit__ds__day + , DATE_TRUNC(visits_source_src_10011.ds, isoweek) AS visit__ds__week + , DATE_TRUNC(visits_source_src_10011.ds, month) AS visit__ds__month + , DATE_TRUNC(visits_source_src_10011.ds, quarter) AS visit__ds__quarter + , DATE_TRUNC(visits_source_src_10011.ds, year) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_10011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_10011.ds) - 1) AS visit__ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_4 + ) subq_5 + ) subq_6 + INNER JOIN ( + -- Add column with generated UUID + 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.buy__ds__day + , subq_8.buy__ds__week + , subq_8.buy__ds__month + , subq_8.buy__ds__quarter + , subq_8.buy__ds__year + , subq_8.buy__ds__extract_year + , subq_8.buy__ds__extract_quarter + , subq_8.buy__ds__extract_month + , subq_8.buy__ds__extract_day + , subq_8.buy__ds__extract_dow + , subq_8.buy__ds__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.user + , subq_8.session_id + , subq_8.buy__user + , subq_8.buy__session_id + , subq_8.buys + , subq_8.buyers + , GENERATE_UUID() AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.buy__ds__day + , subq_7.buy__ds__week + , subq_7.buy__ds__month + , subq_7.buy__ds__quarter + , subq_7.buy__ds__year + , subq_7.buy__ds__extract_year + , subq_7.buy__ds__extract_quarter + , subq_7.buy__ds__extract_month + , subq_7.buy__ds__extract_day + , subq_7.buy__ds__extract_dow + , subq_7.buy__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.session_id + , subq_7.buy__user + , subq_7.buy__session_id + , subq_7.buys + , subq_7.buyers + FROM ( + -- Read Elements From Semantic Model 'buys_source' + SELECT + 1 AS buys + , buys_source_src_10002.user_id AS buyers + , DATE_TRUNC(buys_source_src_10002.ds, day) AS ds__day + , DATE_TRUNC(buys_source_src_10002.ds, isoweek) AS ds__week + , DATE_TRUNC(buys_source_src_10002.ds, month) AS ds__month + , DATE_TRUNC(buys_source_src_10002.ds, quarter) AS ds__quarter + , DATE_TRUNC(buys_source_src_10002.ds, year) AS ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM buys_source_src_10002.ds) = 1, 7, EXTRACT(dayofweek FROM buys_source_src_10002.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM buys_source_src_10002.ds) AS ds__extract_doy + , DATE_TRUNC(buys_source_src_10002.ds, day) AS buy__ds__day + , DATE_TRUNC(buys_source_src_10002.ds, isoweek) AS buy__ds__week + , DATE_TRUNC(buys_source_src_10002.ds, month) AS buy__ds__month + , DATE_TRUNC(buys_source_src_10002.ds, quarter) AS buy__ds__quarter + , DATE_TRUNC(buys_source_src_10002.ds, year) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS buy__ds__extract_day + , IF(EXTRACT(dayofweek FROM buys_source_src_10002.ds) = 1, 7, EXTRACT(dayofweek FROM buys_source_src_10002.ds) - 1) AS buy__ds__extract_dow + , EXTRACT(dayofyear FROM buys_source_src_10002.ds) AS buy__ds__extract_doy + , buys_source_src_10002.user_id AS user + , buys_source_src_10002.session_id + , buys_source_src_10002.user_id AS buy__user + , buys_source_src_10002.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_7 + ) subq_8 + ) subq_9 + ON + ( + subq_6.user = subq_9.user + ) AND ( + subq_6.session = subq_9.session_id + ) AND ( + ( + subq_6.ds__day <= subq_9.ds__day + ) AND ( + subq_6.ds__day > DATE_SUB(CAST(subq_9.ds__day AS DATETIME), INTERVAL 7 day) + ) + ) + ) subq_10 + ) subq_11 + ) subq_12 + GROUP BY + metric_time__day + , visit__referrer_id + ) subq_13 + ON + ( + subq_3.visit__referrer_id = subq_13.visit__referrer_id + ) AND ( + subq_3.metric_time__day = subq_13.metric_time__day + ) + GROUP BY + metric_time__day + , visit__referrer_id +) subq_14 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_constant_properties__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_constant_properties__plan0_optimized.sql new file mode 100644 index 0000000000..15eff91d32 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_constant_properties__plan0_optimized.sql @@ -0,0 +1,111 @@ +-- Compute Metrics via Expressions +SELECT + metric_time__day + , visit__referrer_id + , CAST(buys AS FLOAT64) / CAST(NULLIF(visits, 0) AS FLOAT64) AS visit_buy_conversion_rate_by_session +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id + , MAX(subq_18.visits) AS visits + , MAX(subq_28.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + metric_time__day + , visit__referrer_id + , SUM(visits) AS visits + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'metric_time__day'] + SELECT + DATE_TRUNC(ds, day) AS metric_time__day + , referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_17 + GROUP BY + metric_time__day + , visit__referrer_id + ) subq_18 + FULL OUTER JOIN ( + -- Find conversions for user within the range of 7 day + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id', 'metric_time__day'] + -- Aggregate Measures + SELECT + metric_time__day + , visit__referrer_id + , SUM(buys) AS buys + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_21.metric_time__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , first_value(subq_21.session) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session + , subq_24.mf_internal_uuid AS mf_internal_uuid + , subq_24.buys AS buys + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', + -- 'visit__referrer_id', + -- 'ds__day', + -- 'metric_time__day', + -- 'user', + -- 'session'] + SELECT + DATE_TRUNC(ds, day) AS ds__day + , DATE_TRUNC(ds, day) AS metric_time__day + , user_id AS user + , session_id AS session + , referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_21 + INNER JOIN ( + -- Read Elements From Semantic Model 'buys_source' + -- Metric Time Dimension 'ds' + -- Add column with generated UUID + SELECT + DATE_TRUNC(ds, day) AS ds__day + , user_id AS user + , session_id + , 1 AS buys + , GENERATE_UUID() AS mf_internal_uuid + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_24 + ON + ( + subq_21.user = subq_24.user + ) AND ( + subq_21.session = subq_24.session_id + ) AND ( + ( + subq_21.ds__day <= subq_24.ds__day + ) AND ( + subq_21.ds__day > DATE_SUB(CAST(subq_24.ds__day AS DATETIME), INTERVAL 7 day) + ) + ) + ) subq_25 + GROUP BY + metric_time__day + , visit__referrer_id + ) subq_28 + ON + ( + subq_18.visit__referrer_id = subq_28.visit__referrer_id + ) AND ( + subq_18.metric_time__day = subq_28.metric_time__day + ) + GROUP BY + metric_time__day + , visit__referrer_id +) subq_29 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_no_group_by__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_no_group_by__plan0.sql new file mode 100644 index 0000000000..1908eb47a9 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_no_group_by__plan0.sql @@ -0,0 +1,346 @@ +-- Compute Metrics via Expressions +SELECT + CAST(subq_14.buys AS FLOAT64) / CAST(NULLIF(subq_14.visits, 0) AS FLOAT64) AS visit_buy_conversion_rate_7days +FROM ( + -- Combine Aggregated Outputs + SELECT + MAX(subq_3.visits) AS visits + , MAX(subq_13.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + SUM(subq_2.visits) AS visits + FROM ( + -- Pass Only Elements: + -- ['visits'] + SELECT + subq_1.visits + 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.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__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.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC(visits_source_src_10011.ds, day) AS ds__day + , DATE_TRUNC(visits_source_src_10011.ds, isoweek) AS ds__week + , DATE_TRUNC(visits_source_src_10011.ds, month) AS ds__month + , DATE_TRUNC(visits_source_src_10011.ds, quarter) AS ds__quarter + , DATE_TRUNC(visits_source_src_10011.ds, year) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_10011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_10011.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC(visits_source_src_10011.ds, day) AS visit__ds__day + , DATE_TRUNC(visits_source_src_10011.ds, isoweek) AS visit__ds__week + , DATE_TRUNC(visits_source_src_10011.ds, month) AS visit__ds__month + , DATE_TRUNC(visits_source_src_10011.ds, quarter) AS visit__ds__quarter + , DATE_TRUNC(visits_source_src_10011.ds, year) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_10011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_10011.ds) - 1) AS visit__ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_0 + ) subq_1 + ) subq_2 + ) subq_3 + CROSS JOIN ( + -- Aggregate Measures + SELECT + SUM(subq_12.buys) AS buys + FROM ( + -- Pass Only Elements: + -- ['buys'] + SELECT + subq_11.buys + FROM ( + -- Find conversions for user within the range of 7 day + SELECT + subq_10.ds__day + , subq_10.user + , subq_10.buys + , subq_10.visits + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_9.mf_internal_uuid AS mf_internal_uuid + , subq_9.buys AS buys + FROM ( + -- Pass Only Elements: + -- ['visits', 'ds__day', 'user'] + SELECT + subq_5.ds__day + , subq_5.user + , subq_5.visits + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.visit__ds__day + , subq_4.visit__ds__week + , subq_4.visit__ds__month + , subq_4.visit__ds__quarter + , subq_4.visit__ds__year + , subq_4.visit__ds__extract_year + , subq_4.visit__ds__extract_quarter + , subq_4.visit__ds__extract_month + , subq_4.visit__ds__extract_day + , subq_4.visit__ds__extract_dow + , subq_4.visit__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.session + , subq_4.visit__user + , subq_4.visit__session + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.visits + , subq_4.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC(visits_source_src_10011.ds, day) AS ds__day + , DATE_TRUNC(visits_source_src_10011.ds, isoweek) AS ds__week + , DATE_TRUNC(visits_source_src_10011.ds, month) AS ds__month + , DATE_TRUNC(visits_source_src_10011.ds, quarter) AS ds__quarter + , DATE_TRUNC(visits_source_src_10011.ds, year) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_10011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_10011.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC(visits_source_src_10011.ds, day) AS visit__ds__day + , DATE_TRUNC(visits_source_src_10011.ds, isoweek) AS visit__ds__week + , DATE_TRUNC(visits_source_src_10011.ds, month) AS visit__ds__month + , DATE_TRUNC(visits_source_src_10011.ds, quarter) AS visit__ds__quarter + , DATE_TRUNC(visits_source_src_10011.ds, year) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_10011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_10011.ds) - 1) AS visit__ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_4 + ) subq_5 + ) subq_6 + INNER JOIN ( + -- Add column with generated UUID + 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.buy__ds__day + , subq_8.buy__ds__week + , subq_8.buy__ds__month + , subq_8.buy__ds__quarter + , subq_8.buy__ds__year + , subq_8.buy__ds__extract_year + , subq_8.buy__ds__extract_quarter + , subq_8.buy__ds__extract_month + , subq_8.buy__ds__extract_day + , subq_8.buy__ds__extract_dow + , subq_8.buy__ds__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.user + , subq_8.session_id + , subq_8.buy__user + , subq_8.buy__session_id + , subq_8.buys + , subq_8.buyers + , GENERATE_UUID() AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.buy__ds__day + , subq_7.buy__ds__week + , subq_7.buy__ds__month + , subq_7.buy__ds__quarter + , subq_7.buy__ds__year + , subq_7.buy__ds__extract_year + , subq_7.buy__ds__extract_quarter + , subq_7.buy__ds__extract_month + , subq_7.buy__ds__extract_day + , subq_7.buy__ds__extract_dow + , subq_7.buy__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.session_id + , subq_7.buy__user + , subq_7.buy__session_id + , subq_7.buys + , subq_7.buyers + FROM ( + -- Read Elements From Semantic Model 'buys_source' + SELECT + 1 AS buys + , buys_source_src_10002.user_id AS buyers + , DATE_TRUNC(buys_source_src_10002.ds, day) AS ds__day + , DATE_TRUNC(buys_source_src_10002.ds, isoweek) AS ds__week + , DATE_TRUNC(buys_source_src_10002.ds, month) AS ds__month + , DATE_TRUNC(buys_source_src_10002.ds, quarter) AS ds__quarter + , DATE_TRUNC(buys_source_src_10002.ds, year) AS ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM buys_source_src_10002.ds) = 1, 7, EXTRACT(dayofweek FROM buys_source_src_10002.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM buys_source_src_10002.ds) AS ds__extract_doy + , DATE_TRUNC(buys_source_src_10002.ds, day) AS buy__ds__day + , DATE_TRUNC(buys_source_src_10002.ds, isoweek) AS buy__ds__week + , DATE_TRUNC(buys_source_src_10002.ds, month) AS buy__ds__month + , DATE_TRUNC(buys_source_src_10002.ds, quarter) AS buy__ds__quarter + , DATE_TRUNC(buys_source_src_10002.ds, year) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS buy__ds__extract_day + , IF(EXTRACT(dayofweek FROM buys_source_src_10002.ds) = 1, 7, EXTRACT(dayofweek FROM buys_source_src_10002.ds) - 1) AS buy__ds__extract_dow + , EXTRACT(dayofyear FROM buys_source_src_10002.ds) AS buy__ds__extract_doy + , buys_source_src_10002.user_id AS user + , buys_source_src_10002.session_id + , buys_source_src_10002.user_id AS buy__user + , buys_source_src_10002.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_7 + ) subq_8 + ) subq_9 + ON + ( + subq_6.user = subq_9.user + ) AND ( + ( + subq_6.ds__day <= subq_9.ds__day + ) AND ( + subq_6.ds__day > DATE_SUB(CAST(subq_9.ds__day AS DATETIME), INTERVAL 7 day) + ) + ) + ) subq_10 + ) subq_11 + ) subq_12 + ) subq_13 +) subq_14 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_no_group_by__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_no_group_by__plan0_optimized.sql new file mode 100644 index 0000000000..95bd1d3d04 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_no_group_by__plan0_optimized.sql @@ -0,0 +1,63 @@ +-- Combine Aggregated Outputs +-- Compute Metrics via Expressions +SELECT + CAST(MAX(subq_28.buys) AS FLOAT64) / CAST(NULLIF(MAX(subq_18.visits), 0) AS FLOAT64) AS visit_buy_conversion_rate_7days +FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits'] + -- Aggregate Measures + SELECT + SUM(1) AS visits + FROM ***************************.fct_visits visits_source_src_10011 +) subq_18 +CROSS JOIN ( + -- Find conversions for user within the range of 7 day + -- Pass Only Elements: + -- ['buys'] + -- Aggregate Measures + SELECT + SUM(buys) AS buys + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_24.mf_internal_uuid AS mf_internal_uuid + , subq_24.buys AS buys + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'ds__day', 'user'] + SELECT + DATE_TRUNC(ds, day) AS ds__day + , user_id AS user + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_21 + INNER JOIN ( + -- Read Elements From Semantic Model 'buys_source' + -- Metric Time Dimension 'ds' + -- Add column with generated UUID + SELECT + DATE_TRUNC(ds, day) AS ds__day + , user_id AS user + , 1 AS buys + , GENERATE_UUID() AS mf_internal_uuid + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_24 + ON + ( + subq_21.user = subq_24.user + ) AND ( + ( + subq_21.ds__day <= subq_24.ds__day + ) AND ( + subq_21.ds__day > DATE_SUB(CAST(subq_24.ds__day AS DATETIME), INTERVAL 7 day) + ) + ) + ) subq_25 +) subq_28 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_window__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_window__plan0.sql new file mode 100644 index 0000000000..4bcbd18091 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_window__plan0.sql @@ -0,0 +1,379 @@ +-- Compute Metrics via Expressions +SELECT + subq_14.metric_time__day + , subq_14.visit__referrer_id + , CAST(subq_14.buys AS FLOAT64) / CAST(NULLIF(subq_14.visits, 0) AS FLOAT64) AS visit_buy_conversion_rate_7days +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) AS metric_time__day + , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id + , MAX(subq_3.visits) AS visits + , MAX(subq_13.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + subq_2.metric_time__day + , subq_2.visit__referrer_id + , SUM(subq_2.visits) AS visits + FROM ( + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'metric_time__day'] + SELECT + subq_1.metric_time__day + , subq_1.visit__referrer_id + , subq_1.visits + 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.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__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.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC(visits_source_src_10011.ds, day) AS ds__day + , DATE_TRUNC(visits_source_src_10011.ds, isoweek) AS ds__week + , DATE_TRUNC(visits_source_src_10011.ds, month) AS ds__month + , DATE_TRUNC(visits_source_src_10011.ds, quarter) AS ds__quarter + , DATE_TRUNC(visits_source_src_10011.ds, year) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_10011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_10011.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC(visits_source_src_10011.ds, day) AS visit__ds__day + , DATE_TRUNC(visits_source_src_10011.ds, isoweek) AS visit__ds__week + , DATE_TRUNC(visits_source_src_10011.ds, month) AS visit__ds__month + , DATE_TRUNC(visits_source_src_10011.ds, quarter) AS visit__ds__quarter + , DATE_TRUNC(visits_source_src_10011.ds, year) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_10011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_10011.ds) - 1) AS visit__ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_0 + ) subq_1 + ) subq_2 + GROUP BY + metric_time__day + , visit__referrer_id + ) subq_3 + FULL OUTER JOIN ( + -- Aggregate Measures + SELECT + subq_12.metric_time__day + , subq_12.visit__referrer_id + , SUM(subq_12.buys) AS buys + FROM ( + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id', 'metric_time__day'] + SELECT + subq_11.metric_time__day + , subq_11.visit__referrer_id + , subq_11.buys + FROM ( + -- Find conversions for user within the range of 7 day + SELECT + subq_10.ds__day + , subq_10.metric_time__day + , subq_10.user + , subq_10.visit__referrer_id + , subq_10.buys + , subq_10.visits + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_6.metric_time__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_9.mf_internal_uuid AS mf_internal_uuid + , subq_9.buys AS buys + FROM ( + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user'] + SELECT + subq_5.ds__day + , subq_5.metric_time__day + , subq_5.user + , subq_5.visit__referrer_id + , subq_5.visits + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.visit__ds__day + , subq_4.visit__ds__week + , subq_4.visit__ds__month + , subq_4.visit__ds__quarter + , subq_4.visit__ds__year + , subq_4.visit__ds__extract_year + , subq_4.visit__ds__extract_quarter + , subq_4.visit__ds__extract_month + , subq_4.visit__ds__extract_day + , subq_4.visit__ds__extract_dow + , subq_4.visit__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.session + , subq_4.visit__user + , subq_4.visit__session + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.visits + , subq_4.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC(visits_source_src_10011.ds, day) AS ds__day + , DATE_TRUNC(visits_source_src_10011.ds, isoweek) AS ds__week + , DATE_TRUNC(visits_source_src_10011.ds, month) AS ds__month + , DATE_TRUNC(visits_source_src_10011.ds, quarter) AS ds__quarter + , DATE_TRUNC(visits_source_src_10011.ds, year) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_10011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_10011.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC(visits_source_src_10011.ds, day) AS visit__ds__day + , DATE_TRUNC(visits_source_src_10011.ds, isoweek) AS visit__ds__week + , DATE_TRUNC(visits_source_src_10011.ds, month) AS visit__ds__month + , DATE_TRUNC(visits_source_src_10011.ds, quarter) AS visit__ds__quarter + , DATE_TRUNC(visits_source_src_10011.ds, year) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_10011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_10011.ds) - 1) AS visit__ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_4 + ) subq_5 + ) subq_6 + INNER JOIN ( + -- Add column with generated UUID + 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.buy__ds__day + , subq_8.buy__ds__week + , subq_8.buy__ds__month + , subq_8.buy__ds__quarter + , subq_8.buy__ds__year + , subq_8.buy__ds__extract_year + , subq_8.buy__ds__extract_quarter + , subq_8.buy__ds__extract_month + , subq_8.buy__ds__extract_day + , subq_8.buy__ds__extract_dow + , subq_8.buy__ds__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.user + , subq_8.session_id + , subq_8.buy__user + , subq_8.buy__session_id + , subq_8.buys + , subq_8.buyers + , GENERATE_UUID() AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.buy__ds__day + , subq_7.buy__ds__week + , subq_7.buy__ds__month + , subq_7.buy__ds__quarter + , subq_7.buy__ds__year + , subq_7.buy__ds__extract_year + , subq_7.buy__ds__extract_quarter + , subq_7.buy__ds__extract_month + , subq_7.buy__ds__extract_day + , subq_7.buy__ds__extract_dow + , subq_7.buy__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.session_id + , subq_7.buy__user + , subq_7.buy__session_id + , subq_7.buys + , subq_7.buyers + FROM ( + -- Read Elements From Semantic Model 'buys_source' + SELECT + 1 AS buys + , buys_source_src_10002.user_id AS buyers + , DATE_TRUNC(buys_source_src_10002.ds, day) AS ds__day + , DATE_TRUNC(buys_source_src_10002.ds, isoweek) AS ds__week + , DATE_TRUNC(buys_source_src_10002.ds, month) AS ds__month + , DATE_TRUNC(buys_source_src_10002.ds, quarter) AS ds__quarter + , DATE_TRUNC(buys_source_src_10002.ds, year) AS ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM buys_source_src_10002.ds) = 1, 7, EXTRACT(dayofweek FROM buys_source_src_10002.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM buys_source_src_10002.ds) AS ds__extract_doy + , DATE_TRUNC(buys_source_src_10002.ds, day) AS buy__ds__day + , DATE_TRUNC(buys_source_src_10002.ds, isoweek) AS buy__ds__week + , DATE_TRUNC(buys_source_src_10002.ds, month) AS buy__ds__month + , DATE_TRUNC(buys_source_src_10002.ds, quarter) AS buy__ds__quarter + , DATE_TRUNC(buys_source_src_10002.ds, year) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS buy__ds__extract_day + , IF(EXTRACT(dayofweek FROM buys_source_src_10002.ds) = 1, 7, EXTRACT(dayofweek FROM buys_source_src_10002.ds) - 1) AS buy__ds__extract_dow + , EXTRACT(dayofyear FROM buys_source_src_10002.ds) AS buy__ds__extract_doy + , buys_source_src_10002.user_id AS user + , buys_source_src_10002.session_id + , buys_source_src_10002.user_id AS buy__user + , buys_source_src_10002.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_7 + ) subq_8 + ) subq_9 + ON + ( + subq_6.user = subq_9.user + ) AND ( + ( + subq_6.ds__day <= subq_9.ds__day + ) AND ( + subq_6.ds__day > DATE_SUB(CAST(subq_9.ds__day AS DATETIME), INTERVAL 7 day) + ) + ) + ) subq_10 + ) subq_11 + ) subq_12 + GROUP BY + metric_time__day + , visit__referrer_id + ) subq_13 + ON + ( + subq_3.visit__referrer_id = subq_13.visit__referrer_id + ) AND ( + subq_3.metric_time__day = subq_13.metric_time__day + ) + GROUP BY + metric_time__day + , visit__referrer_id +) subq_14 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_window__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_window__plan0_optimized.sql new file mode 100644 index 0000000000..41e5ea2dbe --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_window__plan0_optimized.sql @@ -0,0 +1,101 @@ +-- Compute Metrics via Expressions +SELECT + metric_time__day + , visit__referrer_id + , CAST(buys AS FLOAT64) / CAST(NULLIF(visits, 0) AS FLOAT64) AS visit_buy_conversion_rate_7days +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id + , MAX(subq_18.visits) AS visits + , MAX(subq_28.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + metric_time__day + , visit__referrer_id + , SUM(visits) AS visits + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'metric_time__day'] + SELECT + DATE_TRUNC(ds, day) AS metric_time__day + , referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_17 + GROUP BY + metric_time__day + , visit__referrer_id + ) subq_18 + FULL OUTER JOIN ( + -- Find conversions for user within the range of 7 day + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id', 'metric_time__day'] + -- Aggregate Measures + SELECT + metric_time__day + , visit__referrer_id + , SUM(buys) AS buys + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_21.metric_time__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_24.mf_internal_uuid AS mf_internal_uuid + , subq_24.buys AS buys + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user'] + SELECT + DATE_TRUNC(ds, day) AS ds__day + , DATE_TRUNC(ds, day) AS metric_time__day + , user_id AS user + , referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_21 + INNER JOIN ( + -- Read Elements From Semantic Model 'buys_source' + -- Metric Time Dimension 'ds' + -- Add column with generated UUID + SELECT + DATE_TRUNC(ds, day) AS ds__day + , user_id AS user + , 1 AS buys + , GENERATE_UUID() AS mf_internal_uuid + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_24 + ON + ( + subq_21.user = subq_24.user + ) AND ( + ( + subq_21.ds__day <= subq_24.ds__day + ) AND ( + subq_21.ds__day > DATE_SUB(CAST(subq_24.ds__day AS DATETIME), INTERVAL 7 day) + ) + ) + ) subq_25 + GROUP BY + metric_time__day + , visit__referrer_id + ) subq_28 + ON + ( + subq_18.visit__referrer_id = subq_28.visit__referrer_id + ) AND ( + subq_18.metric_time__day = subq_28.metric_time__day + ) + GROUP BY + metric_time__day + , visit__referrer_id +) subq_29 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_count_with_no_group_by__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_count_with_no_group_by__plan0.sql new file mode 100644 index 0000000000..ad0d2d86e4 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_count_with_no_group_by__plan0.sql @@ -0,0 +1,346 @@ +-- Compute Metrics via Expressions +SELECT + subq_14.buys AS visit_buy_conversions +FROM ( + -- Combine Aggregated Outputs + SELECT + MAX(subq_3.visits) AS visits + , COALESCE(MAX(subq_13.buys), 0) AS buys + FROM ( + -- Aggregate Measures + SELECT + SUM(subq_2.visits) AS visits + FROM ( + -- Pass Only Elements: + -- ['visits'] + SELECT + subq_1.visits + 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.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__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.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_0 + ) subq_1 + ) subq_2 + ) subq_3 + CROSS JOIN ( + -- Aggregate Measures + SELECT + SUM(subq_12.buys) AS buys + FROM ( + -- Pass Only Elements: + -- ['buys'] + SELECT + subq_11.buys + FROM ( + -- Find conversions for user within the range of 7 day + SELECT + subq_10.ds__day + , subq_10.user + , subq_10.buys + , subq_10.visits + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_9.mf_internal_uuid AS mf_internal_uuid + , subq_9.buys AS buys + FROM ( + -- Pass Only Elements: + -- ['visits', 'ds__day', 'user'] + SELECT + subq_5.ds__day + , subq_5.user + , subq_5.visits + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.visit__ds__day + , subq_4.visit__ds__week + , subq_4.visit__ds__month + , subq_4.visit__ds__quarter + , subq_4.visit__ds__year + , subq_4.visit__ds__extract_year + , subq_4.visit__ds__extract_quarter + , subq_4.visit__ds__extract_month + , subq_4.visit__ds__extract_day + , subq_4.visit__ds__extract_dow + , subq_4.visit__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.session + , subq_4.visit__user + , subq_4.visit__session + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.visits + , subq_4.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_4 + ) subq_5 + ) subq_6 + INNER JOIN ( + -- Add column with generated UUID + 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.buy__ds__day + , subq_8.buy__ds__week + , subq_8.buy__ds__month + , subq_8.buy__ds__quarter + , subq_8.buy__ds__year + , subq_8.buy__ds__extract_year + , subq_8.buy__ds__extract_quarter + , subq_8.buy__ds__extract_month + , subq_8.buy__ds__extract_day + , subq_8.buy__ds__extract_dow + , subq_8.buy__ds__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.user + , subq_8.session_id + , subq_8.buy__user + , subq_8.buy__session_id + , subq_8.buys + , subq_8.buyers + , UUID() AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.buy__ds__day + , subq_7.buy__ds__week + , subq_7.buy__ds__month + , subq_7.buy__ds__quarter + , subq_7.buy__ds__year + , subq_7.buy__ds__extract_year + , subq_7.buy__ds__extract_quarter + , subq_7.buy__ds__extract_month + , subq_7.buy__ds__extract_day + , subq_7.buy__ds__extract_dow + , subq_7.buy__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.session_id + , subq_7.buy__user + , subq_7.buy__session_id + , subq_7.buys + , subq_7.buyers + FROM ( + -- Read Elements From Semantic Model 'buys_source' + SELECT + 1 AS buys + , buys_source_src_10002.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_10002.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM buys_source_src_10002.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_10002.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS buy__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM buys_source_src_10002.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS buy__ds__extract_doy + , buys_source_src_10002.user_id AS user + , buys_source_src_10002.session_id + , buys_source_src_10002.user_id AS buy__user + , buys_source_src_10002.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_7 + ) subq_8 + ) subq_9 + ON + ( + subq_6.user = subq_9.user + ) AND ( + ( + subq_6.ds__day <= subq_9.ds__day + ) AND ( + subq_6.ds__day > DATEADD(day, -7, subq_9.ds__day) + ) + ) + ) subq_10 + ) subq_11 + ) subq_12 + ) subq_13 +) subq_14 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_count_with_no_group_by__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_count_with_no_group_by__plan0_optimized.sql new file mode 100644 index 0000000000..d4297cb415 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_count_with_no_group_by__plan0_optimized.sql @@ -0,0 +1,63 @@ +-- Combine Aggregated Outputs +-- Compute Metrics via Expressions +SELECT + COALESCE(MAX(subq_28.buys), 0) AS visit_buy_conversions +FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits'] + -- Aggregate Measures + SELECT + SUM(1) AS visits + FROM ***************************.fct_visits visits_source_src_10011 +) subq_18 +CROSS JOIN ( + -- Find conversions for user within the range of 7 day + -- Pass Only Elements: + -- ['buys'] + -- Aggregate Measures + SELECT + SUM(buys) AS buys + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_24.mf_internal_uuid AS mf_internal_uuid + , subq_24.buys AS buys + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'ds__day', 'user'] + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_21 + INNER JOIN ( + -- Read Elements From Semantic Model 'buys_source' + -- Metric Time Dimension 'ds' + -- Add column with generated UUID + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , 1 AS buys + , UUID() AS mf_internal_uuid + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_24 + ON + ( + subq_21.user = subq_24.user + ) AND ( + ( + subq_21.ds__day <= subq_24.ds__day + ) AND ( + subq_21.ds__day > DATEADD(day, -7, subq_24.ds__day) + ) + ) + ) subq_25 +) subq_28 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate__plan0.sql new file mode 100644 index 0000000000..80a2f409ec --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate__plan0.sql @@ -0,0 +1,355 @@ +-- Compute Metrics via Expressions +SELECT + subq_14.visit__referrer_id + , CAST(subq_14.buys AS DOUBLE) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id + , MAX(subq_3.visits) AS visits + , MAX(subq_13.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + subq_2.visit__referrer_id + , SUM(subq_2.visits) AS visits + FROM ( + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id'] + SELECT + subq_1.visit__referrer_id + , subq_1.visits + 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.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__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.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_0 + ) subq_1 + ) subq_2 + GROUP BY + subq_2.visit__referrer_id + ) subq_3 + FULL OUTER JOIN ( + -- Aggregate Measures + SELECT + subq_12.visit__referrer_id + , SUM(subq_12.buys) AS buys + FROM ( + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id'] + SELECT + subq_11.visit__referrer_id + , subq_11.buys + FROM ( + -- Find conversions for user within the range of INF + SELECT + subq_10.ds__day + , subq_10.user + , subq_10.visit__referrer_id + , subq_10.buys + , subq_10.visits + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_9.mf_internal_uuid AS mf_internal_uuid + , subq_9.buys AS buys + FROM ( + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'ds__day', 'user'] + SELECT + subq_5.ds__day + , subq_5.user + , subq_5.visit__referrer_id + , subq_5.visits + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.visit__ds__day + , subq_4.visit__ds__week + , subq_4.visit__ds__month + , subq_4.visit__ds__quarter + , subq_4.visit__ds__year + , subq_4.visit__ds__extract_year + , subq_4.visit__ds__extract_quarter + , subq_4.visit__ds__extract_month + , subq_4.visit__ds__extract_day + , subq_4.visit__ds__extract_dow + , subq_4.visit__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.session + , subq_4.visit__user + , subq_4.visit__session + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.visits + , subq_4.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_4 + ) subq_5 + ) subq_6 + INNER JOIN ( + -- Add column with generated UUID + 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.buy__ds__day + , subq_8.buy__ds__week + , subq_8.buy__ds__month + , subq_8.buy__ds__quarter + , subq_8.buy__ds__year + , subq_8.buy__ds__extract_year + , subq_8.buy__ds__extract_quarter + , subq_8.buy__ds__extract_month + , subq_8.buy__ds__extract_day + , subq_8.buy__ds__extract_dow + , subq_8.buy__ds__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.user + , subq_8.session_id + , subq_8.buy__user + , subq_8.buy__session_id + , subq_8.buys + , subq_8.buyers + , UUID() AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.buy__ds__day + , subq_7.buy__ds__week + , subq_7.buy__ds__month + , subq_7.buy__ds__quarter + , subq_7.buy__ds__year + , subq_7.buy__ds__extract_year + , subq_7.buy__ds__extract_quarter + , subq_7.buy__ds__extract_month + , subq_7.buy__ds__extract_day + , subq_7.buy__ds__extract_dow + , subq_7.buy__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.session_id + , subq_7.buy__user + , subq_7.buy__session_id + , subq_7.buys + , subq_7.buyers + FROM ( + -- Read Elements From Semantic Model 'buys_source' + SELECT + 1 AS buys + , buys_source_src_10002.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_10002.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM buys_source_src_10002.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_10002.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS buy__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM buys_source_src_10002.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS buy__ds__extract_doy + , buys_source_src_10002.user_id AS user + , buys_source_src_10002.session_id + , buys_source_src_10002.user_id AS buy__user + , buys_source_src_10002.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_7 + ) subq_8 + ) subq_9 + ON + (subq_6.user = subq_9.user) AND ((subq_6.ds__day <= subq_9.ds__day)) + ) subq_10 + ) subq_11 + ) subq_12 + GROUP BY + subq_12.visit__referrer_id + ) subq_13 + ON + subq_3.visit__referrer_id = subq_13.visit__referrer_id + GROUP BY + COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) +) subq_14 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate__plan0_optimized.sql new file mode 100644 index 0000000000..607ef8de7a --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate__plan0_optimized.sql @@ -0,0 +1,83 @@ +-- Compute Metrics via Expressions +SELECT + visit__referrer_id + , CAST(buys AS DOUBLE) / CAST(NULLIF(visits, 0) AS DOUBLE) AS visit_buy_conversion_rate +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id + , MAX(subq_18.visits) AS visits + , MAX(subq_28.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + visit__referrer_id + , SUM(visits) AS visits + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id'] + SELECT + referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_17 + GROUP BY + visit__referrer_id + ) subq_18 + FULL OUTER JOIN ( + -- Find conversions for user within the range of INF + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id'] + -- Aggregate Measures + SELECT + visit__referrer_id + , SUM(buys) AS buys + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_24.mf_internal_uuid AS mf_internal_uuid + , subq_24.buys AS buys + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'ds__day', 'user'] + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_21 + INNER JOIN ( + -- Read Elements From Semantic Model 'buys_source' + -- Metric Time Dimension 'ds' + -- Add column with generated UUID + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , 1 AS buys + , UUID() AS mf_internal_uuid + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_24 + ON + ( + subq_21.user = subq_24.user + ) AND ( + (subq_21.ds__day <= subq_24.ds__day) + ) + ) subq_25 + GROUP BY + visit__referrer_id + ) subq_28 + ON + subq_18.visit__referrer_id = subq_28.visit__referrer_id + GROUP BY + COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) +) subq_29 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_constant_properties__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_constant_properties__plan0.sql new file mode 100644 index 0000000000..810dce6a94 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_constant_properties__plan0.sql @@ -0,0 +1,389 @@ +-- Compute Metrics via Expressions +SELECT + subq_14.metric_time__day + , subq_14.visit__referrer_id + , CAST(subq_14.buys AS DOUBLE) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_by_session +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) AS metric_time__day + , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id + , MAX(subq_3.visits) AS visits + , MAX(subq_13.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + subq_2.metric_time__day + , subq_2.visit__referrer_id + , SUM(subq_2.visits) AS visits + FROM ( + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'metric_time__day'] + SELECT + subq_1.metric_time__day + , subq_1.visit__referrer_id + , subq_1.visits + 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.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__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.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_0 + ) subq_1 + ) subq_2 + GROUP BY + subq_2.metric_time__day + , subq_2.visit__referrer_id + ) subq_3 + FULL OUTER JOIN ( + -- Aggregate Measures + SELECT + subq_12.metric_time__day + , subq_12.visit__referrer_id + , SUM(subq_12.buys) AS buys + FROM ( + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id', 'metric_time__day'] + SELECT + subq_11.metric_time__day + , subq_11.visit__referrer_id + , subq_11.buys + FROM ( + -- Find conversions for user within the range of 7 day + SELECT + subq_10.ds__day + , subq_10.metric_time__day + , subq_10.user + , subq_10.session + , subq_10.visit__referrer_id + , subq_10.buys + , subq_10.visits + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_6.metric_time__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , first_value(subq_6.session) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session + , subq_9.mf_internal_uuid AS mf_internal_uuid + , subq_9.buys AS buys + FROM ( + -- Pass Only Elements: + -- ['visits', + -- 'visit__referrer_id', + -- 'ds__day', + -- 'metric_time__day', + -- 'user', + -- 'session'] + SELECT + subq_5.ds__day + , subq_5.metric_time__day + , subq_5.user + , subq_5.session + , subq_5.visit__referrer_id + , subq_5.visits + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.visit__ds__day + , subq_4.visit__ds__week + , subq_4.visit__ds__month + , subq_4.visit__ds__quarter + , subq_4.visit__ds__year + , subq_4.visit__ds__extract_year + , subq_4.visit__ds__extract_quarter + , subq_4.visit__ds__extract_month + , subq_4.visit__ds__extract_day + , subq_4.visit__ds__extract_dow + , subq_4.visit__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.session + , subq_4.visit__user + , subq_4.visit__session + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.visits + , subq_4.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_4 + ) subq_5 + ) subq_6 + INNER JOIN ( + -- Add column with generated UUID + 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.buy__ds__day + , subq_8.buy__ds__week + , subq_8.buy__ds__month + , subq_8.buy__ds__quarter + , subq_8.buy__ds__year + , subq_8.buy__ds__extract_year + , subq_8.buy__ds__extract_quarter + , subq_8.buy__ds__extract_month + , subq_8.buy__ds__extract_day + , subq_8.buy__ds__extract_dow + , subq_8.buy__ds__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.user + , subq_8.session_id + , subq_8.buy__user + , subq_8.buy__session_id + , subq_8.buys + , subq_8.buyers + , UUID() AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.buy__ds__day + , subq_7.buy__ds__week + , subq_7.buy__ds__month + , subq_7.buy__ds__quarter + , subq_7.buy__ds__year + , subq_7.buy__ds__extract_year + , subq_7.buy__ds__extract_quarter + , subq_7.buy__ds__extract_month + , subq_7.buy__ds__extract_day + , subq_7.buy__ds__extract_dow + , subq_7.buy__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.session_id + , subq_7.buy__user + , subq_7.buy__session_id + , subq_7.buys + , subq_7.buyers + FROM ( + -- Read Elements From Semantic Model 'buys_source' + SELECT + 1 AS buys + , buys_source_src_10002.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_10002.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM buys_source_src_10002.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_10002.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS buy__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM buys_source_src_10002.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS buy__ds__extract_doy + , buys_source_src_10002.user_id AS user + , buys_source_src_10002.session_id + , buys_source_src_10002.user_id AS buy__user + , buys_source_src_10002.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_7 + ) subq_8 + ) subq_9 + ON + ( + subq_6.user = subq_9.user + ) AND ( + subq_6.session = subq_9.session_id + ) AND ( + ( + subq_6.ds__day <= subq_9.ds__day + ) AND ( + subq_6.ds__day > DATEADD(day, -7, subq_9.ds__day) + ) + ) + ) subq_10 + ) subq_11 + ) subq_12 + GROUP BY + subq_12.metric_time__day + , subq_12.visit__referrer_id + ) subq_13 + ON + ( + subq_3.visit__referrer_id = subq_13.visit__referrer_id + ) AND ( + subq_3.metric_time__day = subq_13.metric_time__day + ) + GROUP BY + COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) + , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) +) subq_14 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_constant_properties__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_constant_properties__plan0_optimized.sql new file mode 100644 index 0000000000..3b2ce9a6fa --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_constant_properties__plan0_optimized.sql @@ -0,0 +1,111 @@ +-- Compute Metrics via Expressions +SELECT + metric_time__day + , visit__referrer_id + , CAST(buys AS DOUBLE) / CAST(NULLIF(visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_by_session +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id + , MAX(subq_18.visits) AS visits + , MAX(subq_28.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + metric_time__day + , visit__referrer_id + , SUM(visits) AS visits + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'metric_time__day'] + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + , referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_17 + GROUP BY + metric_time__day + , visit__referrer_id + ) subq_18 + FULL OUTER JOIN ( + -- Find conversions for user within the range of 7 day + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id', 'metric_time__day'] + -- Aggregate Measures + SELECT + metric_time__day + , visit__referrer_id + , SUM(buys) AS buys + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_21.metric_time__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , first_value(subq_21.session) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session + , subq_24.mf_internal_uuid AS mf_internal_uuid + , subq_24.buys AS buys + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', + -- 'visit__referrer_id', + -- 'ds__day', + -- 'metric_time__day', + -- 'user', + -- 'session'] + SELECT + DATE_TRUNC('day', ds) AS ds__day + , DATE_TRUNC('day', ds) AS metric_time__day + , user_id AS user + , session_id AS session + , referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_21 + INNER JOIN ( + -- Read Elements From Semantic Model 'buys_source' + -- Metric Time Dimension 'ds' + -- Add column with generated UUID + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , session_id + , 1 AS buys + , UUID() AS mf_internal_uuid + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_24 + ON + ( + subq_21.user = subq_24.user + ) AND ( + subq_21.session = subq_24.session_id + ) AND ( + ( + subq_21.ds__day <= subq_24.ds__day + ) AND ( + subq_21.ds__day > DATEADD(day, -7, subq_24.ds__day) + ) + ) + ) subq_25 + GROUP BY + metric_time__day + , visit__referrer_id + ) subq_28 + ON + ( + subq_18.visit__referrer_id = subq_28.visit__referrer_id + ) AND ( + subq_18.metric_time__day = subq_28.metric_time__day + ) + GROUP BY + COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) + , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) +) subq_29 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_no_group_by__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_no_group_by__plan0.sql new file mode 100644 index 0000000000..e67042deda --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_no_group_by__plan0.sql @@ -0,0 +1,346 @@ +-- Compute Metrics via Expressions +SELECT + CAST(subq_14.buys AS DOUBLE) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days +FROM ( + -- Combine Aggregated Outputs + SELECT + MAX(subq_3.visits) AS visits + , MAX(subq_13.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + SUM(subq_2.visits) AS visits + FROM ( + -- Pass Only Elements: + -- ['visits'] + SELECT + subq_1.visits + 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.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__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.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_0 + ) subq_1 + ) subq_2 + ) subq_3 + CROSS JOIN ( + -- Aggregate Measures + SELECT + SUM(subq_12.buys) AS buys + FROM ( + -- Pass Only Elements: + -- ['buys'] + SELECT + subq_11.buys + FROM ( + -- Find conversions for user within the range of 7 day + SELECT + subq_10.ds__day + , subq_10.user + , subq_10.buys + , subq_10.visits + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_9.mf_internal_uuid AS mf_internal_uuid + , subq_9.buys AS buys + FROM ( + -- Pass Only Elements: + -- ['visits', 'ds__day', 'user'] + SELECT + subq_5.ds__day + , subq_5.user + , subq_5.visits + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.visit__ds__day + , subq_4.visit__ds__week + , subq_4.visit__ds__month + , subq_4.visit__ds__quarter + , subq_4.visit__ds__year + , subq_4.visit__ds__extract_year + , subq_4.visit__ds__extract_quarter + , subq_4.visit__ds__extract_month + , subq_4.visit__ds__extract_day + , subq_4.visit__ds__extract_dow + , subq_4.visit__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.session + , subq_4.visit__user + , subq_4.visit__session + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.visits + , subq_4.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_4 + ) subq_5 + ) subq_6 + INNER JOIN ( + -- Add column with generated UUID + 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.buy__ds__day + , subq_8.buy__ds__week + , subq_8.buy__ds__month + , subq_8.buy__ds__quarter + , subq_8.buy__ds__year + , subq_8.buy__ds__extract_year + , subq_8.buy__ds__extract_quarter + , subq_8.buy__ds__extract_month + , subq_8.buy__ds__extract_day + , subq_8.buy__ds__extract_dow + , subq_8.buy__ds__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.user + , subq_8.session_id + , subq_8.buy__user + , subq_8.buy__session_id + , subq_8.buys + , subq_8.buyers + , UUID() AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.buy__ds__day + , subq_7.buy__ds__week + , subq_7.buy__ds__month + , subq_7.buy__ds__quarter + , subq_7.buy__ds__year + , subq_7.buy__ds__extract_year + , subq_7.buy__ds__extract_quarter + , subq_7.buy__ds__extract_month + , subq_7.buy__ds__extract_day + , subq_7.buy__ds__extract_dow + , subq_7.buy__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.session_id + , subq_7.buy__user + , subq_7.buy__session_id + , subq_7.buys + , subq_7.buyers + FROM ( + -- Read Elements From Semantic Model 'buys_source' + SELECT + 1 AS buys + , buys_source_src_10002.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_10002.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM buys_source_src_10002.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_10002.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS buy__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM buys_source_src_10002.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS buy__ds__extract_doy + , buys_source_src_10002.user_id AS user + , buys_source_src_10002.session_id + , buys_source_src_10002.user_id AS buy__user + , buys_source_src_10002.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_7 + ) subq_8 + ) subq_9 + ON + ( + subq_6.user = subq_9.user + ) AND ( + ( + subq_6.ds__day <= subq_9.ds__day + ) AND ( + subq_6.ds__day > DATEADD(day, -7, subq_9.ds__day) + ) + ) + ) subq_10 + ) subq_11 + ) subq_12 + ) subq_13 +) subq_14 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_no_group_by__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_no_group_by__plan0_optimized.sql new file mode 100644 index 0000000000..956be41336 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_no_group_by__plan0_optimized.sql @@ -0,0 +1,63 @@ +-- Combine Aggregated Outputs +-- Compute Metrics via Expressions +SELECT + CAST(MAX(subq_28.buys) AS DOUBLE) / CAST(NULLIF(MAX(subq_18.visits), 0) AS DOUBLE) AS visit_buy_conversion_rate_7days +FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits'] + -- Aggregate Measures + SELECT + SUM(1) AS visits + FROM ***************************.fct_visits visits_source_src_10011 +) subq_18 +CROSS JOIN ( + -- Find conversions for user within the range of 7 day + -- Pass Only Elements: + -- ['buys'] + -- Aggregate Measures + SELECT + SUM(buys) AS buys + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_24.mf_internal_uuid AS mf_internal_uuid + , subq_24.buys AS buys + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'ds__day', 'user'] + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_21 + INNER JOIN ( + -- Read Elements From Semantic Model 'buys_source' + -- Metric Time Dimension 'ds' + -- Add column with generated UUID + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , 1 AS buys + , UUID() AS mf_internal_uuid + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_24 + ON + ( + subq_21.user = subq_24.user + ) AND ( + ( + subq_21.ds__day <= subq_24.ds__day + ) AND ( + subq_21.ds__day > DATEADD(day, -7, subq_24.ds__day) + ) + ) + ) subq_25 +) subq_28 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_window__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_window__plan0.sql new file mode 100644 index 0000000000..9cf7d8743b --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_window__plan0.sql @@ -0,0 +1,379 @@ +-- Compute Metrics via Expressions +SELECT + subq_14.metric_time__day + , subq_14.visit__referrer_id + , CAST(subq_14.buys AS DOUBLE) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) AS metric_time__day + , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id + , MAX(subq_3.visits) AS visits + , MAX(subq_13.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + subq_2.metric_time__day + , subq_2.visit__referrer_id + , SUM(subq_2.visits) AS visits + FROM ( + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'metric_time__day'] + SELECT + subq_1.metric_time__day + , subq_1.visit__referrer_id + , subq_1.visits + 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.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__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.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_0 + ) subq_1 + ) subq_2 + GROUP BY + subq_2.metric_time__day + , subq_2.visit__referrer_id + ) subq_3 + FULL OUTER JOIN ( + -- Aggregate Measures + SELECT + subq_12.metric_time__day + , subq_12.visit__referrer_id + , SUM(subq_12.buys) AS buys + FROM ( + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id', 'metric_time__day'] + SELECT + subq_11.metric_time__day + , subq_11.visit__referrer_id + , subq_11.buys + FROM ( + -- Find conversions for user within the range of 7 day + SELECT + subq_10.ds__day + , subq_10.metric_time__day + , subq_10.user + , subq_10.visit__referrer_id + , subq_10.buys + , subq_10.visits + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_6.metric_time__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_9.mf_internal_uuid AS mf_internal_uuid + , subq_9.buys AS buys + FROM ( + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user'] + SELECT + subq_5.ds__day + , subq_5.metric_time__day + , subq_5.user + , subq_5.visit__referrer_id + , subq_5.visits + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.visit__ds__day + , subq_4.visit__ds__week + , subq_4.visit__ds__month + , subq_4.visit__ds__quarter + , subq_4.visit__ds__year + , subq_4.visit__ds__extract_year + , subq_4.visit__ds__extract_quarter + , subq_4.visit__ds__extract_month + , subq_4.visit__ds__extract_day + , subq_4.visit__ds__extract_dow + , subq_4.visit__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.session + , subq_4.visit__user + , subq_4.visit__session + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.visits + , subq_4.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_4 + ) subq_5 + ) subq_6 + INNER JOIN ( + -- Add column with generated UUID + 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.buy__ds__day + , subq_8.buy__ds__week + , subq_8.buy__ds__month + , subq_8.buy__ds__quarter + , subq_8.buy__ds__year + , subq_8.buy__ds__extract_year + , subq_8.buy__ds__extract_quarter + , subq_8.buy__ds__extract_month + , subq_8.buy__ds__extract_day + , subq_8.buy__ds__extract_dow + , subq_8.buy__ds__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.user + , subq_8.session_id + , subq_8.buy__user + , subq_8.buy__session_id + , subq_8.buys + , subq_8.buyers + , UUID() AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.buy__ds__day + , subq_7.buy__ds__week + , subq_7.buy__ds__month + , subq_7.buy__ds__quarter + , subq_7.buy__ds__year + , subq_7.buy__ds__extract_year + , subq_7.buy__ds__extract_quarter + , subq_7.buy__ds__extract_month + , subq_7.buy__ds__extract_day + , subq_7.buy__ds__extract_dow + , subq_7.buy__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.session_id + , subq_7.buy__user + , subq_7.buy__session_id + , subq_7.buys + , subq_7.buyers + FROM ( + -- Read Elements From Semantic Model 'buys_source' + SELECT + 1 AS buys + , buys_source_src_10002.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_10002.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM buys_source_src_10002.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_10002.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS buy__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM buys_source_src_10002.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS buy__ds__extract_doy + , buys_source_src_10002.user_id AS user + , buys_source_src_10002.session_id + , buys_source_src_10002.user_id AS buy__user + , buys_source_src_10002.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_7 + ) subq_8 + ) subq_9 + ON + ( + subq_6.user = subq_9.user + ) AND ( + ( + subq_6.ds__day <= subq_9.ds__day + ) AND ( + subq_6.ds__day > DATEADD(day, -7, subq_9.ds__day) + ) + ) + ) subq_10 + ) subq_11 + ) subq_12 + GROUP BY + subq_12.metric_time__day + , subq_12.visit__referrer_id + ) subq_13 + ON + ( + subq_3.visit__referrer_id = subq_13.visit__referrer_id + ) AND ( + subq_3.metric_time__day = subq_13.metric_time__day + ) + GROUP BY + COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) + , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) +) subq_14 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_window__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_window__plan0_optimized.sql new file mode 100644 index 0000000000..41e19bed96 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_window__plan0_optimized.sql @@ -0,0 +1,101 @@ +-- Compute Metrics via Expressions +SELECT + metric_time__day + , visit__referrer_id + , CAST(buys AS DOUBLE) / CAST(NULLIF(visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id + , MAX(subq_18.visits) AS visits + , MAX(subq_28.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + metric_time__day + , visit__referrer_id + , SUM(visits) AS visits + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'metric_time__day'] + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + , referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_17 + GROUP BY + metric_time__day + , visit__referrer_id + ) subq_18 + FULL OUTER JOIN ( + -- Find conversions for user within the range of 7 day + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id', 'metric_time__day'] + -- Aggregate Measures + SELECT + metric_time__day + , visit__referrer_id + , SUM(buys) AS buys + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_21.metric_time__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_24.mf_internal_uuid AS mf_internal_uuid + , subq_24.buys AS buys + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user'] + SELECT + DATE_TRUNC('day', ds) AS ds__day + , DATE_TRUNC('day', ds) AS metric_time__day + , user_id AS user + , referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_21 + INNER JOIN ( + -- Read Elements From Semantic Model 'buys_source' + -- Metric Time Dimension 'ds' + -- Add column with generated UUID + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , 1 AS buys + , UUID() AS mf_internal_uuid + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_24 + ON + ( + subq_21.user = subq_24.user + ) AND ( + ( + subq_21.ds__day <= subq_24.ds__day + ) AND ( + subq_21.ds__day > DATEADD(day, -7, subq_24.ds__day) + ) + ) + ) subq_25 + GROUP BY + metric_time__day + , visit__referrer_id + ) subq_28 + ON + ( + subq_18.visit__referrer_id = subq_28.visit__referrer_id + ) AND ( + subq_18.metric_time__day = subq_28.metric_time__day + ) + GROUP BY + COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) + , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) +) subq_29 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_count_with_no_group_by__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_count_with_no_group_by__plan0.sql new file mode 100644 index 0000000000..dd5e8bb893 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_count_with_no_group_by__plan0.sql @@ -0,0 +1,346 @@ +-- Compute Metrics via Expressions +SELECT + subq_14.buys AS visit_buy_conversions +FROM ( + -- Combine Aggregated Outputs + SELECT + MAX(subq_3.visits) AS visits + , COALESCE(MAX(subq_13.buys), 0) AS buys + FROM ( + -- Aggregate Measures + SELECT + SUM(subq_2.visits) AS visits + FROM ( + -- Pass Only Elements: + -- ['visits'] + SELECT + subq_1.visits + 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.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__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.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_0 + ) subq_1 + ) subq_2 + ) subq_3 + CROSS JOIN ( + -- Aggregate Measures + SELECT + SUM(subq_12.buys) AS buys + FROM ( + -- Pass Only Elements: + -- ['buys'] + SELECT + subq_11.buys + FROM ( + -- Find conversions for user within the range of 7 day + SELECT + subq_10.ds__day + , subq_10.user + , subq_10.buys + , subq_10.visits + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_9.mf_internal_uuid AS mf_internal_uuid + , subq_9.buys AS buys + FROM ( + -- Pass Only Elements: + -- ['visits', 'ds__day', 'user'] + SELECT + subq_5.ds__day + , subq_5.user + , subq_5.visits + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.visit__ds__day + , subq_4.visit__ds__week + , subq_4.visit__ds__month + , subq_4.visit__ds__quarter + , subq_4.visit__ds__year + , subq_4.visit__ds__extract_year + , subq_4.visit__ds__extract_quarter + , subq_4.visit__ds__extract_month + , subq_4.visit__ds__extract_day + , subq_4.visit__ds__extract_dow + , subq_4.visit__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.session + , subq_4.visit__user + , subq_4.visit__session + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.visits + , subq_4.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_4 + ) subq_5 + ) subq_6 + INNER JOIN ( + -- Add column with generated UUID + 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.buy__ds__day + , subq_8.buy__ds__week + , subq_8.buy__ds__month + , subq_8.buy__ds__quarter + , subq_8.buy__ds__year + , subq_8.buy__ds__extract_year + , subq_8.buy__ds__extract_quarter + , subq_8.buy__ds__extract_month + , subq_8.buy__ds__extract_day + , subq_8.buy__ds__extract_dow + , subq_8.buy__ds__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.user + , subq_8.session_id + , subq_8.buy__user + , subq_8.buy__session_id + , subq_8.buys + , subq_8.buyers + , GEN_RANDOM_UUID() AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.buy__ds__day + , subq_7.buy__ds__week + , subq_7.buy__ds__month + , subq_7.buy__ds__quarter + , subq_7.buy__ds__year + , subq_7.buy__ds__extract_year + , subq_7.buy__ds__extract_quarter + , subq_7.buy__ds__extract_month + , subq_7.buy__ds__extract_day + , subq_7.buy__ds__extract_dow + , subq_7.buy__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.session_id + , subq_7.buy__user + , subq_7.buy__session_id + , subq_7.buys + , subq_7.buyers + FROM ( + -- Read Elements From Semantic Model 'buys_source' + SELECT + 1 AS buys + , buys_source_src_10002.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_10002.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS ds__extract_day + , EXTRACT(isodow FROM buys_source_src_10002.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_10002.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS buy__ds__extract_day + , EXTRACT(isodow FROM buys_source_src_10002.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS buy__ds__extract_doy + , buys_source_src_10002.user_id AS user + , buys_source_src_10002.session_id + , buys_source_src_10002.user_id AS buy__user + , buys_source_src_10002.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_7 + ) subq_8 + ) subq_9 + ON + ( + subq_6.user = subq_9.user + ) AND ( + ( + subq_6.ds__day <= subq_9.ds__day + ) AND ( + subq_6.ds__day > subq_9.ds__day - INTERVAL 7 day + ) + ) + ) subq_10 + ) subq_11 + ) subq_12 + ) subq_13 +) subq_14 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_count_with_no_group_by__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_count_with_no_group_by__plan0_optimized.sql new file mode 100644 index 0000000000..8289e8c753 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_count_with_no_group_by__plan0_optimized.sql @@ -0,0 +1,63 @@ +-- Combine Aggregated Outputs +-- Compute Metrics via Expressions +SELECT + COALESCE(MAX(subq_28.buys), 0) AS visit_buy_conversions +FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits'] + -- Aggregate Measures + SELECT + SUM(1) AS visits + FROM ***************************.fct_visits visits_source_src_10011 +) subq_18 +CROSS JOIN ( + -- Find conversions for user within the range of 7 day + -- Pass Only Elements: + -- ['buys'] + -- Aggregate Measures + SELECT + SUM(buys) AS buys + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_24.mf_internal_uuid AS mf_internal_uuid + , subq_24.buys AS buys + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'ds__day', 'user'] + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_21 + INNER JOIN ( + -- Read Elements From Semantic Model 'buys_source' + -- Metric Time Dimension 'ds' + -- Add column with generated UUID + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , 1 AS buys + , GEN_RANDOM_UUID() AS mf_internal_uuid + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_24 + ON + ( + subq_21.user = subq_24.user + ) AND ( + ( + subq_21.ds__day <= subq_24.ds__day + ) AND ( + subq_21.ds__day > subq_24.ds__day - INTERVAL 7 day + ) + ) + ) subq_25 +) subq_28 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate__plan0.sql new file mode 100644 index 0000000000..ecfcf5e56b --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate__plan0.sql @@ -0,0 +1,355 @@ +-- Compute Metrics via Expressions +SELECT + subq_14.visit__referrer_id + , CAST(subq_14.buys AS DOUBLE) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id + , MAX(subq_3.visits) AS visits + , MAX(subq_13.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + subq_2.visit__referrer_id + , SUM(subq_2.visits) AS visits + FROM ( + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id'] + SELECT + subq_1.visit__referrer_id + , subq_1.visits + 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.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__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.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_0 + ) subq_1 + ) subq_2 + GROUP BY + subq_2.visit__referrer_id + ) subq_3 + FULL OUTER JOIN ( + -- Aggregate Measures + SELECT + subq_12.visit__referrer_id + , SUM(subq_12.buys) AS buys + FROM ( + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id'] + SELECT + subq_11.visit__referrer_id + , subq_11.buys + FROM ( + -- Find conversions for user within the range of INF + SELECT + subq_10.ds__day + , subq_10.user + , subq_10.visit__referrer_id + , subq_10.buys + , subq_10.visits + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_9.mf_internal_uuid AS mf_internal_uuid + , subq_9.buys AS buys + FROM ( + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'ds__day', 'user'] + SELECT + subq_5.ds__day + , subq_5.user + , subq_5.visit__referrer_id + , subq_5.visits + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.visit__ds__day + , subq_4.visit__ds__week + , subq_4.visit__ds__month + , subq_4.visit__ds__quarter + , subq_4.visit__ds__year + , subq_4.visit__ds__extract_year + , subq_4.visit__ds__extract_quarter + , subq_4.visit__ds__extract_month + , subq_4.visit__ds__extract_day + , subq_4.visit__ds__extract_dow + , subq_4.visit__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.session + , subq_4.visit__user + , subq_4.visit__session + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.visits + , subq_4.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_4 + ) subq_5 + ) subq_6 + INNER JOIN ( + -- Add column with generated UUID + 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.buy__ds__day + , subq_8.buy__ds__week + , subq_8.buy__ds__month + , subq_8.buy__ds__quarter + , subq_8.buy__ds__year + , subq_8.buy__ds__extract_year + , subq_8.buy__ds__extract_quarter + , subq_8.buy__ds__extract_month + , subq_8.buy__ds__extract_day + , subq_8.buy__ds__extract_dow + , subq_8.buy__ds__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.user + , subq_8.session_id + , subq_8.buy__user + , subq_8.buy__session_id + , subq_8.buys + , subq_8.buyers + , GEN_RANDOM_UUID() AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.buy__ds__day + , subq_7.buy__ds__week + , subq_7.buy__ds__month + , subq_7.buy__ds__quarter + , subq_7.buy__ds__year + , subq_7.buy__ds__extract_year + , subq_7.buy__ds__extract_quarter + , subq_7.buy__ds__extract_month + , subq_7.buy__ds__extract_day + , subq_7.buy__ds__extract_dow + , subq_7.buy__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.session_id + , subq_7.buy__user + , subq_7.buy__session_id + , subq_7.buys + , subq_7.buyers + FROM ( + -- Read Elements From Semantic Model 'buys_source' + SELECT + 1 AS buys + , buys_source_src_10002.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_10002.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS ds__extract_day + , EXTRACT(isodow FROM buys_source_src_10002.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_10002.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS buy__ds__extract_day + , EXTRACT(isodow FROM buys_source_src_10002.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS buy__ds__extract_doy + , buys_source_src_10002.user_id AS user + , buys_source_src_10002.session_id + , buys_source_src_10002.user_id AS buy__user + , buys_source_src_10002.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_7 + ) subq_8 + ) subq_9 + ON + (subq_6.user = subq_9.user) AND ((subq_6.ds__day <= subq_9.ds__day)) + ) subq_10 + ) subq_11 + ) subq_12 + GROUP BY + subq_12.visit__referrer_id + ) subq_13 + ON + subq_3.visit__referrer_id = subq_13.visit__referrer_id + GROUP BY + COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) +) subq_14 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate__plan0_optimized.sql new file mode 100644 index 0000000000..65be6c324d --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate__plan0_optimized.sql @@ -0,0 +1,83 @@ +-- Compute Metrics via Expressions +SELECT + visit__referrer_id + , CAST(buys AS DOUBLE) / CAST(NULLIF(visits, 0) AS DOUBLE) AS visit_buy_conversion_rate +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id + , MAX(subq_18.visits) AS visits + , MAX(subq_28.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + visit__referrer_id + , SUM(visits) AS visits + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id'] + SELECT + referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_17 + GROUP BY + visit__referrer_id + ) subq_18 + FULL OUTER JOIN ( + -- Find conversions for user within the range of INF + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id'] + -- Aggregate Measures + SELECT + visit__referrer_id + , SUM(buys) AS buys + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_24.mf_internal_uuid AS mf_internal_uuid + , subq_24.buys AS buys + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'ds__day', 'user'] + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_21 + INNER JOIN ( + -- Read Elements From Semantic Model 'buys_source' + -- Metric Time Dimension 'ds' + -- Add column with generated UUID + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , 1 AS buys + , GEN_RANDOM_UUID() AS mf_internal_uuid + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_24 + ON + ( + subq_21.user = subq_24.user + ) AND ( + (subq_21.ds__day <= subq_24.ds__day) + ) + ) subq_25 + GROUP BY + visit__referrer_id + ) subq_28 + ON + subq_18.visit__referrer_id = subq_28.visit__referrer_id + GROUP BY + COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) +) subq_29 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_constant_properties__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_constant_properties__plan0.sql new file mode 100644 index 0000000000..2217da50ea --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_constant_properties__plan0.sql @@ -0,0 +1,389 @@ +-- Compute Metrics via Expressions +SELECT + subq_14.metric_time__day + , subq_14.visit__referrer_id + , CAST(subq_14.buys AS DOUBLE) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_by_session +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) AS metric_time__day + , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id + , MAX(subq_3.visits) AS visits + , MAX(subq_13.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + subq_2.metric_time__day + , subq_2.visit__referrer_id + , SUM(subq_2.visits) AS visits + FROM ( + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'metric_time__day'] + SELECT + subq_1.metric_time__day + , subq_1.visit__referrer_id + , subq_1.visits + 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.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__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.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_0 + ) subq_1 + ) subq_2 + GROUP BY + subq_2.metric_time__day + , subq_2.visit__referrer_id + ) subq_3 + FULL OUTER JOIN ( + -- Aggregate Measures + SELECT + subq_12.metric_time__day + , subq_12.visit__referrer_id + , SUM(subq_12.buys) AS buys + FROM ( + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id', 'metric_time__day'] + SELECT + subq_11.metric_time__day + , subq_11.visit__referrer_id + , subq_11.buys + FROM ( + -- Find conversions for user within the range of 7 day + SELECT + subq_10.ds__day + , subq_10.metric_time__day + , subq_10.user + , subq_10.session + , subq_10.visit__referrer_id + , subq_10.buys + , subq_10.visits + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_6.metric_time__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , first_value(subq_6.session) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session + , subq_9.mf_internal_uuid AS mf_internal_uuid + , subq_9.buys AS buys + FROM ( + -- Pass Only Elements: + -- ['visits', + -- 'visit__referrer_id', + -- 'ds__day', + -- 'metric_time__day', + -- 'user', + -- 'session'] + SELECT + subq_5.ds__day + , subq_5.metric_time__day + , subq_5.user + , subq_5.session + , subq_5.visit__referrer_id + , subq_5.visits + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.visit__ds__day + , subq_4.visit__ds__week + , subq_4.visit__ds__month + , subq_4.visit__ds__quarter + , subq_4.visit__ds__year + , subq_4.visit__ds__extract_year + , subq_4.visit__ds__extract_quarter + , subq_4.visit__ds__extract_month + , subq_4.visit__ds__extract_day + , subq_4.visit__ds__extract_dow + , subq_4.visit__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.session + , subq_4.visit__user + , subq_4.visit__session + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.visits + , subq_4.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_4 + ) subq_5 + ) subq_6 + INNER JOIN ( + -- Add column with generated UUID + 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.buy__ds__day + , subq_8.buy__ds__week + , subq_8.buy__ds__month + , subq_8.buy__ds__quarter + , subq_8.buy__ds__year + , subq_8.buy__ds__extract_year + , subq_8.buy__ds__extract_quarter + , subq_8.buy__ds__extract_month + , subq_8.buy__ds__extract_day + , subq_8.buy__ds__extract_dow + , subq_8.buy__ds__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.user + , subq_8.session_id + , subq_8.buy__user + , subq_8.buy__session_id + , subq_8.buys + , subq_8.buyers + , GEN_RANDOM_UUID() AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.buy__ds__day + , subq_7.buy__ds__week + , subq_7.buy__ds__month + , subq_7.buy__ds__quarter + , subq_7.buy__ds__year + , subq_7.buy__ds__extract_year + , subq_7.buy__ds__extract_quarter + , subq_7.buy__ds__extract_month + , subq_7.buy__ds__extract_day + , subq_7.buy__ds__extract_dow + , subq_7.buy__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.session_id + , subq_7.buy__user + , subq_7.buy__session_id + , subq_7.buys + , subq_7.buyers + FROM ( + -- Read Elements From Semantic Model 'buys_source' + SELECT + 1 AS buys + , buys_source_src_10002.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_10002.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS ds__extract_day + , EXTRACT(isodow FROM buys_source_src_10002.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_10002.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS buy__ds__extract_day + , EXTRACT(isodow FROM buys_source_src_10002.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS buy__ds__extract_doy + , buys_source_src_10002.user_id AS user + , buys_source_src_10002.session_id + , buys_source_src_10002.user_id AS buy__user + , buys_source_src_10002.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_7 + ) subq_8 + ) subq_9 + ON + ( + subq_6.user = subq_9.user + ) AND ( + subq_6.session = subq_9.session_id + ) AND ( + ( + subq_6.ds__day <= subq_9.ds__day + ) AND ( + subq_6.ds__day > subq_9.ds__day - INTERVAL 7 day + ) + ) + ) subq_10 + ) subq_11 + ) subq_12 + GROUP BY + subq_12.metric_time__day + , subq_12.visit__referrer_id + ) subq_13 + ON + ( + subq_3.visit__referrer_id = subq_13.visit__referrer_id + ) AND ( + subq_3.metric_time__day = subq_13.metric_time__day + ) + GROUP BY + COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) + , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) +) subq_14 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_constant_properties__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_constant_properties__plan0_optimized.sql new file mode 100644 index 0000000000..5ab95cfe02 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_constant_properties__plan0_optimized.sql @@ -0,0 +1,111 @@ +-- Compute Metrics via Expressions +SELECT + metric_time__day + , visit__referrer_id + , CAST(buys AS DOUBLE) / CAST(NULLIF(visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_by_session +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id + , MAX(subq_18.visits) AS visits + , MAX(subq_28.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + metric_time__day + , visit__referrer_id + , SUM(visits) AS visits + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'metric_time__day'] + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + , referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_17 + GROUP BY + metric_time__day + , visit__referrer_id + ) subq_18 + FULL OUTER JOIN ( + -- Find conversions for user within the range of 7 day + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id', 'metric_time__day'] + -- Aggregate Measures + SELECT + metric_time__day + , visit__referrer_id + , SUM(buys) AS buys + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_21.metric_time__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , first_value(subq_21.session) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session + , subq_24.mf_internal_uuid AS mf_internal_uuid + , subq_24.buys AS buys + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', + -- 'visit__referrer_id', + -- 'ds__day', + -- 'metric_time__day', + -- 'user', + -- 'session'] + SELECT + DATE_TRUNC('day', ds) AS ds__day + , DATE_TRUNC('day', ds) AS metric_time__day + , user_id AS user + , session_id AS session + , referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_21 + INNER JOIN ( + -- Read Elements From Semantic Model 'buys_source' + -- Metric Time Dimension 'ds' + -- Add column with generated UUID + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , session_id + , 1 AS buys + , GEN_RANDOM_UUID() AS mf_internal_uuid + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_24 + ON + ( + subq_21.user = subq_24.user + ) AND ( + subq_21.session = subq_24.session_id + ) AND ( + ( + subq_21.ds__day <= subq_24.ds__day + ) AND ( + subq_21.ds__day > subq_24.ds__day - INTERVAL 7 day + ) + ) + ) subq_25 + GROUP BY + metric_time__day + , visit__referrer_id + ) subq_28 + ON + ( + subq_18.visit__referrer_id = subq_28.visit__referrer_id + ) AND ( + subq_18.metric_time__day = subq_28.metric_time__day + ) + GROUP BY + COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) + , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) +) subq_29 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_no_group_by__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_no_group_by__plan0.sql new file mode 100644 index 0000000000..210fb954fa --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_no_group_by__plan0.sql @@ -0,0 +1,346 @@ +-- Compute Metrics via Expressions +SELECT + CAST(subq_14.buys AS DOUBLE) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days +FROM ( + -- Combine Aggregated Outputs + SELECT + MAX(subq_3.visits) AS visits + , MAX(subq_13.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + SUM(subq_2.visits) AS visits + FROM ( + -- Pass Only Elements: + -- ['visits'] + SELECT + subq_1.visits + 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.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__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.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_0 + ) subq_1 + ) subq_2 + ) subq_3 + CROSS JOIN ( + -- Aggregate Measures + SELECT + SUM(subq_12.buys) AS buys + FROM ( + -- Pass Only Elements: + -- ['buys'] + SELECT + subq_11.buys + FROM ( + -- Find conversions for user within the range of 7 day + SELECT + subq_10.ds__day + , subq_10.user + , subq_10.buys + , subq_10.visits + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_9.mf_internal_uuid AS mf_internal_uuid + , subq_9.buys AS buys + FROM ( + -- Pass Only Elements: + -- ['visits', 'ds__day', 'user'] + SELECT + subq_5.ds__day + , subq_5.user + , subq_5.visits + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.visit__ds__day + , subq_4.visit__ds__week + , subq_4.visit__ds__month + , subq_4.visit__ds__quarter + , subq_4.visit__ds__year + , subq_4.visit__ds__extract_year + , subq_4.visit__ds__extract_quarter + , subq_4.visit__ds__extract_month + , subq_4.visit__ds__extract_day + , subq_4.visit__ds__extract_dow + , subq_4.visit__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.session + , subq_4.visit__user + , subq_4.visit__session + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.visits + , subq_4.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_4 + ) subq_5 + ) subq_6 + INNER JOIN ( + -- Add column with generated UUID + 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.buy__ds__day + , subq_8.buy__ds__week + , subq_8.buy__ds__month + , subq_8.buy__ds__quarter + , subq_8.buy__ds__year + , subq_8.buy__ds__extract_year + , subq_8.buy__ds__extract_quarter + , subq_8.buy__ds__extract_month + , subq_8.buy__ds__extract_day + , subq_8.buy__ds__extract_dow + , subq_8.buy__ds__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.user + , subq_8.session_id + , subq_8.buy__user + , subq_8.buy__session_id + , subq_8.buys + , subq_8.buyers + , GEN_RANDOM_UUID() AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.buy__ds__day + , subq_7.buy__ds__week + , subq_7.buy__ds__month + , subq_7.buy__ds__quarter + , subq_7.buy__ds__year + , subq_7.buy__ds__extract_year + , subq_7.buy__ds__extract_quarter + , subq_7.buy__ds__extract_month + , subq_7.buy__ds__extract_day + , subq_7.buy__ds__extract_dow + , subq_7.buy__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.session_id + , subq_7.buy__user + , subq_7.buy__session_id + , subq_7.buys + , subq_7.buyers + FROM ( + -- Read Elements From Semantic Model 'buys_source' + SELECT + 1 AS buys + , buys_source_src_10002.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_10002.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS ds__extract_day + , EXTRACT(isodow FROM buys_source_src_10002.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_10002.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS buy__ds__extract_day + , EXTRACT(isodow FROM buys_source_src_10002.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS buy__ds__extract_doy + , buys_source_src_10002.user_id AS user + , buys_source_src_10002.session_id + , buys_source_src_10002.user_id AS buy__user + , buys_source_src_10002.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_7 + ) subq_8 + ) subq_9 + ON + ( + subq_6.user = subq_9.user + ) AND ( + ( + subq_6.ds__day <= subq_9.ds__day + ) AND ( + subq_6.ds__day > subq_9.ds__day - INTERVAL 7 day + ) + ) + ) subq_10 + ) subq_11 + ) subq_12 + ) subq_13 +) subq_14 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_no_group_by__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_no_group_by__plan0_optimized.sql new file mode 100644 index 0000000000..f24319a150 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_no_group_by__plan0_optimized.sql @@ -0,0 +1,63 @@ +-- Combine Aggregated Outputs +-- Compute Metrics via Expressions +SELECT + CAST(MAX(subq_28.buys) AS DOUBLE) / CAST(NULLIF(MAX(subq_18.visits), 0) AS DOUBLE) AS visit_buy_conversion_rate_7days +FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits'] + -- Aggregate Measures + SELECT + SUM(1) AS visits + FROM ***************************.fct_visits visits_source_src_10011 +) subq_18 +CROSS JOIN ( + -- Find conversions for user within the range of 7 day + -- Pass Only Elements: + -- ['buys'] + -- Aggregate Measures + SELECT + SUM(buys) AS buys + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_24.mf_internal_uuid AS mf_internal_uuid + , subq_24.buys AS buys + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'ds__day', 'user'] + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_21 + INNER JOIN ( + -- Read Elements From Semantic Model 'buys_source' + -- Metric Time Dimension 'ds' + -- Add column with generated UUID + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , 1 AS buys + , GEN_RANDOM_UUID() AS mf_internal_uuid + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_24 + ON + ( + subq_21.user = subq_24.user + ) AND ( + ( + subq_21.ds__day <= subq_24.ds__day + ) AND ( + subq_21.ds__day > subq_24.ds__day - INTERVAL 7 day + ) + ) + ) subq_25 +) subq_28 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_window__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_window__plan0.sql new file mode 100644 index 0000000000..4420d8b99a --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_window__plan0.sql @@ -0,0 +1,379 @@ +-- Compute Metrics via Expressions +SELECT + subq_14.metric_time__day + , subq_14.visit__referrer_id + , CAST(subq_14.buys AS DOUBLE) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) AS metric_time__day + , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id + , MAX(subq_3.visits) AS visits + , MAX(subq_13.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + subq_2.metric_time__day + , subq_2.visit__referrer_id + , SUM(subq_2.visits) AS visits + FROM ( + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'metric_time__day'] + SELECT + subq_1.metric_time__day + , subq_1.visit__referrer_id + , subq_1.visits + 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.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__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.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_0 + ) subq_1 + ) subq_2 + GROUP BY + subq_2.metric_time__day + , subq_2.visit__referrer_id + ) subq_3 + FULL OUTER JOIN ( + -- Aggregate Measures + SELECT + subq_12.metric_time__day + , subq_12.visit__referrer_id + , SUM(subq_12.buys) AS buys + FROM ( + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id', 'metric_time__day'] + SELECT + subq_11.metric_time__day + , subq_11.visit__referrer_id + , subq_11.buys + FROM ( + -- Find conversions for user within the range of 7 day + SELECT + subq_10.ds__day + , subq_10.metric_time__day + , subq_10.user + , subq_10.visit__referrer_id + , subq_10.buys + , subq_10.visits + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_6.metric_time__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_9.mf_internal_uuid AS mf_internal_uuid + , subq_9.buys AS buys + FROM ( + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user'] + SELECT + subq_5.ds__day + , subq_5.metric_time__day + , subq_5.user + , subq_5.visit__referrer_id + , subq_5.visits + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.visit__ds__day + , subq_4.visit__ds__week + , subq_4.visit__ds__month + , subq_4.visit__ds__quarter + , subq_4.visit__ds__year + , subq_4.visit__ds__extract_year + , subq_4.visit__ds__extract_quarter + , subq_4.visit__ds__extract_month + , subq_4.visit__ds__extract_day + , subq_4.visit__ds__extract_dow + , subq_4.visit__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.session + , subq_4.visit__user + , subq_4.visit__session + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.visits + , subq_4.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_4 + ) subq_5 + ) subq_6 + INNER JOIN ( + -- Add column with generated UUID + 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.buy__ds__day + , subq_8.buy__ds__week + , subq_8.buy__ds__month + , subq_8.buy__ds__quarter + , subq_8.buy__ds__year + , subq_8.buy__ds__extract_year + , subq_8.buy__ds__extract_quarter + , subq_8.buy__ds__extract_month + , subq_8.buy__ds__extract_day + , subq_8.buy__ds__extract_dow + , subq_8.buy__ds__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.user + , subq_8.session_id + , subq_8.buy__user + , subq_8.buy__session_id + , subq_8.buys + , subq_8.buyers + , GEN_RANDOM_UUID() AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.buy__ds__day + , subq_7.buy__ds__week + , subq_7.buy__ds__month + , subq_7.buy__ds__quarter + , subq_7.buy__ds__year + , subq_7.buy__ds__extract_year + , subq_7.buy__ds__extract_quarter + , subq_7.buy__ds__extract_month + , subq_7.buy__ds__extract_day + , subq_7.buy__ds__extract_dow + , subq_7.buy__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.session_id + , subq_7.buy__user + , subq_7.buy__session_id + , subq_7.buys + , subq_7.buyers + FROM ( + -- Read Elements From Semantic Model 'buys_source' + SELECT + 1 AS buys + , buys_source_src_10002.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_10002.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS ds__extract_day + , EXTRACT(isodow FROM buys_source_src_10002.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_10002.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS buy__ds__extract_day + , EXTRACT(isodow FROM buys_source_src_10002.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS buy__ds__extract_doy + , buys_source_src_10002.user_id AS user + , buys_source_src_10002.session_id + , buys_source_src_10002.user_id AS buy__user + , buys_source_src_10002.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_7 + ) subq_8 + ) subq_9 + ON + ( + subq_6.user = subq_9.user + ) AND ( + ( + subq_6.ds__day <= subq_9.ds__day + ) AND ( + subq_6.ds__day > subq_9.ds__day - INTERVAL 7 day + ) + ) + ) subq_10 + ) subq_11 + ) subq_12 + GROUP BY + subq_12.metric_time__day + , subq_12.visit__referrer_id + ) subq_13 + ON + ( + subq_3.visit__referrer_id = subq_13.visit__referrer_id + ) AND ( + subq_3.metric_time__day = subq_13.metric_time__day + ) + GROUP BY + COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) + , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) +) subq_14 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_window__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_window__plan0_optimized.sql new file mode 100644 index 0000000000..77f1d7e299 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_window__plan0_optimized.sql @@ -0,0 +1,101 @@ +-- Compute Metrics via Expressions +SELECT + metric_time__day + , visit__referrer_id + , CAST(buys AS DOUBLE) / CAST(NULLIF(visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id + , MAX(subq_18.visits) AS visits + , MAX(subq_28.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + metric_time__day + , visit__referrer_id + , SUM(visits) AS visits + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'metric_time__day'] + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + , referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_17 + GROUP BY + metric_time__day + , visit__referrer_id + ) subq_18 + FULL OUTER JOIN ( + -- Find conversions for user within the range of 7 day + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id', 'metric_time__day'] + -- Aggregate Measures + SELECT + metric_time__day + , visit__referrer_id + , SUM(buys) AS buys + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_21.metric_time__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_24.mf_internal_uuid AS mf_internal_uuid + , subq_24.buys AS buys + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user'] + SELECT + DATE_TRUNC('day', ds) AS ds__day + , DATE_TRUNC('day', ds) AS metric_time__day + , user_id AS user + , referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_21 + INNER JOIN ( + -- Read Elements From Semantic Model 'buys_source' + -- Metric Time Dimension 'ds' + -- Add column with generated UUID + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , 1 AS buys + , GEN_RANDOM_UUID() AS mf_internal_uuid + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_24 + ON + ( + subq_21.user = subq_24.user + ) AND ( + ( + subq_21.ds__day <= subq_24.ds__day + ) AND ( + subq_21.ds__day > subq_24.ds__day - INTERVAL 7 day + ) + ) + ) subq_25 + GROUP BY + metric_time__day + , visit__referrer_id + ) subq_28 + ON + ( + subq_18.visit__referrer_id = subq_28.visit__referrer_id + ) AND ( + subq_18.metric_time__day = subq_28.metric_time__day + ) + GROUP BY + COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) + , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) +) subq_29 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_count_with_no_group_by__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_count_with_no_group_by__plan0.sql new file mode 100644 index 0000000000..6c6da0fbe4 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_count_with_no_group_by__plan0.sql @@ -0,0 +1,346 @@ +-- Compute Metrics via Expressions +SELECT + subq_14.buys AS visit_buy_conversions +FROM ( + -- Combine Aggregated Outputs + SELECT + MAX(subq_3.visits) AS visits + , COALESCE(MAX(subq_13.buys), 0) AS buys + FROM ( + -- Aggregate Measures + SELECT + SUM(subq_2.visits) AS visits + FROM ( + -- Pass Only Elements: + -- ['visits'] + SELECT + subq_1.visits + 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.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__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.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_0 + ) subq_1 + ) subq_2 + ) subq_3 + CROSS JOIN ( + -- Aggregate Measures + SELECT + SUM(subq_12.buys) AS buys + FROM ( + -- Pass Only Elements: + -- ['buys'] + SELECT + subq_11.buys + FROM ( + -- Find conversions for user within the range of 7 day + SELECT + subq_10.ds__day + , subq_10.user + , subq_10.buys + , subq_10.visits + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_9.mf_internal_uuid AS mf_internal_uuid + , subq_9.buys AS buys + FROM ( + -- Pass Only Elements: + -- ['visits', 'ds__day', 'user'] + SELECT + subq_5.ds__day + , subq_5.user + , subq_5.visits + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.visit__ds__day + , subq_4.visit__ds__week + , subq_4.visit__ds__month + , subq_4.visit__ds__quarter + , subq_4.visit__ds__year + , subq_4.visit__ds__extract_year + , subq_4.visit__ds__extract_quarter + , subq_4.visit__ds__extract_month + , subq_4.visit__ds__extract_day + , subq_4.visit__ds__extract_dow + , subq_4.visit__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.session + , subq_4.visit__user + , subq_4.visit__session + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.visits + , subq_4.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_4 + ) subq_5 + ) subq_6 + INNER JOIN ( + -- Add column with generated UUID + 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.buy__ds__day + , subq_8.buy__ds__week + , subq_8.buy__ds__month + , subq_8.buy__ds__quarter + , subq_8.buy__ds__year + , subq_8.buy__ds__extract_year + , subq_8.buy__ds__extract_quarter + , subq_8.buy__ds__extract_month + , subq_8.buy__ds__extract_day + , subq_8.buy__ds__extract_dow + , subq_8.buy__ds__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.user + , subq_8.session_id + , subq_8.buy__user + , subq_8.buy__session_id + , subq_8.buys + , subq_8.buyers + , GEN_RANDOM_UUID() AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.buy__ds__day + , subq_7.buy__ds__week + , subq_7.buy__ds__month + , subq_7.buy__ds__quarter + , subq_7.buy__ds__year + , subq_7.buy__ds__extract_year + , subq_7.buy__ds__extract_quarter + , subq_7.buy__ds__extract_month + , subq_7.buy__ds__extract_day + , subq_7.buy__ds__extract_dow + , subq_7.buy__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.session_id + , subq_7.buy__user + , subq_7.buy__session_id + , subq_7.buys + , subq_7.buyers + FROM ( + -- Read Elements From Semantic Model 'buys_source' + SELECT + 1 AS buys + , buys_source_src_10002.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_10002.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS ds__extract_day + , EXTRACT(isodow FROM buys_source_src_10002.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_10002.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS buy__ds__extract_day + , EXTRACT(isodow FROM buys_source_src_10002.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS buy__ds__extract_doy + , buys_source_src_10002.user_id AS user + , buys_source_src_10002.session_id + , buys_source_src_10002.user_id AS buy__user + , buys_source_src_10002.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_7 + ) subq_8 + ) subq_9 + ON + ( + subq_6.user = subq_9.user + ) AND ( + ( + subq_6.ds__day <= subq_9.ds__day + ) AND ( + subq_6.ds__day > subq_9.ds__day - MAKE_INTERVAL(days => 7) + ) + ) + ) subq_10 + ) subq_11 + ) subq_12 + ) subq_13 +) subq_14 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_count_with_no_group_by__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_count_with_no_group_by__plan0_optimized.sql new file mode 100644 index 0000000000..ba3b2ced4c --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_count_with_no_group_by__plan0_optimized.sql @@ -0,0 +1,63 @@ +-- Combine Aggregated Outputs +-- Compute Metrics via Expressions +SELECT + COALESCE(MAX(subq_28.buys), 0) AS visit_buy_conversions +FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits'] + -- Aggregate Measures + SELECT + SUM(1) AS visits + FROM ***************************.fct_visits visits_source_src_10011 +) subq_18 +CROSS JOIN ( + -- Find conversions for user within the range of 7 day + -- Pass Only Elements: + -- ['buys'] + -- Aggregate Measures + SELECT + SUM(buys) AS buys + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_24.mf_internal_uuid AS mf_internal_uuid + , subq_24.buys AS buys + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'ds__day', 'user'] + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_21 + INNER JOIN ( + -- Read Elements From Semantic Model 'buys_source' + -- Metric Time Dimension 'ds' + -- Add column with generated UUID + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , 1 AS buys + , GEN_RANDOM_UUID() AS mf_internal_uuid + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_24 + ON + ( + subq_21.user = subq_24.user + ) AND ( + ( + subq_21.ds__day <= subq_24.ds__day + ) AND ( + subq_21.ds__day > subq_24.ds__day - MAKE_INTERVAL(days => 7) + ) + ) + ) subq_25 +) subq_28 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate__plan0.sql new file mode 100644 index 0000000000..dd1cae7ebf --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate__plan0.sql @@ -0,0 +1,355 @@ +-- Compute Metrics via Expressions +SELECT + subq_14.visit__referrer_id + , CAST(subq_14.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id + , MAX(subq_3.visits) AS visits + , MAX(subq_13.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + subq_2.visit__referrer_id + , SUM(subq_2.visits) AS visits + FROM ( + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id'] + SELECT + subq_1.visit__referrer_id + , subq_1.visits + 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.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__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.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_0 + ) subq_1 + ) subq_2 + GROUP BY + subq_2.visit__referrer_id + ) subq_3 + FULL OUTER JOIN ( + -- Aggregate Measures + SELECT + subq_12.visit__referrer_id + , SUM(subq_12.buys) AS buys + FROM ( + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id'] + SELECT + subq_11.visit__referrer_id + , subq_11.buys + FROM ( + -- Find conversions for user within the range of INF + SELECT + subq_10.ds__day + , subq_10.user + , subq_10.visit__referrer_id + , subq_10.buys + , subq_10.visits + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_9.mf_internal_uuid AS mf_internal_uuid + , subq_9.buys AS buys + FROM ( + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'ds__day', 'user'] + SELECT + subq_5.ds__day + , subq_5.user + , subq_5.visit__referrer_id + , subq_5.visits + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.visit__ds__day + , subq_4.visit__ds__week + , subq_4.visit__ds__month + , subq_4.visit__ds__quarter + , subq_4.visit__ds__year + , subq_4.visit__ds__extract_year + , subq_4.visit__ds__extract_quarter + , subq_4.visit__ds__extract_month + , subq_4.visit__ds__extract_day + , subq_4.visit__ds__extract_dow + , subq_4.visit__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.session + , subq_4.visit__user + , subq_4.visit__session + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.visits + , subq_4.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_4 + ) subq_5 + ) subq_6 + INNER JOIN ( + -- Add column with generated UUID + 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.buy__ds__day + , subq_8.buy__ds__week + , subq_8.buy__ds__month + , subq_8.buy__ds__quarter + , subq_8.buy__ds__year + , subq_8.buy__ds__extract_year + , subq_8.buy__ds__extract_quarter + , subq_8.buy__ds__extract_month + , subq_8.buy__ds__extract_day + , subq_8.buy__ds__extract_dow + , subq_8.buy__ds__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.user + , subq_8.session_id + , subq_8.buy__user + , subq_8.buy__session_id + , subq_8.buys + , subq_8.buyers + , GEN_RANDOM_UUID() AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.buy__ds__day + , subq_7.buy__ds__week + , subq_7.buy__ds__month + , subq_7.buy__ds__quarter + , subq_7.buy__ds__year + , subq_7.buy__ds__extract_year + , subq_7.buy__ds__extract_quarter + , subq_7.buy__ds__extract_month + , subq_7.buy__ds__extract_day + , subq_7.buy__ds__extract_dow + , subq_7.buy__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.session_id + , subq_7.buy__user + , subq_7.buy__session_id + , subq_7.buys + , subq_7.buyers + FROM ( + -- Read Elements From Semantic Model 'buys_source' + SELECT + 1 AS buys + , buys_source_src_10002.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_10002.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS ds__extract_day + , EXTRACT(isodow FROM buys_source_src_10002.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_10002.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS buy__ds__extract_day + , EXTRACT(isodow FROM buys_source_src_10002.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS buy__ds__extract_doy + , buys_source_src_10002.user_id AS user + , buys_source_src_10002.session_id + , buys_source_src_10002.user_id AS buy__user + , buys_source_src_10002.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_7 + ) subq_8 + ) subq_9 + ON + (subq_6.user = subq_9.user) AND ((subq_6.ds__day <= subq_9.ds__day)) + ) subq_10 + ) subq_11 + ) subq_12 + GROUP BY + subq_12.visit__referrer_id + ) subq_13 + ON + subq_3.visit__referrer_id = subq_13.visit__referrer_id + GROUP BY + COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) +) subq_14 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate__plan0_optimized.sql new file mode 100644 index 0000000000..5ab5cc19b1 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate__plan0_optimized.sql @@ -0,0 +1,83 @@ +-- Compute Metrics via Expressions +SELECT + visit__referrer_id + , CAST(buys AS DOUBLE PRECISION) / CAST(NULLIF(visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id + , MAX(subq_18.visits) AS visits + , MAX(subq_28.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + visit__referrer_id + , SUM(visits) AS visits + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id'] + SELECT + referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_17 + GROUP BY + visit__referrer_id + ) subq_18 + FULL OUTER JOIN ( + -- Find conversions for user within the range of INF + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id'] + -- Aggregate Measures + SELECT + visit__referrer_id + , SUM(buys) AS buys + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_24.mf_internal_uuid AS mf_internal_uuid + , subq_24.buys AS buys + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'ds__day', 'user'] + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_21 + INNER JOIN ( + -- Read Elements From Semantic Model 'buys_source' + -- Metric Time Dimension 'ds' + -- Add column with generated UUID + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , 1 AS buys + , GEN_RANDOM_UUID() AS mf_internal_uuid + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_24 + ON + ( + subq_21.user = subq_24.user + ) AND ( + (subq_21.ds__day <= subq_24.ds__day) + ) + ) subq_25 + GROUP BY + visit__referrer_id + ) subq_28 + ON + subq_18.visit__referrer_id = subq_28.visit__referrer_id + GROUP BY + COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) +) subq_29 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_constant_properties__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_constant_properties__plan0.sql new file mode 100644 index 0000000000..b1411229b3 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_constant_properties__plan0.sql @@ -0,0 +1,389 @@ +-- Compute Metrics via Expressions +SELECT + subq_14.metric_time__day + , subq_14.visit__referrer_id + , CAST(subq_14.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_by_session +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) AS metric_time__day + , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id + , MAX(subq_3.visits) AS visits + , MAX(subq_13.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + subq_2.metric_time__day + , subq_2.visit__referrer_id + , SUM(subq_2.visits) AS visits + FROM ( + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'metric_time__day'] + SELECT + subq_1.metric_time__day + , subq_1.visit__referrer_id + , subq_1.visits + 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.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__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.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_0 + ) subq_1 + ) subq_2 + GROUP BY + subq_2.metric_time__day + , subq_2.visit__referrer_id + ) subq_3 + FULL OUTER JOIN ( + -- Aggregate Measures + SELECT + subq_12.metric_time__day + , subq_12.visit__referrer_id + , SUM(subq_12.buys) AS buys + FROM ( + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id', 'metric_time__day'] + SELECT + subq_11.metric_time__day + , subq_11.visit__referrer_id + , subq_11.buys + FROM ( + -- Find conversions for user within the range of 7 day + SELECT + subq_10.ds__day + , subq_10.metric_time__day + , subq_10.user + , subq_10.session + , subq_10.visit__referrer_id + , subq_10.buys + , subq_10.visits + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_6.metric_time__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , first_value(subq_6.session) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session + , subq_9.mf_internal_uuid AS mf_internal_uuid + , subq_9.buys AS buys + FROM ( + -- Pass Only Elements: + -- ['visits', + -- 'visit__referrer_id', + -- 'ds__day', + -- 'metric_time__day', + -- 'user', + -- 'session'] + SELECT + subq_5.ds__day + , subq_5.metric_time__day + , subq_5.user + , subq_5.session + , subq_5.visit__referrer_id + , subq_5.visits + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.visit__ds__day + , subq_4.visit__ds__week + , subq_4.visit__ds__month + , subq_4.visit__ds__quarter + , subq_4.visit__ds__year + , subq_4.visit__ds__extract_year + , subq_4.visit__ds__extract_quarter + , subq_4.visit__ds__extract_month + , subq_4.visit__ds__extract_day + , subq_4.visit__ds__extract_dow + , subq_4.visit__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.session + , subq_4.visit__user + , subq_4.visit__session + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.visits + , subq_4.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_4 + ) subq_5 + ) subq_6 + INNER JOIN ( + -- Add column with generated UUID + 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.buy__ds__day + , subq_8.buy__ds__week + , subq_8.buy__ds__month + , subq_8.buy__ds__quarter + , subq_8.buy__ds__year + , subq_8.buy__ds__extract_year + , subq_8.buy__ds__extract_quarter + , subq_8.buy__ds__extract_month + , subq_8.buy__ds__extract_day + , subq_8.buy__ds__extract_dow + , subq_8.buy__ds__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.user + , subq_8.session_id + , subq_8.buy__user + , subq_8.buy__session_id + , subq_8.buys + , subq_8.buyers + , GEN_RANDOM_UUID() AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.buy__ds__day + , subq_7.buy__ds__week + , subq_7.buy__ds__month + , subq_7.buy__ds__quarter + , subq_7.buy__ds__year + , subq_7.buy__ds__extract_year + , subq_7.buy__ds__extract_quarter + , subq_7.buy__ds__extract_month + , subq_7.buy__ds__extract_day + , subq_7.buy__ds__extract_dow + , subq_7.buy__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.session_id + , subq_7.buy__user + , subq_7.buy__session_id + , subq_7.buys + , subq_7.buyers + FROM ( + -- Read Elements From Semantic Model 'buys_source' + SELECT + 1 AS buys + , buys_source_src_10002.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_10002.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS ds__extract_day + , EXTRACT(isodow FROM buys_source_src_10002.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_10002.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS buy__ds__extract_day + , EXTRACT(isodow FROM buys_source_src_10002.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS buy__ds__extract_doy + , buys_source_src_10002.user_id AS user + , buys_source_src_10002.session_id + , buys_source_src_10002.user_id AS buy__user + , buys_source_src_10002.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_7 + ) subq_8 + ) subq_9 + ON + ( + subq_6.user = subq_9.user + ) AND ( + subq_6.session = subq_9.session_id + ) AND ( + ( + subq_6.ds__day <= subq_9.ds__day + ) AND ( + subq_6.ds__day > subq_9.ds__day - MAKE_INTERVAL(days => 7) + ) + ) + ) subq_10 + ) subq_11 + ) subq_12 + GROUP BY + subq_12.metric_time__day + , subq_12.visit__referrer_id + ) subq_13 + ON + ( + subq_3.visit__referrer_id = subq_13.visit__referrer_id + ) AND ( + subq_3.metric_time__day = subq_13.metric_time__day + ) + GROUP BY + COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) + , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) +) subq_14 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_constant_properties__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_constant_properties__plan0_optimized.sql new file mode 100644 index 0000000000..d996a6005b --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_constant_properties__plan0_optimized.sql @@ -0,0 +1,111 @@ +-- Compute Metrics via Expressions +SELECT + metric_time__day + , visit__referrer_id + , CAST(buys AS DOUBLE PRECISION) / CAST(NULLIF(visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_by_session +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id + , MAX(subq_18.visits) AS visits + , MAX(subq_28.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + metric_time__day + , visit__referrer_id + , SUM(visits) AS visits + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'metric_time__day'] + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + , referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_17 + GROUP BY + metric_time__day + , visit__referrer_id + ) subq_18 + FULL OUTER JOIN ( + -- Find conversions for user within the range of 7 day + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id', 'metric_time__day'] + -- Aggregate Measures + SELECT + metric_time__day + , visit__referrer_id + , SUM(buys) AS buys + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_21.metric_time__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , first_value(subq_21.session) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session + , subq_24.mf_internal_uuid AS mf_internal_uuid + , subq_24.buys AS buys + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', + -- 'visit__referrer_id', + -- 'ds__day', + -- 'metric_time__day', + -- 'user', + -- 'session'] + SELECT + DATE_TRUNC('day', ds) AS ds__day + , DATE_TRUNC('day', ds) AS metric_time__day + , user_id AS user + , session_id AS session + , referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_21 + INNER JOIN ( + -- Read Elements From Semantic Model 'buys_source' + -- Metric Time Dimension 'ds' + -- Add column with generated UUID + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , session_id + , 1 AS buys + , GEN_RANDOM_UUID() AS mf_internal_uuid + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_24 + ON + ( + subq_21.user = subq_24.user + ) AND ( + subq_21.session = subq_24.session_id + ) AND ( + ( + subq_21.ds__day <= subq_24.ds__day + ) AND ( + subq_21.ds__day > subq_24.ds__day - MAKE_INTERVAL(days => 7) + ) + ) + ) subq_25 + GROUP BY + metric_time__day + , visit__referrer_id + ) subq_28 + ON + ( + subq_18.visit__referrer_id = subq_28.visit__referrer_id + ) AND ( + subq_18.metric_time__day = subq_28.metric_time__day + ) + GROUP BY + COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) + , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) +) subq_29 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_no_group_by__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_no_group_by__plan0.sql new file mode 100644 index 0000000000..da9cb2b540 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_no_group_by__plan0.sql @@ -0,0 +1,346 @@ +-- Compute Metrics via Expressions +SELECT + CAST(subq_14.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days +FROM ( + -- Combine Aggregated Outputs + SELECT + MAX(subq_3.visits) AS visits + , MAX(subq_13.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + SUM(subq_2.visits) AS visits + FROM ( + -- Pass Only Elements: + -- ['visits'] + SELECT + subq_1.visits + 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.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__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.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_0 + ) subq_1 + ) subq_2 + ) subq_3 + CROSS JOIN ( + -- Aggregate Measures + SELECT + SUM(subq_12.buys) AS buys + FROM ( + -- Pass Only Elements: + -- ['buys'] + SELECT + subq_11.buys + FROM ( + -- Find conversions for user within the range of 7 day + SELECT + subq_10.ds__day + , subq_10.user + , subq_10.buys + , subq_10.visits + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_9.mf_internal_uuid AS mf_internal_uuid + , subq_9.buys AS buys + FROM ( + -- Pass Only Elements: + -- ['visits', 'ds__day', 'user'] + SELECT + subq_5.ds__day + , subq_5.user + , subq_5.visits + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.visit__ds__day + , subq_4.visit__ds__week + , subq_4.visit__ds__month + , subq_4.visit__ds__quarter + , subq_4.visit__ds__year + , subq_4.visit__ds__extract_year + , subq_4.visit__ds__extract_quarter + , subq_4.visit__ds__extract_month + , subq_4.visit__ds__extract_day + , subq_4.visit__ds__extract_dow + , subq_4.visit__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.session + , subq_4.visit__user + , subq_4.visit__session + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.visits + , subq_4.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_4 + ) subq_5 + ) subq_6 + INNER JOIN ( + -- Add column with generated UUID + 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.buy__ds__day + , subq_8.buy__ds__week + , subq_8.buy__ds__month + , subq_8.buy__ds__quarter + , subq_8.buy__ds__year + , subq_8.buy__ds__extract_year + , subq_8.buy__ds__extract_quarter + , subq_8.buy__ds__extract_month + , subq_8.buy__ds__extract_day + , subq_8.buy__ds__extract_dow + , subq_8.buy__ds__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.user + , subq_8.session_id + , subq_8.buy__user + , subq_8.buy__session_id + , subq_8.buys + , subq_8.buyers + , GEN_RANDOM_UUID() AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.buy__ds__day + , subq_7.buy__ds__week + , subq_7.buy__ds__month + , subq_7.buy__ds__quarter + , subq_7.buy__ds__year + , subq_7.buy__ds__extract_year + , subq_7.buy__ds__extract_quarter + , subq_7.buy__ds__extract_month + , subq_7.buy__ds__extract_day + , subq_7.buy__ds__extract_dow + , subq_7.buy__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.session_id + , subq_7.buy__user + , subq_7.buy__session_id + , subq_7.buys + , subq_7.buyers + FROM ( + -- Read Elements From Semantic Model 'buys_source' + SELECT + 1 AS buys + , buys_source_src_10002.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_10002.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS ds__extract_day + , EXTRACT(isodow FROM buys_source_src_10002.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_10002.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS buy__ds__extract_day + , EXTRACT(isodow FROM buys_source_src_10002.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS buy__ds__extract_doy + , buys_source_src_10002.user_id AS user + , buys_source_src_10002.session_id + , buys_source_src_10002.user_id AS buy__user + , buys_source_src_10002.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_7 + ) subq_8 + ) subq_9 + ON + ( + subq_6.user = subq_9.user + ) AND ( + ( + subq_6.ds__day <= subq_9.ds__day + ) AND ( + subq_6.ds__day > subq_9.ds__day - MAKE_INTERVAL(days => 7) + ) + ) + ) subq_10 + ) subq_11 + ) subq_12 + ) subq_13 +) subq_14 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_no_group_by__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_no_group_by__plan0_optimized.sql new file mode 100644 index 0000000000..0fe378e4c9 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_no_group_by__plan0_optimized.sql @@ -0,0 +1,63 @@ +-- Combine Aggregated Outputs +-- Compute Metrics via Expressions +SELECT + CAST(MAX(subq_28.buys) AS DOUBLE PRECISION) / CAST(NULLIF(MAX(subq_18.visits), 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days +FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits'] + -- Aggregate Measures + SELECT + SUM(1) AS visits + FROM ***************************.fct_visits visits_source_src_10011 +) subq_18 +CROSS JOIN ( + -- Find conversions for user within the range of 7 day + -- Pass Only Elements: + -- ['buys'] + -- Aggregate Measures + SELECT + SUM(buys) AS buys + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_24.mf_internal_uuid AS mf_internal_uuid + , subq_24.buys AS buys + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'ds__day', 'user'] + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_21 + INNER JOIN ( + -- Read Elements From Semantic Model 'buys_source' + -- Metric Time Dimension 'ds' + -- Add column with generated UUID + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , 1 AS buys + , GEN_RANDOM_UUID() AS mf_internal_uuid + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_24 + ON + ( + subq_21.user = subq_24.user + ) AND ( + ( + subq_21.ds__day <= subq_24.ds__day + ) AND ( + subq_21.ds__day > subq_24.ds__day - MAKE_INTERVAL(days => 7) + ) + ) + ) subq_25 +) subq_28 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_window__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_window__plan0.sql new file mode 100644 index 0000000000..cc5ff28b97 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_window__plan0.sql @@ -0,0 +1,379 @@ +-- Compute Metrics via Expressions +SELECT + subq_14.metric_time__day + , subq_14.visit__referrer_id + , CAST(subq_14.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) AS metric_time__day + , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id + , MAX(subq_3.visits) AS visits + , MAX(subq_13.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + subq_2.metric_time__day + , subq_2.visit__referrer_id + , SUM(subq_2.visits) AS visits + FROM ( + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'metric_time__day'] + SELECT + subq_1.metric_time__day + , subq_1.visit__referrer_id + , subq_1.visits + 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.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__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.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_0 + ) subq_1 + ) subq_2 + GROUP BY + subq_2.metric_time__day + , subq_2.visit__referrer_id + ) subq_3 + FULL OUTER JOIN ( + -- Aggregate Measures + SELECT + subq_12.metric_time__day + , subq_12.visit__referrer_id + , SUM(subq_12.buys) AS buys + FROM ( + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id', 'metric_time__day'] + SELECT + subq_11.metric_time__day + , subq_11.visit__referrer_id + , subq_11.buys + FROM ( + -- Find conversions for user within the range of 7 day + SELECT + subq_10.ds__day + , subq_10.metric_time__day + , subq_10.user + , subq_10.visit__referrer_id + , subq_10.buys + , subq_10.visits + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_6.metric_time__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_9.mf_internal_uuid AS mf_internal_uuid + , subq_9.buys AS buys + FROM ( + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user'] + SELECT + subq_5.ds__day + , subq_5.metric_time__day + , subq_5.user + , subq_5.visit__referrer_id + , subq_5.visits + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.visit__ds__day + , subq_4.visit__ds__week + , subq_4.visit__ds__month + , subq_4.visit__ds__quarter + , subq_4.visit__ds__year + , subq_4.visit__ds__extract_year + , subq_4.visit__ds__extract_quarter + , subq_4.visit__ds__extract_month + , subq_4.visit__ds__extract_day + , subq_4.visit__ds__extract_dow + , subq_4.visit__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.session + , subq_4.visit__user + , subq_4.visit__session + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.visits + , subq_4.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_4 + ) subq_5 + ) subq_6 + INNER JOIN ( + -- Add column with generated UUID + 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.buy__ds__day + , subq_8.buy__ds__week + , subq_8.buy__ds__month + , subq_8.buy__ds__quarter + , subq_8.buy__ds__year + , subq_8.buy__ds__extract_year + , subq_8.buy__ds__extract_quarter + , subq_8.buy__ds__extract_month + , subq_8.buy__ds__extract_day + , subq_8.buy__ds__extract_dow + , subq_8.buy__ds__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.user + , subq_8.session_id + , subq_8.buy__user + , subq_8.buy__session_id + , subq_8.buys + , subq_8.buyers + , GEN_RANDOM_UUID() AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.buy__ds__day + , subq_7.buy__ds__week + , subq_7.buy__ds__month + , subq_7.buy__ds__quarter + , subq_7.buy__ds__year + , subq_7.buy__ds__extract_year + , subq_7.buy__ds__extract_quarter + , subq_7.buy__ds__extract_month + , subq_7.buy__ds__extract_day + , subq_7.buy__ds__extract_dow + , subq_7.buy__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.session_id + , subq_7.buy__user + , subq_7.buy__session_id + , subq_7.buys + , subq_7.buyers + FROM ( + -- Read Elements From Semantic Model 'buys_source' + SELECT + 1 AS buys + , buys_source_src_10002.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_10002.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS ds__extract_day + , EXTRACT(isodow FROM buys_source_src_10002.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_10002.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS buy__ds__extract_day + , EXTRACT(isodow FROM buys_source_src_10002.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS buy__ds__extract_doy + , buys_source_src_10002.user_id AS user + , buys_source_src_10002.session_id + , buys_source_src_10002.user_id AS buy__user + , buys_source_src_10002.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_7 + ) subq_8 + ) subq_9 + ON + ( + subq_6.user = subq_9.user + ) AND ( + ( + subq_6.ds__day <= subq_9.ds__day + ) AND ( + subq_6.ds__day > subq_9.ds__day - MAKE_INTERVAL(days => 7) + ) + ) + ) subq_10 + ) subq_11 + ) subq_12 + GROUP BY + subq_12.metric_time__day + , subq_12.visit__referrer_id + ) subq_13 + ON + ( + subq_3.visit__referrer_id = subq_13.visit__referrer_id + ) AND ( + subq_3.metric_time__day = subq_13.metric_time__day + ) + GROUP BY + COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) + , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) +) subq_14 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_window__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_window__plan0_optimized.sql new file mode 100644 index 0000000000..c7f10ab2b7 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_window__plan0_optimized.sql @@ -0,0 +1,101 @@ +-- Compute Metrics via Expressions +SELECT + metric_time__day + , visit__referrer_id + , CAST(buys AS DOUBLE PRECISION) / CAST(NULLIF(visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id + , MAX(subq_18.visits) AS visits + , MAX(subq_28.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + metric_time__day + , visit__referrer_id + , SUM(visits) AS visits + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'metric_time__day'] + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + , referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_17 + GROUP BY + metric_time__day + , visit__referrer_id + ) subq_18 + FULL OUTER JOIN ( + -- Find conversions for user within the range of 7 day + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id', 'metric_time__day'] + -- Aggregate Measures + SELECT + metric_time__day + , visit__referrer_id + , SUM(buys) AS buys + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_21.metric_time__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_24.mf_internal_uuid AS mf_internal_uuid + , subq_24.buys AS buys + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user'] + SELECT + DATE_TRUNC('day', ds) AS ds__day + , DATE_TRUNC('day', ds) AS metric_time__day + , user_id AS user + , referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_21 + INNER JOIN ( + -- Read Elements From Semantic Model 'buys_source' + -- Metric Time Dimension 'ds' + -- Add column with generated UUID + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , 1 AS buys + , GEN_RANDOM_UUID() AS mf_internal_uuid + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_24 + ON + ( + subq_21.user = subq_24.user + ) AND ( + ( + subq_21.ds__day <= subq_24.ds__day + ) AND ( + subq_21.ds__day > subq_24.ds__day - MAKE_INTERVAL(days => 7) + ) + ) + ) subq_25 + GROUP BY + metric_time__day + , visit__referrer_id + ) subq_28 + ON + ( + subq_18.visit__referrer_id = subq_28.visit__referrer_id + ) AND ( + subq_18.metric_time__day = subq_28.metric_time__day + ) + GROUP BY + COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) + , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) +) subq_29 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_count_with_no_group_by__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_count_with_no_group_by__plan0.sql new file mode 100644 index 0000000000..d08df1af63 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_count_with_no_group_by__plan0.sql @@ -0,0 +1,346 @@ +-- Compute Metrics via Expressions +SELECT + subq_14.buys AS visit_buy_conversions +FROM ( + -- Combine Aggregated Outputs + SELECT + MAX(subq_3.visits) AS visits + , COALESCE(MAX(subq_13.buys), 0) AS buys + FROM ( + -- Aggregate Measures + SELECT + SUM(subq_2.visits) AS visits + FROM ( + -- Pass Only Elements: + -- ['visits'] + SELECT + subq_1.visits + 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.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__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.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_10011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_10011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_10011.ds) END AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_10011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_10011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_10011.ds) END AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_0 + ) subq_1 + ) subq_2 + ) subq_3 + CROSS JOIN ( + -- Aggregate Measures + SELECT + SUM(subq_12.buys) AS buys + FROM ( + -- Pass Only Elements: + -- ['buys'] + SELECT + subq_11.buys + FROM ( + -- Find conversions for user within the range of 7 day + SELECT + subq_10.ds__day + , subq_10.user + , subq_10.buys + , subq_10.visits + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_9.mf_internal_uuid AS mf_internal_uuid + , subq_9.buys AS buys + FROM ( + -- Pass Only Elements: + -- ['visits', 'ds__day', 'user'] + SELECT + subq_5.ds__day + , subq_5.user + , subq_5.visits + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.visit__ds__day + , subq_4.visit__ds__week + , subq_4.visit__ds__month + , subq_4.visit__ds__quarter + , subq_4.visit__ds__year + , subq_4.visit__ds__extract_year + , subq_4.visit__ds__extract_quarter + , subq_4.visit__ds__extract_month + , subq_4.visit__ds__extract_day + , subq_4.visit__ds__extract_dow + , subq_4.visit__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.session + , subq_4.visit__user + , subq_4.visit__session + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.visits + , subq_4.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_10011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_10011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_10011.ds) END AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_10011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_10011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_10011.ds) END AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_4 + ) subq_5 + ) subq_6 + INNER JOIN ( + -- Add column with generated UUID + 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.buy__ds__day + , subq_8.buy__ds__week + , subq_8.buy__ds__month + , subq_8.buy__ds__quarter + , subq_8.buy__ds__year + , subq_8.buy__ds__extract_year + , subq_8.buy__ds__extract_quarter + , subq_8.buy__ds__extract_month + , subq_8.buy__ds__extract_day + , subq_8.buy__ds__extract_dow + , subq_8.buy__ds__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.user + , subq_8.session_id + , subq_8.buy__user + , subq_8.buy__session_id + , subq_8.buys + , subq_8.buyers + , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.buy__ds__day + , subq_7.buy__ds__week + , subq_7.buy__ds__month + , subq_7.buy__ds__quarter + , subq_7.buy__ds__year + , subq_7.buy__ds__extract_year + , subq_7.buy__ds__extract_quarter + , subq_7.buy__ds__extract_month + , subq_7.buy__ds__extract_day + , subq_7.buy__ds__extract_dow + , subq_7.buy__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.session_id + , subq_7.buy__user + , subq_7.buy__session_id + , subq_7.buys + , subq_7.buyers + FROM ( + -- Read Elements From Semantic Model 'buys_source' + SELECT + 1 AS buys + , buys_source_src_10002.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_10002.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM buys_source_src_10002.ds) = 0 THEN EXTRACT(dow FROM buys_source_src_10002.ds) + 7 ELSE EXTRACT(dow FROM buys_source_src_10002.ds) END AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_10002.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS buy__ds__extract_day + , CASE WHEN EXTRACT(dow FROM buys_source_src_10002.ds) = 0 THEN EXTRACT(dow FROM buys_source_src_10002.ds) + 7 ELSE EXTRACT(dow FROM buys_source_src_10002.ds) END AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS buy__ds__extract_doy + , buys_source_src_10002.user_id AS user + , buys_source_src_10002.session_id + , buys_source_src_10002.user_id AS buy__user + , buys_source_src_10002.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_7 + ) subq_8 + ) subq_9 + ON + ( + subq_6.user = subq_9.user + ) AND ( + ( + subq_6.ds__day <= subq_9.ds__day + ) AND ( + subq_6.ds__day > DATEADD(day, -7, subq_9.ds__day) + ) + ) + ) subq_10 + ) subq_11 + ) subq_12 + ) subq_13 +) subq_14 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_count_with_no_group_by__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_count_with_no_group_by__plan0_optimized.sql new file mode 100644 index 0000000000..baf3a6e10a --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_count_with_no_group_by__plan0_optimized.sql @@ -0,0 +1,63 @@ +-- Combine Aggregated Outputs +-- Compute Metrics via Expressions +SELECT + COALESCE(MAX(subq_28.buys), 0) AS visit_buy_conversions +FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits'] + -- Aggregate Measures + SELECT + SUM(1) AS visits + FROM ***************************.fct_visits visits_source_src_10011 +) subq_18 +CROSS JOIN ( + -- Find conversions for user within the range of 7 day + -- Pass Only Elements: + -- ['buys'] + -- Aggregate Measures + SELECT + SUM(buys) AS buys + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_24.mf_internal_uuid AS mf_internal_uuid + , subq_24.buys AS buys + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'ds__day', 'user'] + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_21 + INNER JOIN ( + -- Read Elements From Semantic Model 'buys_source' + -- Metric Time Dimension 'ds' + -- Add column with generated UUID + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , 1 AS buys + , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_24 + ON + ( + subq_21.user = subq_24.user + ) AND ( + ( + subq_21.ds__day <= subq_24.ds__day + ) AND ( + subq_21.ds__day > DATEADD(day, -7, subq_24.ds__day) + ) + ) + ) subq_25 +) subq_28 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate__plan0.sql new file mode 100644 index 0000000000..9fafac0e1e --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate__plan0.sql @@ -0,0 +1,355 @@ +-- Compute Metrics via Expressions +SELECT + subq_14.visit__referrer_id + , CAST(subq_14.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id + , MAX(subq_3.visits) AS visits + , MAX(subq_13.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + subq_2.visit__referrer_id + , SUM(subq_2.visits) AS visits + FROM ( + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id'] + SELECT + subq_1.visit__referrer_id + , subq_1.visits + 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.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__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.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_10011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_10011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_10011.ds) END AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_10011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_10011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_10011.ds) END AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_0 + ) subq_1 + ) subq_2 + GROUP BY + subq_2.visit__referrer_id + ) subq_3 + FULL OUTER JOIN ( + -- Aggregate Measures + SELECT + subq_12.visit__referrer_id + , SUM(subq_12.buys) AS buys + FROM ( + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id'] + SELECT + subq_11.visit__referrer_id + , subq_11.buys + FROM ( + -- Find conversions for user within the range of INF + SELECT + subq_10.ds__day + , subq_10.user + , subq_10.visit__referrer_id + , subq_10.buys + , subq_10.visits + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_9.mf_internal_uuid AS mf_internal_uuid + , subq_9.buys AS buys + FROM ( + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'ds__day', 'user'] + SELECT + subq_5.ds__day + , subq_5.user + , subq_5.visit__referrer_id + , subq_5.visits + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.visit__ds__day + , subq_4.visit__ds__week + , subq_4.visit__ds__month + , subq_4.visit__ds__quarter + , subq_4.visit__ds__year + , subq_4.visit__ds__extract_year + , subq_4.visit__ds__extract_quarter + , subq_4.visit__ds__extract_month + , subq_4.visit__ds__extract_day + , subq_4.visit__ds__extract_dow + , subq_4.visit__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.session + , subq_4.visit__user + , subq_4.visit__session + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.visits + , subq_4.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_10011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_10011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_10011.ds) END AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_10011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_10011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_10011.ds) END AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_4 + ) subq_5 + ) subq_6 + INNER JOIN ( + -- Add column with generated UUID + 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.buy__ds__day + , subq_8.buy__ds__week + , subq_8.buy__ds__month + , subq_8.buy__ds__quarter + , subq_8.buy__ds__year + , subq_8.buy__ds__extract_year + , subq_8.buy__ds__extract_quarter + , subq_8.buy__ds__extract_month + , subq_8.buy__ds__extract_day + , subq_8.buy__ds__extract_dow + , subq_8.buy__ds__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.user + , subq_8.session_id + , subq_8.buy__user + , subq_8.buy__session_id + , subq_8.buys + , subq_8.buyers + , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.buy__ds__day + , subq_7.buy__ds__week + , subq_7.buy__ds__month + , subq_7.buy__ds__quarter + , subq_7.buy__ds__year + , subq_7.buy__ds__extract_year + , subq_7.buy__ds__extract_quarter + , subq_7.buy__ds__extract_month + , subq_7.buy__ds__extract_day + , subq_7.buy__ds__extract_dow + , subq_7.buy__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.session_id + , subq_7.buy__user + , subq_7.buy__session_id + , subq_7.buys + , subq_7.buyers + FROM ( + -- Read Elements From Semantic Model 'buys_source' + SELECT + 1 AS buys + , buys_source_src_10002.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_10002.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM buys_source_src_10002.ds) = 0 THEN EXTRACT(dow FROM buys_source_src_10002.ds) + 7 ELSE EXTRACT(dow FROM buys_source_src_10002.ds) END AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_10002.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS buy__ds__extract_day + , CASE WHEN EXTRACT(dow FROM buys_source_src_10002.ds) = 0 THEN EXTRACT(dow FROM buys_source_src_10002.ds) + 7 ELSE EXTRACT(dow FROM buys_source_src_10002.ds) END AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS buy__ds__extract_doy + , buys_source_src_10002.user_id AS user + , buys_source_src_10002.session_id + , buys_source_src_10002.user_id AS buy__user + , buys_source_src_10002.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_7 + ) subq_8 + ) subq_9 + ON + (subq_6.user = subq_9.user) AND ((subq_6.ds__day <= subq_9.ds__day)) + ) subq_10 + ) subq_11 + ) subq_12 + GROUP BY + subq_12.visit__referrer_id + ) subq_13 + ON + subq_3.visit__referrer_id = subq_13.visit__referrer_id + GROUP BY + COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) +) subq_14 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate__plan0_optimized.sql new file mode 100644 index 0000000000..cb844c2a51 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate__plan0_optimized.sql @@ -0,0 +1,83 @@ +-- Compute Metrics via Expressions +SELECT + visit__referrer_id + , CAST(buys AS DOUBLE PRECISION) / CAST(NULLIF(visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id + , MAX(subq_18.visits) AS visits + , MAX(subq_28.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + visit__referrer_id + , SUM(visits) AS visits + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id'] + SELECT + referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_17 + GROUP BY + visit__referrer_id + ) subq_18 + FULL OUTER JOIN ( + -- Find conversions for user within the range of INF + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id'] + -- Aggregate Measures + SELECT + visit__referrer_id + , SUM(buys) AS buys + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_24.mf_internal_uuid AS mf_internal_uuid + , subq_24.buys AS buys + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'ds__day', 'user'] + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_21 + INNER JOIN ( + -- Read Elements From Semantic Model 'buys_source' + -- Metric Time Dimension 'ds' + -- Add column with generated UUID + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , 1 AS buys + , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_24 + ON + ( + subq_21.user = subq_24.user + ) AND ( + (subq_21.ds__day <= subq_24.ds__day) + ) + ) subq_25 + GROUP BY + visit__referrer_id + ) subq_28 + ON + subq_18.visit__referrer_id = subq_28.visit__referrer_id + GROUP BY + COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) +) subq_29 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_constant_properties__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_constant_properties__plan0.sql new file mode 100644 index 0000000000..4c2da672c9 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_constant_properties__plan0.sql @@ -0,0 +1,389 @@ +-- Compute Metrics via Expressions +SELECT + subq_14.metric_time__day + , subq_14.visit__referrer_id + , CAST(subq_14.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_by_session +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) AS metric_time__day + , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id + , MAX(subq_3.visits) AS visits + , MAX(subq_13.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + subq_2.metric_time__day + , subq_2.visit__referrer_id + , SUM(subq_2.visits) AS visits + FROM ( + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'metric_time__day'] + SELECT + subq_1.metric_time__day + , subq_1.visit__referrer_id + , subq_1.visits + 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.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__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.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_10011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_10011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_10011.ds) END AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_10011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_10011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_10011.ds) END AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_0 + ) subq_1 + ) subq_2 + GROUP BY + subq_2.metric_time__day + , subq_2.visit__referrer_id + ) subq_3 + FULL OUTER JOIN ( + -- Aggregate Measures + SELECT + subq_12.metric_time__day + , subq_12.visit__referrer_id + , SUM(subq_12.buys) AS buys + FROM ( + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id', 'metric_time__day'] + SELECT + subq_11.metric_time__day + , subq_11.visit__referrer_id + , subq_11.buys + FROM ( + -- Find conversions for user within the range of 7 day + SELECT + subq_10.ds__day + , subq_10.metric_time__day + , subq_10.user + , subq_10.session + , subq_10.visit__referrer_id + , subq_10.buys + , subq_10.visits + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_6.metric_time__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , first_value(subq_6.session) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session + , subq_9.mf_internal_uuid AS mf_internal_uuid + , subq_9.buys AS buys + FROM ( + -- Pass Only Elements: + -- ['visits', + -- 'visit__referrer_id', + -- 'ds__day', + -- 'metric_time__day', + -- 'user', + -- 'session'] + SELECT + subq_5.ds__day + , subq_5.metric_time__day + , subq_5.user + , subq_5.session + , subq_5.visit__referrer_id + , subq_5.visits + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.visit__ds__day + , subq_4.visit__ds__week + , subq_4.visit__ds__month + , subq_4.visit__ds__quarter + , subq_4.visit__ds__year + , subq_4.visit__ds__extract_year + , subq_4.visit__ds__extract_quarter + , subq_4.visit__ds__extract_month + , subq_4.visit__ds__extract_day + , subq_4.visit__ds__extract_dow + , subq_4.visit__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.session + , subq_4.visit__user + , subq_4.visit__session + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.visits + , subq_4.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_10011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_10011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_10011.ds) END AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_10011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_10011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_10011.ds) END AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_4 + ) subq_5 + ) subq_6 + INNER JOIN ( + -- Add column with generated UUID + 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.buy__ds__day + , subq_8.buy__ds__week + , subq_8.buy__ds__month + , subq_8.buy__ds__quarter + , subq_8.buy__ds__year + , subq_8.buy__ds__extract_year + , subq_8.buy__ds__extract_quarter + , subq_8.buy__ds__extract_month + , subq_8.buy__ds__extract_day + , subq_8.buy__ds__extract_dow + , subq_8.buy__ds__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.user + , subq_8.session_id + , subq_8.buy__user + , subq_8.buy__session_id + , subq_8.buys + , subq_8.buyers + , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.buy__ds__day + , subq_7.buy__ds__week + , subq_7.buy__ds__month + , subq_7.buy__ds__quarter + , subq_7.buy__ds__year + , subq_7.buy__ds__extract_year + , subq_7.buy__ds__extract_quarter + , subq_7.buy__ds__extract_month + , subq_7.buy__ds__extract_day + , subq_7.buy__ds__extract_dow + , subq_7.buy__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.session_id + , subq_7.buy__user + , subq_7.buy__session_id + , subq_7.buys + , subq_7.buyers + FROM ( + -- Read Elements From Semantic Model 'buys_source' + SELECT + 1 AS buys + , buys_source_src_10002.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_10002.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM buys_source_src_10002.ds) = 0 THEN EXTRACT(dow FROM buys_source_src_10002.ds) + 7 ELSE EXTRACT(dow FROM buys_source_src_10002.ds) END AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_10002.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS buy__ds__extract_day + , CASE WHEN EXTRACT(dow FROM buys_source_src_10002.ds) = 0 THEN EXTRACT(dow FROM buys_source_src_10002.ds) + 7 ELSE EXTRACT(dow FROM buys_source_src_10002.ds) END AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS buy__ds__extract_doy + , buys_source_src_10002.user_id AS user + , buys_source_src_10002.session_id + , buys_source_src_10002.user_id AS buy__user + , buys_source_src_10002.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_7 + ) subq_8 + ) subq_9 + ON + ( + subq_6.user = subq_9.user + ) AND ( + subq_6.session = subq_9.session_id + ) AND ( + ( + subq_6.ds__day <= subq_9.ds__day + ) AND ( + subq_6.ds__day > DATEADD(day, -7, subq_9.ds__day) + ) + ) + ) subq_10 + ) subq_11 + ) subq_12 + GROUP BY + subq_12.metric_time__day + , subq_12.visit__referrer_id + ) subq_13 + ON + ( + subq_3.visit__referrer_id = subq_13.visit__referrer_id + ) AND ( + subq_3.metric_time__day = subq_13.metric_time__day + ) + GROUP BY + COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) + , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) +) subq_14 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_constant_properties__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_constant_properties__plan0_optimized.sql new file mode 100644 index 0000000000..b3a9dd9462 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_constant_properties__plan0_optimized.sql @@ -0,0 +1,111 @@ +-- Compute Metrics via Expressions +SELECT + metric_time__day + , visit__referrer_id + , CAST(buys AS DOUBLE PRECISION) / CAST(NULLIF(visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_by_session +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id + , MAX(subq_18.visits) AS visits + , MAX(subq_28.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + metric_time__day + , visit__referrer_id + , SUM(visits) AS visits + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'metric_time__day'] + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + , referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_17 + GROUP BY + metric_time__day + , visit__referrer_id + ) subq_18 + FULL OUTER JOIN ( + -- Find conversions for user within the range of 7 day + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id', 'metric_time__day'] + -- Aggregate Measures + SELECT + metric_time__day + , visit__referrer_id + , SUM(buys) AS buys + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_21.metric_time__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , first_value(subq_21.session) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session + , subq_24.mf_internal_uuid AS mf_internal_uuid + , subq_24.buys AS buys + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', + -- 'visit__referrer_id', + -- 'ds__day', + -- 'metric_time__day', + -- 'user', + -- 'session'] + SELECT + DATE_TRUNC('day', ds) AS ds__day + , DATE_TRUNC('day', ds) AS metric_time__day + , user_id AS user + , session_id AS session + , referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_21 + INNER JOIN ( + -- Read Elements From Semantic Model 'buys_source' + -- Metric Time Dimension 'ds' + -- Add column with generated UUID + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , session_id + , 1 AS buys + , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_24 + ON + ( + subq_21.user = subq_24.user + ) AND ( + subq_21.session = subq_24.session_id + ) AND ( + ( + subq_21.ds__day <= subq_24.ds__day + ) AND ( + subq_21.ds__day > DATEADD(day, -7, subq_24.ds__day) + ) + ) + ) subq_25 + GROUP BY + metric_time__day + , visit__referrer_id + ) subq_28 + ON + ( + subq_18.visit__referrer_id = subq_28.visit__referrer_id + ) AND ( + subq_18.metric_time__day = subq_28.metric_time__day + ) + GROUP BY + COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) + , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) +) subq_29 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_no_group_by__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_no_group_by__plan0.sql new file mode 100644 index 0000000000..5ff0fb8078 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_no_group_by__plan0.sql @@ -0,0 +1,346 @@ +-- Compute Metrics via Expressions +SELECT + CAST(subq_14.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days +FROM ( + -- Combine Aggregated Outputs + SELECT + MAX(subq_3.visits) AS visits + , MAX(subq_13.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + SUM(subq_2.visits) AS visits + FROM ( + -- Pass Only Elements: + -- ['visits'] + SELECT + subq_1.visits + 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.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__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.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_10011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_10011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_10011.ds) END AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_10011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_10011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_10011.ds) END AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_0 + ) subq_1 + ) subq_2 + ) subq_3 + CROSS JOIN ( + -- Aggregate Measures + SELECT + SUM(subq_12.buys) AS buys + FROM ( + -- Pass Only Elements: + -- ['buys'] + SELECT + subq_11.buys + FROM ( + -- Find conversions for user within the range of 7 day + SELECT + subq_10.ds__day + , subq_10.user + , subq_10.buys + , subq_10.visits + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_9.mf_internal_uuid AS mf_internal_uuid + , subq_9.buys AS buys + FROM ( + -- Pass Only Elements: + -- ['visits', 'ds__day', 'user'] + SELECT + subq_5.ds__day + , subq_5.user + , subq_5.visits + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.visit__ds__day + , subq_4.visit__ds__week + , subq_4.visit__ds__month + , subq_4.visit__ds__quarter + , subq_4.visit__ds__year + , subq_4.visit__ds__extract_year + , subq_4.visit__ds__extract_quarter + , subq_4.visit__ds__extract_month + , subq_4.visit__ds__extract_day + , subq_4.visit__ds__extract_dow + , subq_4.visit__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.session + , subq_4.visit__user + , subq_4.visit__session + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.visits + , subq_4.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_10011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_10011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_10011.ds) END AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_10011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_10011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_10011.ds) END AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_4 + ) subq_5 + ) subq_6 + INNER JOIN ( + -- Add column with generated UUID + 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.buy__ds__day + , subq_8.buy__ds__week + , subq_8.buy__ds__month + , subq_8.buy__ds__quarter + , subq_8.buy__ds__year + , subq_8.buy__ds__extract_year + , subq_8.buy__ds__extract_quarter + , subq_8.buy__ds__extract_month + , subq_8.buy__ds__extract_day + , subq_8.buy__ds__extract_dow + , subq_8.buy__ds__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.user + , subq_8.session_id + , subq_8.buy__user + , subq_8.buy__session_id + , subq_8.buys + , subq_8.buyers + , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.buy__ds__day + , subq_7.buy__ds__week + , subq_7.buy__ds__month + , subq_7.buy__ds__quarter + , subq_7.buy__ds__year + , subq_7.buy__ds__extract_year + , subq_7.buy__ds__extract_quarter + , subq_7.buy__ds__extract_month + , subq_7.buy__ds__extract_day + , subq_7.buy__ds__extract_dow + , subq_7.buy__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.session_id + , subq_7.buy__user + , subq_7.buy__session_id + , subq_7.buys + , subq_7.buyers + FROM ( + -- Read Elements From Semantic Model 'buys_source' + SELECT + 1 AS buys + , buys_source_src_10002.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_10002.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM buys_source_src_10002.ds) = 0 THEN EXTRACT(dow FROM buys_source_src_10002.ds) + 7 ELSE EXTRACT(dow FROM buys_source_src_10002.ds) END AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_10002.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS buy__ds__extract_day + , CASE WHEN EXTRACT(dow FROM buys_source_src_10002.ds) = 0 THEN EXTRACT(dow FROM buys_source_src_10002.ds) + 7 ELSE EXTRACT(dow FROM buys_source_src_10002.ds) END AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS buy__ds__extract_doy + , buys_source_src_10002.user_id AS user + , buys_source_src_10002.session_id + , buys_source_src_10002.user_id AS buy__user + , buys_source_src_10002.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_7 + ) subq_8 + ) subq_9 + ON + ( + subq_6.user = subq_9.user + ) AND ( + ( + subq_6.ds__day <= subq_9.ds__day + ) AND ( + subq_6.ds__day > DATEADD(day, -7, subq_9.ds__day) + ) + ) + ) subq_10 + ) subq_11 + ) subq_12 + ) subq_13 +) subq_14 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_no_group_by__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_no_group_by__plan0_optimized.sql new file mode 100644 index 0000000000..82ad07a281 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_no_group_by__plan0_optimized.sql @@ -0,0 +1,63 @@ +-- Combine Aggregated Outputs +-- Compute Metrics via Expressions +SELECT + CAST(MAX(subq_28.buys) AS DOUBLE PRECISION) / CAST(NULLIF(MAX(subq_18.visits), 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days +FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits'] + -- Aggregate Measures + SELECT + SUM(1) AS visits + FROM ***************************.fct_visits visits_source_src_10011 +) subq_18 +CROSS JOIN ( + -- Find conversions for user within the range of 7 day + -- Pass Only Elements: + -- ['buys'] + -- Aggregate Measures + SELECT + SUM(buys) AS buys + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_24.mf_internal_uuid AS mf_internal_uuid + , subq_24.buys AS buys + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'ds__day', 'user'] + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_21 + INNER JOIN ( + -- Read Elements From Semantic Model 'buys_source' + -- Metric Time Dimension 'ds' + -- Add column with generated UUID + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , 1 AS buys + , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_24 + ON + ( + subq_21.user = subq_24.user + ) AND ( + ( + subq_21.ds__day <= subq_24.ds__day + ) AND ( + subq_21.ds__day > DATEADD(day, -7, subq_24.ds__day) + ) + ) + ) subq_25 +) subq_28 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_window__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_window__plan0.sql new file mode 100644 index 0000000000..2a46119e14 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_window__plan0.sql @@ -0,0 +1,379 @@ +-- Compute Metrics via Expressions +SELECT + subq_14.metric_time__day + , subq_14.visit__referrer_id + , CAST(subq_14.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) AS metric_time__day + , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id + , MAX(subq_3.visits) AS visits + , MAX(subq_13.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + subq_2.metric_time__day + , subq_2.visit__referrer_id + , SUM(subq_2.visits) AS visits + FROM ( + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'metric_time__day'] + SELECT + subq_1.metric_time__day + , subq_1.visit__referrer_id + , subq_1.visits + 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.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__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.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_10011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_10011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_10011.ds) END AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_10011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_10011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_10011.ds) END AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_0 + ) subq_1 + ) subq_2 + GROUP BY + subq_2.metric_time__day + , subq_2.visit__referrer_id + ) subq_3 + FULL OUTER JOIN ( + -- Aggregate Measures + SELECT + subq_12.metric_time__day + , subq_12.visit__referrer_id + , SUM(subq_12.buys) AS buys + FROM ( + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id', 'metric_time__day'] + SELECT + subq_11.metric_time__day + , subq_11.visit__referrer_id + , subq_11.buys + FROM ( + -- Find conversions for user within the range of 7 day + SELECT + subq_10.ds__day + , subq_10.metric_time__day + , subq_10.user + , subq_10.visit__referrer_id + , subq_10.buys + , subq_10.visits + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_6.metric_time__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_9.mf_internal_uuid AS mf_internal_uuid + , subq_9.buys AS buys + FROM ( + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user'] + SELECT + subq_5.ds__day + , subq_5.metric_time__day + , subq_5.user + , subq_5.visit__referrer_id + , subq_5.visits + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.visit__ds__day + , subq_4.visit__ds__week + , subq_4.visit__ds__month + , subq_4.visit__ds__quarter + , subq_4.visit__ds__year + , subq_4.visit__ds__extract_year + , subq_4.visit__ds__extract_quarter + , subq_4.visit__ds__extract_month + , subq_4.visit__ds__extract_day + , subq_4.visit__ds__extract_dow + , subq_4.visit__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.session + , subq_4.visit__user + , subq_4.visit__session + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.visits + , subq_4.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_10011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_10011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_10011.ds) END AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_10011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_10011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_10011.ds) END AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_4 + ) subq_5 + ) subq_6 + INNER JOIN ( + -- Add column with generated UUID + 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.buy__ds__day + , subq_8.buy__ds__week + , subq_8.buy__ds__month + , subq_8.buy__ds__quarter + , subq_8.buy__ds__year + , subq_8.buy__ds__extract_year + , subq_8.buy__ds__extract_quarter + , subq_8.buy__ds__extract_month + , subq_8.buy__ds__extract_day + , subq_8.buy__ds__extract_dow + , subq_8.buy__ds__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.user + , subq_8.session_id + , subq_8.buy__user + , subq_8.buy__session_id + , subq_8.buys + , subq_8.buyers + , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.buy__ds__day + , subq_7.buy__ds__week + , subq_7.buy__ds__month + , subq_7.buy__ds__quarter + , subq_7.buy__ds__year + , subq_7.buy__ds__extract_year + , subq_7.buy__ds__extract_quarter + , subq_7.buy__ds__extract_month + , subq_7.buy__ds__extract_day + , subq_7.buy__ds__extract_dow + , subq_7.buy__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.session_id + , subq_7.buy__user + , subq_7.buy__session_id + , subq_7.buys + , subq_7.buyers + FROM ( + -- Read Elements From Semantic Model 'buys_source' + SELECT + 1 AS buys + , buys_source_src_10002.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_10002.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM buys_source_src_10002.ds) = 0 THEN EXTRACT(dow FROM buys_source_src_10002.ds) + 7 ELSE EXTRACT(dow FROM buys_source_src_10002.ds) END AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_10002.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS buy__ds__extract_day + , CASE WHEN EXTRACT(dow FROM buys_source_src_10002.ds) = 0 THEN EXTRACT(dow FROM buys_source_src_10002.ds) + 7 ELSE EXTRACT(dow FROM buys_source_src_10002.ds) END AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS buy__ds__extract_doy + , buys_source_src_10002.user_id AS user + , buys_source_src_10002.session_id + , buys_source_src_10002.user_id AS buy__user + , buys_source_src_10002.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_7 + ) subq_8 + ) subq_9 + ON + ( + subq_6.user = subq_9.user + ) AND ( + ( + subq_6.ds__day <= subq_9.ds__day + ) AND ( + subq_6.ds__day > DATEADD(day, -7, subq_9.ds__day) + ) + ) + ) subq_10 + ) subq_11 + ) subq_12 + GROUP BY + subq_12.metric_time__day + , subq_12.visit__referrer_id + ) subq_13 + ON + ( + subq_3.visit__referrer_id = subq_13.visit__referrer_id + ) AND ( + subq_3.metric_time__day = subq_13.metric_time__day + ) + GROUP BY + COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) + , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) +) subq_14 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_window__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_window__plan0_optimized.sql new file mode 100644 index 0000000000..68d8111ff1 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_window__plan0_optimized.sql @@ -0,0 +1,101 @@ +-- Compute Metrics via Expressions +SELECT + metric_time__day + , visit__referrer_id + , CAST(buys AS DOUBLE PRECISION) / CAST(NULLIF(visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id + , MAX(subq_18.visits) AS visits + , MAX(subq_28.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + metric_time__day + , visit__referrer_id + , SUM(visits) AS visits + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'metric_time__day'] + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + , referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_17 + GROUP BY + metric_time__day + , visit__referrer_id + ) subq_18 + FULL OUTER JOIN ( + -- Find conversions for user within the range of 7 day + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id', 'metric_time__day'] + -- Aggregate Measures + SELECT + metric_time__day + , visit__referrer_id + , SUM(buys) AS buys + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_21.metric_time__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_24.mf_internal_uuid AS mf_internal_uuid + , subq_24.buys AS buys + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user'] + SELECT + DATE_TRUNC('day', ds) AS ds__day + , DATE_TRUNC('day', ds) AS metric_time__day + , user_id AS user + , referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_21 + INNER JOIN ( + -- Read Elements From Semantic Model 'buys_source' + -- Metric Time Dimension 'ds' + -- Add column with generated UUID + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , 1 AS buys + , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_24 + ON + ( + subq_21.user = subq_24.user + ) AND ( + ( + subq_21.ds__day <= subq_24.ds__day + ) AND ( + subq_21.ds__day > DATEADD(day, -7, subq_24.ds__day) + ) + ) + ) subq_25 + GROUP BY + metric_time__day + , visit__referrer_id + ) subq_28 + ON + ( + subq_18.visit__referrer_id = subq_28.visit__referrer_id + ) AND ( + subq_18.metric_time__day = subq_28.metric_time__day + ) + GROUP BY + COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) + , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) +) subq_29 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_count_with_no_group_by__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_count_with_no_group_by__plan0.sql new file mode 100644 index 0000000000..5672b7b52a --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_count_with_no_group_by__plan0.sql @@ -0,0 +1,346 @@ +-- Compute Metrics via Expressions +SELECT + subq_14.buys AS visit_buy_conversions +FROM ( + -- Combine Aggregated Outputs + SELECT + MAX(subq_3.visits) AS visits + , COALESCE(MAX(subq_13.buys), 0) AS buys + FROM ( + -- Aggregate Measures + SELECT + SUM(subq_2.visits) AS visits + FROM ( + -- Pass Only Elements: + -- ['visits'] + SELECT + subq_1.visits + 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.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__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.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_0 + ) subq_1 + ) subq_2 + ) subq_3 + CROSS JOIN ( + -- Aggregate Measures + SELECT + SUM(subq_12.buys) AS buys + FROM ( + -- Pass Only Elements: + -- ['buys'] + SELECT + subq_11.buys + FROM ( + -- Find conversions for user within the range of 7 day + SELECT + subq_10.ds__day + , subq_10.user + , subq_10.buys + , subq_10.visits + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_9.mf_internal_uuid AS mf_internal_uuid + , subq_9.buys AS buys + FROM ( + -- Pass Only Elements: + -- ['visits', 'ds__day', 'user'] + SELECT + subq_5.ds__day + , subq_5.user + , subq_5.visits + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.visit__ds__day + , subq_4.visit__ds__week + , subq_4.visit__ds__month + , subq_4.visit__ds__quarter + , subq_4.visit__ds__year + , subq_4.visit__ds__extract_year + , subq_4.visit__ds__extract_quarter + , subq_4.visit__ds__extract_month + , subq_4.visit__ds__extract_day + , subq_4.visit__ds__extract_dow + , subq_4.visit__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.session + , subq_4.visit__user + , subq_4.visit__session + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.visits + , subq_4.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_4 + ) subq_5 + ) subq_6 + INNER JOIN ( + -- Add column with generated UUID + 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.buy__ds__day + , subq_8.buy__ds__week + , subq_8.buy__ds__month + , subq_8.buy__ds__quarter + , subq_8.buy__ds__year + , subq_8.buy__ds__extract_year + , subq_8.buy__ds__extract_quarter + , subq_8.buy__ds__extract_month + , subq_8.buy__ds__extract_day + , subq_8.buy__ds__extract_dow + , subq_8.buy__ds__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.user + , subq_8.session_id + , subq_8.buy__user + , subq_8.buy__session_id + , subq_8.buys + , subq_8.buyers + , UUID_STRING() AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.buy__ds__day + , subq_7.buy__ds__week + , subq_7.buy__ds__month + , subq_7.buy__ds__quarter + , subq_7.buy__ds__year + , subq_7.buy__ds__extract_year + , subq_7.buy__ds__extract_quarter + , subq_7.buy__ds__extract_month + , subq_7.buy__ds__extract_day + , subq_7.buy__ds__extract_dow + , subq_7.buy__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.session_id + , subq_7.buy__user + , subq_7.buy__session_id + , subq_7.buys + , subq_7.buyers + FROM ( + -- Read Elements From Semantic Model 'buys_source' + SELECT + 1 AS buys + , buys_source_src_10002.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_10002.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM buys_source_src_10002.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_10002.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS buy__ds__extract_day + , EXTRACT(dayofweekiso FROM buys_source_src_10002.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS buy__ds__extract_doy + , buys_source_src_10002.user_id AS user + , buys_source_src_10002.session_id + , buys_source_src_10002.user_id AS buy__user + , buys_source_src_10002.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_7 + ) subq_8 + ) subq_9 + ON + ( + subq_6.user = subq_9.user + ) AND ( + ( + subq_6.ds__day <= subq_9.ds__day + ) AND ( + subq_6.ds__day > DATEADD(day, -7, subq_9.ds__day) + ) + ) + ) subq_10 + ) subq_11 + ) subq_12 + ) subq_13 +) subq_14 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_count_with_no_group_by__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_count_with_no_group_by__plan0_optimized.sql new file mode 100644 index 0000000000..70b48a4901 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_count_with_no_group_by__plan0_optimized.sql @@ -0,0 +1,63 @@ +-- Combine Aggregated Outputs +-- Compute Metrics via Expressions +SELECT + COALESCE(MAX(subq_28.buys), 0) AS visit_buy_conversions +FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits'] + -- Aggregate Measures + SELECT + SUM(1) AS visits + FROM ***************************.fct_visits visits_source_src_10011 +) subq_18 +CROSS JOIN ( + -- Find conversions for user within the range of 7 day + -- Pass Only Elements: + -- ['buys'] + -- Aggregate Measures + SELECT + SUM(buys) AS buys + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_24.mf_internal_uuid AS mf_internal_uuid + , subq_24.buys AS buys + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'ds__day', 'user'] + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_21 + INNER JOIN ( + -- Read Elements From Semantic Model 'buys_source' + -- Metric Time Dimension 'ds' + -- Add column with generated UUID + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , 1 AS buys + , UUID_STRING() AS mf_internal_uuid + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_24 + ON + ( + subq_21.user = subq_24.user + ) AND ( + ( + subq_21.ds__day <= subq_24.ds__day + ) AND ( + subq_21.ds__day > DATEADD(day, -7, subq_24.ds__day) + ) + ) + ) subq_25 +) subq_28 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate__plan0.sql new file mode 100644 index 0000000000..5aeab65154 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate__plan0.sql @@ -0,0 +1,355 @@ +-- Compute Metrics via Expressions +SELECT + subq_14.visit__referrer_id + , CAST(subq_14.buys AS DOUBLE) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id + , MAX(subq_3.visits) AS visits + , MAX(subq_13.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + subq_2.visit__referrer_id + , SUM(subq_2.visits) AS visits + FROM ( + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id'] + SELECT + subq_1.visit__referrer_id + , subq_1.visits + 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.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__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.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_0 + ) subq_1 + ) subq_2 + GROUP BY + subq_2.visit__referrer_id + ) subq_3 + FULL OUTER JOIN ( + -- Aggregate Measures + SELECT + subq_12.visit__referrer_id + , SUM(subq_12.buys) AS buys + FROM ( + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id'] + SELECT + subq_11.visit__referrer_id + , subq_11.buys + FROM ( + -- Find conversions for user within the range of INF + SELECT + subq_10.ds__day + , subq_10.user + , subq_10.visit__referrer_id + , subq_10.buys + , subq_10.visits + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_9.mf_internal_uuid AS mf_internal_uuid + , subq_9.buys AS buys + FROM ( + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'ds__day', 'user'] + SELECT + subq_5.ds__day + , subq_5.user + , subq_5.visit__referrer_id + , subq_5.visits + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.visit__ds__day + , subq_4.visit__ds__week + , subq_4.visit__ds__month + , subq_4.visit__ds__quarter + , subq_4.visit__ds__year + , subq_4.visit__ds__extract_year + , subq_4.visit__ds__extract_quarter + , subq_4.visit__ds__extract_month + , subq_4.visit__ds__extract_day + , subq_4.visit__ds__extract_dow + , subq_4.visit__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.session + , subq_4.visit__user + , subq_4.visit__session + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.visits + , subq_4.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_4 + ) subq_5 + ) subq_6 + INNER JOIN ( + -- Add column with generated UUID + 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.buy__ds__day + , subq_8.buy__ds__week + , subq_8.buy__ds__month + , subq_8.buy__ds__quarter + , subq_8.buy__ds__year + , subq_8.buy__ds__extract_year + , subq_8.buy__ds__extract_quarter + , subq_8.buy__ds__extract_month + , subq_8.buy__ds__extract_day + , subq_8.buy__ds__extract_dow + , subq_8.buy__ds__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.user + , subq_8.session_id + , subq_8.buy__user + , subq_8.buy__session_id + , subq_8.buys + , subq_8.buyers + , UUID_STRING() AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.buy__ds__day + , subq_7.buy__ds__week + , subq_7.buy__ds__month + , subq_7.buy__ds__quarter + , subq_7.buy__ds__year + , subq_7.buy__ds__extract_year + , subq_7.buy__ds__extract_quarter + , subq_7.buy__ds__extract_month + , subq_7.buy__ds__extract_day + , subq_7.buy__ds__extract_dow + , subq_7.buy__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.session_id + , subq_7.buy__user + , subq_7.buy__session_id + , subq_7.buys + , subq_7.buyers + FROM ( + -- Read Elements From Semantic Model 'buys_source' + SELECT + 1 AS buys + , buys_source_src_10002.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_10002.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM buys_source_src_10002.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_10002.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS buy__ds__extract_day + , EXTRACT(dayofweekiso FROM buys_source_src_10002.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS buy__ds__extract_doy + , buys_source_src_10002.user_id AS user + , buys_source_src_10002.session_id + , buys_source_src_10002.user_id AS buy__user + , buys_source_src_10002.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_7 + ) subq_8 + ) subq_9 + ON + (subq_6.user = subq_9.user) AND ((subq_6.ds__day <= subq_9.ds__day)) + ) subq_10 + ) subq_11 + ) subq_12 + GROUP BY + subq_12.visit__referrer_id + ) subq_13 + ON + subq_3.visit__referrer_id = subq_13.visit__referrer_id + GROUP BY + COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) +) subq_14 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate__plan0_optimized.sql new file mode 100644 index 0000000000..63a4062597 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate__plan0_optimized.sql @@ -0,0 +1,83 @@ +-- Compute Metrics via Expressions +SELECT + visit__referrer_id + , CAST(buys AS DOUBLE) / CAST(NULLIF(visits, 0) AS DOUBLE) AS visit_buy_conversion_rate +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id + , MAX(subq_18.visits) AS visits + , MAX(subq_28.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + visit__referrer_id + , SUM(visits) AS visits + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id'] + SELECT + referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_17 + GROUP BY + visit__referrer_id + ) subq_18 + FULL OUTER JOIN ( + -- Find conversions for user within the range of INF + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id'] + -- Aggregate Measures + SELECT + visit__referrer_id + , SUM(buys) AS buys + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_24.mf_internal_uuid AS mf_internal_uuid + , subq_24.buys AS buys + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'ds__day', 'user'] + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_21 + INNER JOIN ( + -- Read Elements From Semantic Model 'buys_source' + -- Metric Time Dimension 'ds' + -- Add column with generated UUID + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , 1 AS buys + , UUID_STRING() AS mf_internal_uuid + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_24 + ON + ( + subq_21.user = subq_24.user + ) AND ( + (subq_21.ds__day <= subq_24.ds__day) + ) + ) subq_25 + GROUP BY + visit__referrer_id + ) subq_28 + ON + subq_18.visit__referrer_id = subq_28.visit__referrer_id + GROUP BY + COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) +) subq_29 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_constant_properties__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_constant_properties__plan0.sql new file mode 100644 index 0000000000..923c1418d5 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_constant_properties__plan0.sql @@ -0,0 +1,389 @@ +-- Compute Metrics via Expressions +SELECT + subq_14.metric_time__day + , subq_14.visit__referrer_id + , CAST(subq_14.buys AS DOUBLE) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_by_session +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) AS metric_time__day + , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id + , MAX(subq_3.visits) AS visits + , MAX(subq_13.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + subq_2.metric_time__day + , subq_2.visit__referrer_id + , SUM(subq_2.visits) AS visits + FROM ( + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'metric_time__day'] + SELECT + subq_1.metric_time__day + , subq_1.visit__referrer_id + , subq_1.visits + 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.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__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.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_0 + ) subq_1 + ) subq_2 + GROUP BY + subq_2.metric_time__day + , subq_2.visit__referrer_id + ) subq_3 + FULL OUTER JOIN ( + -- Aggregate Measures + SELECT + subq_12.metric_time__day + , subq_12.visit__referrer_id + , SUM(subq_12.buys) AS buys + FROM ( + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id', 'metric_time__day'] + SELECT + subq_11.metric_time__day + , subq_11.visit__referrer_id + , subq_11.buys + FROM ( + -- Find conversions for user within the range of 7 day + SELECT + subq_10.ds__day + , subq_10.metric_time__day + , subq_10.user + , subq_10.session + , subq_10.visit__referrer_id + , subq_10.buys + , subq_10.visits + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_6.metric_time__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , first_value(subq_6.session) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session + , subq_9.mf_internal_uuid AS mf_internal_uuid + , subq_9.buys AS buys + FROM ( + -- Pass Only Elements: + -- ['visits', + -- 'visit__referrer_id', + -- 'ds__day', + -- 'metric_time__day', + -- 'user', + -- 'session'] + SELECT + subq_5.ds__day + , subq_5.metric_time__day + , subq_5.user + , subq_5.session + , subq_5.visit__referrer_id + , subq_5.visits + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.visit__ds__day + , subq_4.visit__ds__week + , subq_4.visit__ds__month + , subq_4.visit__ds__quarter + , subq_4.visit__ds__year + , subq_4.visit__ds__extract_year + , subq_4.visit__ds__extract_quarter + , subq_4.visit__ds__extract_month + , subq_4.visit__ds__extract_day + , subq_4.visit__ds__extract_dow + , subq_4.visit__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.session + , subq_4.visit__user + , subq_4.visit__session + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.visits + , subq_4.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_4 + ) subq_5 + ) subq_6 + INNER JOIN ( + -- Add column with generated UUID + 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.buy__ds__day + , subq_8.buy__ds__week + , subq_8.buy__ds__month + , subq_8.buy__ds__quarter + , subq_8.buy__ds__year + , subq_8.buy__ds__extract_year + , subq_8.buy__ds__extract_quarter + , subq_8.buy__ds__extract_month + , subq_8.buy__ds__extract_day + , subq_8.buy__ds__extract_dow + , subq_8.buy__ds__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.user + , subq_8.session_id + , subq_8.buy__user + , subq_8.buy__session_id + , subq_8.buys + , subq_8.buyers + , UUID_STRING() AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.buy__ds__day + , subq_7.buy__ds__week + , subq_7.buy__ds__month + , subq_7.buy__ds__quarter + , subq_7.buy__ds__year + , subq_7.buy__ds__extract_year + , subq_7.buy__ds__extract_quarter + , subq_7.buy__ds__extract_month + , subq_7.buy__ds__extract_day + , subq_7.buy__ds__extract_dow + , subq_7.buy__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.session_id + , subq_7.buy__user + , subq_7.buy__session_id + , subq_7.buys + , subq_7.buyers + FROM ( + -- Read Elements From Semantic Model 'buys_source' + SELECT + 1 AS buys + , buys_source_src_10002.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_10002.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM buys_source_src_10002.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_10002.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS buy__ds__extract_day + , EXTRACT(dayofweekiso FROM buys_source_src_10002.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS buy__ds__extract_doy + , buys_source_src_10002.user_id AS user + , buys_source_src_10002.session_id + , buys_source_src_10002.user_id AS buy__user + , buys_source_src_10002.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_7 + ) subq_8 + ) subq_9 + ON + ( + subq_6.user = subq_9.user + ) AND ( + subq_6.session = subq_9.session_id + ) AND ( + ( + subq_6.ds__day <= subq_9.ds__day + ) AND ( + subq_6.ds__day > DATEADD(day, -7, subq_9.ds__day) + ) + ) + ) subq_10 + ) subq_11 + ) subq_12 + GROUP BY + subq_12.metric_time__day + , subq_12.visit__referrer_id + ) subq_13 + ON + ( + subq_3.visit__referrer_id = subq_13.visit__referrer_id + ) AND ( + subq_3.metric_time__day = subq_13.metric_time__day + ) + GROUP BY + COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) + , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) +) subq_14 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_constant_properties__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_constant_properties__plan0_optimized.sql new file mode 100644 index 0000000000..2678a22401 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_constant_properties__plan0_optimized.sql @@ -0,0 +1,111 @@ +-- Compute Metrics via Expressions +SELECT + metric_time__day + , visit__referrer_id + , CAST(buys AS DOUBLE) / CAST(NULLIF(visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_by_session +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id + , MAX(subq_18.visits) AS visits + , MAX(subq_28.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + metric_time__day + , visit__referrer_id + , SUM(visits) AS visits + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'metric_time__day'] + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + , referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_17 + GROUP BY + metric_time__day + , visit__referrer_id + ) subq_18 + FULL OUTER JOIN ( + -- Find conversions for user within the range of 7 day + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id', 'metric_time__day'] + -- Aggregate Measures + SELECT + metric_time__day + , visit__referrer_id + , SUM(buys) AS buys + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_21.metric_time__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , first_value(subq_21.session) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session + , subq_24.mf_internal_uuid AS mf_internal_uuid + , subq_24.buys AS buys + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', + -- 'visit__referrer_id', + -- 'ds__day', + -- 'metric_time__day', + -- 'user', + -- 'session'] + SELECT + DATE_TRUNC('day', ds) AS ds__day + , DATE_TRUNC('day', ds) AS metric_time__day + , user_id AS user + , session_id AS session + , referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_21 + INNER JOIN ( + -- Read Elements From Semantic Model 'buys_source' + -- Metric Time Dimension 'ds' + -- Add column with generated UUID + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , session_id + , 1 AS buys + , UUID_STRING() AS mf_internal_uuid + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_24 + ON + ( + subq_21.user = subq_24.user + ) AND ( + subq_21.session = subq_24.session_id + ) AND ( + ( + subq_21.ds__day <= subq_24.ds__day + ) AND ( + subq_21.ds__day > DATEADD(day, -7, subq_24.ds__day) + ) + ) + ) subq_25 + GROUP BY + metric_time__day + , visit__referrer_id + ) subq_28 + ON + ( + subq_18.visit__referrer_id = subq_28.visit__referrer_id + ) AND ( + subq_18.metric_time__day = subq_28.metric_time__day + ) + GROUP BY + COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) + , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) +) subq_29 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_no_group_by__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_no_group_by__plan0.sql new file mode 100644 index 0000000000..e01baedbf5 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_no_group_by__plan0.sql @@ -0,0 +1,346 @@ +-- Compute Metrics via Expressions +SELECT + CAST(subq_14.buys AS DOUBLE) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days +FROM ( + -- Combine Aggregated Outputs + SELECT + MAX(subq_3.visits) AS visits + , MAX(subq_13.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + SUM(subq_2.visits) AS visits + FROM ( + -- Pass Only Elements: + -- ['visits'] + SELECT + subq_1.visits + 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.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__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.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_0 + ) subq_1 + ) subq_2 + ) subq_3 + CROSS JOIN ( + -- Aggregate Measures + SELECT + SUM(subq_12.buys) AS buys + FROM ( + -- Pass Only Elements: + -- ['buys'] + SELECT + subq_11.buys + FROM ( + -- Find conversions for user within the range of 7 day + SELECT + subq_10.ds__day + , subq_10.user + , subq_10.buys + , subq_10.visits + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_9.mf_internal_uuid AS mf_internal_uuid + , subq_9.buys AS buys + FROM ( + -- Pass Only Elements: + -- ['visits', 'ds__day', 'user'] + SELECT + subq_5.ds__day + , subq_5.user + , subq_5.visits + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.visit__ds__day + , subq_4.visit__ds__week + , subq_4.visit__ds__month + , subq_4.visit__ds__quarter + , subq_4.visit__ds__year + , subq_4.visit__ds__extract_year + , subq_4.visit__ds__extract_quarter + , subq_4.visit__ds__extract_month + , subq_4.visit__ds__extract_day + , subq_4.visit__ds__extract_dow + , subq_4.visit__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.session + , subq_4.visit__user + , subq_4.visit__session + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.visits + , subq_4.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_4 + ) subq_5 + ) subq_6 + INNER JOIN ( + -- Add column with generated UUID + 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.buy__ds__day + , subq_8.buy__ds__week + , subq_8.buy__ds__month + , subq_8.buy__ds__quarter + , subq_8.buy__ds__year + , subq_8.buy__ds__extract_year + , subq_8.buy__ds__extract_quarter + , subq_8.buy__ds__extract_month + , subq_8.buy__ds__extract_day + , subq_8.buy__ds__extract_dow + , subq_8.buy__ds__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.user + , subq_8.session_id + , subq_8.buy__user + , subq_8.buy__session_id + , subq_8.buys + , subq_8.buyers + , UUID_STRING() AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.buy__ds__day + , subq_7.buy__ds__week + , subq_7.buy__ds__month + , subq_7.buy__ds__quarter + , subq_7.buy__ds__year + , subq_7.buy__ds__extract_year + , subq_7.buy__ds__extract_quarter + , subq_7.buy__ds__extract_month + , subq_7.buy__ds__extract_day + , subq_7.buy__ds__extract_dow + , subq_7.buy__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.session_id + , subq_7.buy__user + , subq_7.buy__session_id + , subq_7.buys + , subq_7.buyers + FROM ( + -- Read Elements From Semantic Model 'buys_source' + SELECT + 1 AS buys + , buys_source_src_10002.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_10002.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM buys_source_src_10002.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_10002.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS buy__ds__extract_day + , EXTRACT(dayofweekiso FROM buys_source_src_10002.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS buy__ds__extract_doy + , buys_source_src_10002.user_id AS user + , buys_source_src_10002.session_id + , buys_source_src_10002.user_id AS buy__user + , buys_source_src_10002.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_7 + ) subq_8 + ) subq_9 + ON + ( + subq_6.user = subq_9.user + ) AND ( + ( + subq_6.ds__day <= subq_9.ds__day + ) AND ( + subq_6.ds__day > DATEADD(day, -7, subq_9.ds__day) + ) + ) + ) subq_10 + ) subq_11 + ) subq_12 + ) subq_13 +) subq_14 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_no_group_by__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_no_group_by__plan0_optimized.sql new file mode 100644 index 0000000000..2b53873952 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_no_group_by__plan0_optimized.sql @@ -0,0 +1,63 @@ +-- Combine Aggregated Outputs +-- Compute Metrics via Expressions +SELECT + CAST(MAX(subq_28.buys) AS DOUBLE) / CAST(NULLIF(MAX(subq_18.visits), 0) AS DOUBLE) AS visit_buy_conversion_rate_7days +FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits'] + -- Aggregate Measures + SELECT + SUM(1) AS visits + FROM ***************************.fct_visits visits_source_src_10011 +) subq_18 +CROSS JOIN ( + -- Find conversions for user within the range of 7 day + -- Pass Only Elements: + -- ['buys'] + -- Aggregate Measures + SELECT + SUM(buys) AS buys + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_24.mf_internal_uuid AS mf_internal_uuid + , subq_24.buys AS buys + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'ds__day', 'user'] + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_21 + INNER JOIN ( + -- Read Elements From Semantic Model 'buys_source' + -- Metric Time Dimension 'ds' + -- Add column with generated UUID + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , 1 AS buys + , UUID_STRING() AS mf_internal_uuid + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_24 + ON + ( + subq_21.user = subq_24.user + ) AND ( + ( + subq_21.ds__day <= subq_24.ds__day + ) AND ( + subq_21.ds__day > DATEADD(day, -7, subq_24.ds__day) + ) + ) + ) subq_25 +) subq_28 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_window__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_window__plan0.sql new file mode 100644 index 0000000000..8310402b53 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_window__plan0.sql @@ -0,0 +1,379 @@ +-- Compute Metrics via Expressions +SELECT + subq_14.metric_time__day + , subq_14.visit__referrer_id + , CAST(subq_14.buys AS DOUBLE) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) AS metric_time__day + , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id + , MAX(subq_3.visits) AS visits + , MAX(subq_13.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + subq_2.metric_time__day + , subq_2.visit__referrer_id + , SUM(subq_2.visits) AS visits + FROM ( + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'metric_time__day'] + SELECT + subq_1.metric_time__day + , subq_1.visit__referrer_id + , subq_1.visits + 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.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__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.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_0 + ) subq_1 + ) subq_2 + GROUP BY + subq_2.metric_time__day + , subq_2.visit__referrer_id + ) subq_3 + FULL OUTER JOIN ( + -- Aggregate Measures + SELECT + subq_12.metric_time__day + , subq_12.visit__referrer_id + , SUM(subq_12.buys) AS buys + FROM ( + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id', 'metric_time__day'] + SELECT + subq_11.metric_time__day + , subq_11.visit__referrer_id + , subq_11.buys + FROM ( + -- Find conversions for user within the range of 7 day + SELECT + subq_10.ds__day + , subq_10.metric_time__day + , subq_10.user + , subq_10.visit__referrer_id + , subq_10.buys + , subq_10.visits + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_6.metric_time__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_9.mf_internal_uuid AS mf_internal_uuid + , subq_9.buys AS buys + FROM ( + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user'] + SELECT + subq_5.ds__day + , subq_5.metric_time__day + , subq_5.user + , subq_5.visit__referrer_id + , subq_5.visits + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.visit__ds__day + , subq_4.visit__ds__week + , subq_4.visit__ds__month + , subq_4.visit__ds__quarter + , subq_4.visit__ds__year + , subq_4.visit__ds__extract_year + , subq_4.visit__ds__extract_quarter + , subq_4.visit__ds__extract_month + , subq_4.visit__ds__extract_day + , subq_4.visit__ds__extract_dow + , subq_4.visit__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.session + , subq_4.visit__user + , subq_4.visit__session + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.visits + , subq_4.visitors + FROM ( + -- Read Elements From Semantic Model 'visits_source' + SELECT + 1 AS visits + , visits_source_src_10011.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_10011.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_10011.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS ds__extract_doy + , visits_source_src_10011.referrer_id + , DATE_TRUNC('day', visits_source_src_10011.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_10011.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_10011.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_10011.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_10011.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_10011.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_10011.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_10011.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_10011.ds) AS visit__ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_10011.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_10011.ds) AS visit__ds__extract_doy + , visits_source_src_10011.referrer_id AS visit__referrer_id + , visits_source_src_10011.user_id AS user + , visits_source_src_10011.session_id AS session + , visits_source_src_10011.user_id AS visit__user + , visits_source_src_10011.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_4 + ) subq_5 + ) subq_6 + INNER JOIN ( + -- Add column with generated UUID + 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.buy__ds__day + , subq_8.buy__ds__week + , subq_8.buy__ds__month + , subq_8.buy__ds__quarter + , subq_8.buy__ds__year + , subq_8.buy__ds__extract_year + , subq_8.buy__ds__extract_quarter + , subq_8.buy__ds__extract_month + , subq_8.buy__ds__extract_day + , subq_8.buy__ds__extract_dow + , subq_8.buy__ds__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.user + , subq_8.session_id + , subq_8.buy__user + , subq_8.buy__session_id + , subq_8.buys + , subq_8.buyers + , UUID_STRING() AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.buy__ds__day + , subq_7.buy__ds__week + , subq_7.buy__ds__month + , subq_7.buy__ds__quarter + , subq_7.buy__ds__year + , subq_7.buy__ds__extract_year + , subq_7.buy__ds__extract_quarter + , subq_7.buy__ds__extract_month + , subq_7.buy__ds__extract_day + , subq_7.buy__ds__extract_dow + , subq_7.buy__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.session_id + , subq_7.buy__user + , subq_7.buy__session_id + , subq_7.buys + , subq_7.buyers + FROM ( + -- Read Elements From Semantic Model 'buys_source' + SELECT + 1 AS buys + , buys_source_src_10002.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_10002.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM buys_source_src_10002.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_10002.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_10002.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_10002.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_10002.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_10002.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_10002.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_10002.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_10002.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_10002.ds) AS buy__ds__extract_day + , EXTRACT(dayofweekiso FROM buys_source_src_10002.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_10002.ds) AS buy__ds__extract_doy + , buys_source_src_10002.user_id AS user + , buys_source_src_10002.session_id + , buys_source_src_10002.user_id AS buy__user + , buys_source_src_10002.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_7 + ) subq_8 + ) subq_9 + ON + ( + subq_6.user = subq_9.user + ) AND ( + ( + subq_6.ds__day <= subq_9.ds__day + ) AND ( + subq_6.ds__day > DATEADD(day, -7, subq_9.ds__day) + ) + ) + ) subq_10 + ) subq_11 + ) subq_12 + GROUP BY + subq_12.metric_time__day + , subq_12.visit__referrer_id + ) subq_13 + ON + ( + subq_3.visit__referrer_id = subq_13.visit__referrer_id + ) AND ( + subq_3.metric_time__day = subq_13.metric_time__day + ) + GROUP BY + COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) + , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) +) subq_14 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_window__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_window__plan0_optimized.sql new file mode 100644 index 0000000000..f96aaa0e00 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_window__plan0_optimized.sql @@ -0,0 +1,101 @@ +-- Compute Metrics via Expressions +SELECT + metric_time__day + , visit__referrer_id + , CAST(buys AS DOUBLE) / CAST(NULLIF(visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id + , MAX(subq_18.visits) AS visits + , MAX(subq_28.buys) AS buys + FROM ( + -- Aggregate Measures + SELECT + metric_time__day + , visit__referrer_id + , SUM(visits) AS visits + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'metric_time__day'] + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + , referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_17 + GROUP BY + metric_time__day + , visit__referrer_id + ) subq_18 + FULL OUTER JOIN ( + -- Find conversions for user within the range of 7 day + -- Pass Only Elements: + -- ['buys', 'visit__referrer_id', 'metric_time__day'] + -- Aggregate Measures + SELECT + metric_time__day + , visit__referrer_id + , SUM(buys) AS buys + FROM ( + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_21.metric_time__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_24.mf_internal_uuid AS mf_internal_uuid + , subq_24.buys AS buys + FROM ( + -- Read Elements From Semantic Model 'visits_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user'] + SELECT + DATE_TRUNC('day', ds) AS ds__day + , DATE_TRUNC('day', ds) AS metric_time__day + , user_id AS user + , referrer_id AS visit__referrer_id + , 1 AS visits + FROM ***************************.fct_visits visits_source_src_10011 + ) subq_21 + INNER JOIN ( + -- Read Elements From Semantic Model 'buys_source' + -- Metric Time Dimension 'ds' + -- Add column with generated UUID + SELECT + DATE_TRUNC('day', ds) AS ds__day + , user_id AS user + , 1 AS buys + , UUID_STRING() AS mf_internal_uuid + FROM ***************************.fct_buys buys_source_src_10002 + ) subq_24 + ON + ( + subq_21.user = subq_24.user + ) AND ( + ( + subq_21.ds__day <= subq_24.ds__day + ) AND ( + subq_21.ds__day > DATEADD(day, -7, subq_24.ds__day) + ) + ) + ) subq_25 + GROUP BY + metric_time__day + , visit__referrer_id + ) subq_28 + ON + ( + subq_18.visit__referrer_id = subq_28.visit__referrer_id + ) AND ( + subq_18.metric_time__day = subq_28.metric_time__day + ) + GROUP BY + COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) + , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) +) subq_29 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_count_with_no_group_by__plan0.xml b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_count_with_no_group_by__plan0.xml new file mode 100644 index 0000000000..a97d0bd26b --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_count_with_no_group_by__plan0.xml @@ -0,0 +1,1220 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate__plan0.xml b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate__plan0.xml new file mode 100644 index 0000000000..46d0c44803 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate__plan0.xml @@ -0,0 +1,1268 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_constant_properties__plan0.xml b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_constant_properties__plan0.xml new file mode 100644 index 0000000000..8f6cb21ac2 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_constant_properties__plan0.xml @@ -0,0 +1,1333 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_no_group_by__plan0.xml b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_no_group_by__plan0.xml new file mode 100644 index 0000000000..e649d811ba --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_no_group_by__plan0.xml @@ -0,0 +1,1220 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_window__plan0.xml b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_window__plan0.xml new file mode 100644 index 0000000000..423a387c10 --- /dev/null +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_window__plan0.xml @@ -0,0 +1,1316 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 01ec3568638b0d8ba2afe4588cfec44631c29dda Mon Sep 17 00:00:00 2001 From: Will Deng Date: Fri, 15 Dec 2023 17:08:29 -0500 Subject: [PATCH 11/14] addressed reviews --- .../dataflow/builder/dataflow_plan_builder.py | 3 +-- metricflow/plan_conversion/dataflow_to_sql.py | 15 +++++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/metricflow/dataflow/builder/dataflow_plan_builder.py b/metricflow/dataflow/builder/dataflow_plan_builder.py index 574200d27e..c727718f83 100644 --- a/metricflow/dataflow/builder/dataflow_plan_builder.py +++ b/metricflow/dataflow/builder/dataflow_plan_builder.py @@ -270,7 +270,6 @@ def _build_aggregated_conversion_node( unaggregated_conversion_measure_node = AddGeneratedUuidColumnNode( parent_node=conversion_measure_recipe.source_node ) - primary_key_specs = (MetadataSpec.from_name(MetricFlowReservedKeywords.MF_INTERNAL_UUID.value),) # Get the agg time dimension for each measure used for matching conversion time windows base_time_dimension_spec = TimeDimensionSpec.from_reference( @@ -320,7 +319,7 @@ def _build_aggregated_conversion_node( conversion_node=unaggregated_conversion_measure_node, conversion_measure_spec=conversion_measure_spec.measure_spec, conversion_time_dimension_spec=conversion_time_dimension_spec, - conversion_primary_key_specs=primary_key_specs, + unique_identifier_keys=(MetadataSpec.from_name(MetricFlowReservedKeywords.MF_INTERNAL_UUID.value),), entity_spec=entity_spec, window=window, constant_properties=constant_property_specs, diff --git a/metricflow/plan_conversion/dataflow_to_sql.py b/metricflow/plan_conversion/dataflow_to_sql.py index 46dd68ae8d..13364a347f 100644 --- a/metricflow/plan_conversion/dataflow_to_sql.py +++ b/metricflow/plan_conversion/dataflow_to_sql.py @@ -1473,14 +1473,13 @@ def visit_join_conversion_events_node(self, node: JoinConversionEventsNode) -> S CreateSqlColumnReferencesForInstances(base_data_set_alias, self._column_association_resolver) ) - conversion_primary_key_col_names = tuple( - self._column_association_resolver.resolve_spec(spec).column_name - for spec in node.conversion_primary_key_specs + unique_conversion_col_names = tuple( + self._column_association_resolver.resolve_spec(spec).column_name for spec in node.unique_identifier_keys ) partition_by_columns: Tuple[str, ...] = ( entity_column_name, conversion_time_dimension_column_name, - ) + conversion_primary_key_col_names + ) + unique_conversion_col_names if node.constant_properties: partition_by_columns += tuple( conversion_column_name for _, conversion_column_name in constant_property_column_names @@ -1528,7 +1527,7 @@ def visit_join_conversion_events_node(self, node: JoinConversionEventsNode) -> S ) # Deduplicate the fanout results - conversion_primary_key_select_columns = tuple( + conversion_unique_key_select_columns = tuple( SqlSelectColumn( expr=SqlColumnReferenceExpression( SqlColumnReference( @@ -1538,15 +1537,15 @@ def visit_join_conversion_events_node(self, node: JoinConversionEventsNode) -> S ), column_alias=column_name, ) - for column_name in conversion_primary_key_col_names + for column_name in unique_conversion_col_names ) additional_conversion_select_columns = conversion_data_set_output_instance_set.transform( CreateSelectColumnsForInstances(conversion_data_set_alias, self._column_association_resolver) ).as_tuple() deduped_sql_select_node = SqlSelectStatementNode( - description=f"Dedupe the fanout on {node.conversion_primary_key_specs} in the conversion data set", + description=f"Dedupe the fanout with {','.join(spec.qualified_name for spec in node.unique_identifier_keys)} in the conversion data set", select_columns=base_sql_select_columns - + conversion_primary_key_select_columns + + conversion_unique_key_select_columns + additional_conversion_select_columns, from_source=base_data_set.sql_select_node, from_source_alias=base_data_set_alias, From 273a20f89a900f86557adff2f3d006a5622d0269 Mon Sep 17 00:00:00 2001 From: Will Deng Date: Sat, 16 Dec 2023 01:56:13 -0500 Subject: [PATCH 12/14] fix merge conflicts from ambiguous group by changes --- .../dataflow/builder/dataflow_plan_builder.py | 48 +++++++++++-------- .../candidate_push_down/push_down_visitor.py | 8 +++- .../resolution_dag/dag_builder.py | 19 ++++++-- .../metric_time_requirements.py | 2 +- 4 files changed, 49 insertions(+), 28 deletions(-) diff --git a/metricflow/dataflow/builder/dataflow_plan_builder.py b/metricflow/dataflow/builder/dataflow_plan_builder.py index c727718f83..60f1556f4e 100644 --- a/metricflow/dataflow/builder/dataflow_plan_builder.py +++ b/metricflow/dataflow/builder/dataflow_plan_builder.py @@ -225,7 +225,6 @@ def _build_aggregated_conversion_node( entity_spec: EntitySpec, window: Optional[MetricTimeWindow], queried_linkable_specs: LinkableSpecSet, - where_constraint: Optional[WhereFilterSpec] = None, time_range_constraint: Optional[TimeRangeConstraint] = None, constant_properties: Optional[Sequence[ConstantPropertyInput]] = None, ) -> BaseOutput: @@ -233,7 +232,7 @@ def _build_aggregated_conversion_node( # Build measure recipes base_required_linkable_specs, _ = self.__get_required_and_extraneous_linkable_specs( queried_linkable_specs=queried_linkable_specs, - where_constraint=where_constraint, + filter_specs=base_measure_spec.filter_specs, ) base_measure_recipe = self._find_dataflow_recipe( measure_spec_properties=self._build_measure_spec_properties([base_measure_spec.measure_spec]), @@ -261,7 +260,6 @@ def _build_aggregated_conversion_node( aggregated_base_measure_node = self.build_aggregated_measure( metric_input_measure_spec=base_measure_spec, queried_linkable_specs=queried_linkable_specs, - where_constraint=where_constraint, time_range_constraint=time_range_constraint, ) @@ -334,7 +332,6 @@ def _build_aggregated_conversion_node( aggregated_conversions_node = self.build_aggregated_measure( metric_input_measure_spec=conversion_measure_spec, queried_linkable_specs=queried_linkable_specs, - where_constraint=where_constraint, time_range_constraint=time_range_constraint, measure_recipe=recipe_with_join_conversion_source_node, ) @@ -346,23 +343,19 @@ def _build_conversion_metric_output_node( self, metric_spec: MetricSpec, queried_linkable_specs: LinkableSpecSet, - where_constraint: Optional[WhereFilterSpec] = None, + filter_spec_factory: WhereSpecFactory, time_range_constraint: Optional[TimeRangeConstraint] = None, ) -> ComputeMetricsNode: """Builds a compute metric node for a conversion metric.""" - combined_where = where_constraint - if metric_spec.constraint: - combined_where = ( - combined_where.combine(metric_spec.constraint) if combined_where else metric_spec.constraint - ) - - metric = self._metric_lookup.get_metric(metric_spec.reference) + metric_reference = metric_spec.reference + metric = self._metric_lookup.get_metric(metric_reference) conversion_type_params = metric.type_params.conversion_type_params assert conversion_type_params, "A conversion metric should have type_params.conversion_type_params defined." base_measure, conversion_measure = self._build_input_measure_specs_for_conversion_metric( metric_reference=metric_spec.reference, conversion_type_params=conversion_type_params, - column_association_resolver=self._column_association_resolver, + filter_spec_factory=filter_spec_factory, + descendent_filter_specs=metric_spec.filter_specs, ) entity_spec = EntitySpec.from_name(conversion_type_params.entity) logger.info( @@ -376,7 +369,6 @@ def _build_conversion_metric_output_node( base_measure_spec=base_measure, conversion_measure_spec=conversion_measure, queried_linkable_specs=queried_linkable_specs, - where_constraint=combined_where, time_range_constraint=time_range_constraint, entity_spec=entity_spec, window=conversion_type_params.window, @@ -546,7 +538,7 @@ def _build_any_metric_output_node( return self._build_conversion_metric_output_node( metric_spec=metric_spec, queried_linkable_specs=queried_linkable_specs, - where_constraint=where_constraint, + filter_spec_factory=filter_spec_factory, time_range_constraint=time_range_constraint, ) @@ -957,7 +949,8 @@ def _build_input_measure_specs_for_conversion_metric( self, metric_reference: MetricReference, conversion_type_params: ConversionTypeParams, - column_association_resolver: ColumnAssociationResolver, + filter_spec_factory: WhereSpecFactory, + descendent_filter_specs: Sequence[WhereFilterSpec], ) -> Tuple[MetricInputMeasureSpec, MetricInputMeasureSpec]: """Return [base_measure_input, conversion_measure_input] for computing a conversion metric.""" metric = self._metric_lookup.get_metric(metric_reference) @@ -969,7 +962,7 @@ def _build_input_measure_specs_for_conversion_metric( ), f"A conversion metric should exactly 2 measures. Got{metric.input_measures}" def _get_matching_measure( - measure_to_match: MeasureReference, input_measures: Sequence[MetricInputMeasure] + measure_to_match: MeasureReference, input_measures: Sequence[MetricInputMeasure], is_base_measure: bool ) -> MetricInputMeasureSpec: matched_measure = next( filter( @@ -979,22 +972,37 @@ def _get_matching_measure( None, ) assert matched_measure, f"Unable to find {measure_to_match} in {input_measures}." + if is_base_measure: + filter_specs: List[WhereFilterSpec] = [] + filter_specs.extend( + filter_spec_factory.create_from_where_filter_intersection( + filter_location=WhereFilterLocation.for_metric(metric_reference), + filter_intersection=metric.filter, + ) + ) + filter_specs.extend(descendent_filter_specs) + filter_specs.extend( + filter_spec_factory.create_from_where_filter_intersection( + filter_location=WhereFilterLocation.for_metric(metric_reference), + filter_intersection=matched_measure.filter, + ) + ) return MetricInputMeasureSpec( measure_spec=MeasureSpec.from_name(matched_measure.name), fill_nulls_with=matched_measure.fill_nulls_with, - constraint=WhereSpecFactory( - column_association_resolver=column_association_resolver, - ).create_from_where_filter_intersection(matched_measure.filter), + filter_specs=tuple(filter_specs) if is_base_measure else (), alias=matched_measure.alias, ) base_input_measure = _get_matching_measure( measure_to_match=conversion_type_params.base_measure.measure_reference, input_measures=metric.input_measures, + is_base_measure=True, ) conversion_input_measure = _get_matching_measure( measure_to_match=conversion_type_params.conversion_measure.measure_reference, input_measures=metric.input_measures, + is_base_measure=False, ) return base_input_measure, conversion_input_measure diff --git a/metricflow/query/group_by_item/candidate_push_down/push_down_visitor.py b/metricflow/query/group_by_item/candidate_push_down/push_down_visitor.py index 1c0e1e4592..ac30c2b23f 100644 --- a/metricflow/query/group_by_item/candidate_push_down/push_down_visitor.py +++ b/metricflow/query/group_by_item/candidate_push_down/push_down_visitor.py @@ -159,7 +159,7 @@ def visit_measure_node(self, node: MeasureGroupByItemSourceNode) -> PushDownResu metric = self._semantic_manifest_lookup.metric_lookup.get_metric(node.child_metric_reference) patterns_to_apply: Tuple[SpecPattern, ...] = () - if metric.type is MetricType.SIMPLE: + if metric.type is MetricType.SIMPLE or metric.type is MetricType.CONVERSION: pass elif metric.type is MetricType.RATIO or metric.type is MetricType.DERIVED: assert False, f"A measure should have a simple or cumulative metric as a child, but got {metric.type}" @@ -293,7 +293,11 @@ def visit_metric_node(self, node: MetricGroupByItemResolutionNode) -> PushDownRe # For metrics with offset_to_grain, don't allow date_part group-by-items patterns_to_apply: Sequence[SpecPattern] = () - if metric.type is MetricType.SIMPLE or metric.type is MetricType.CUMULATIVE: + if ( + metric.type is MetricType.SIMPLE + or metric.type is MetricType.CUMULATIVE + or metric.type is MetricType.CONVERSION + ): pass elif metric.type is MetricType.RATIO or metric.type is MetricType.DERIVED: for input_metric in metric.input_metrics: diff --git a/metricflow/query/group_by_item/resolution_dag/dag_builder.py b/metricflow/query/group_by_item/resolution_dag/dag_builder.py index 661ee99e33..0474e80781 100644 --- a/metricflow/query/group_by_item/resolution_dag/dag_builder.py +++ b/metricflow/query/group_by_item/resolution_dag/dag_builder.py @@ -1,11 +1,12 @@ from __future__ import annotations import logging -from typing import Optional, Sequence +from typing import Optional, Sequence, Tuple from dbt_semantic_interfaces.implementations.filters.where_filter import PydanticWhereFilterIntersection from dbt_semantic_interfaces.protocols import WhereFilterIntersection -from dbt_semantic_interfaces.references import MetricReference +from dbt_semantic_interfaces.references import MeasureReference, MetricReference +from dbt_semantic_interfaces.type_enums import MetricType from metricflow.model.semantic_manifest_lookup import SemanticManifestLookup from metricflow.query.group_by_item.resolution_dag.dag import GroupByItemResolutionDag @@ -42,9 +43,17 @@ def _build_dag_component_for_metric( # For a base metric, the parents are measure nodes if len(metric.input_metrics) == 0: - measure_references_for_metric = tuple( - input_measure.measure_reference for input_measure in metric.input_measures - ) + measure_references_for_metric: Tuple[MeasureReference, ...] + if metric.type is MetricType.CONVERSION: + conversion_type_params = metric.type_params.conversion_type_params + assert ( + conversion_type_params + ), "A conversion metric should have type_params.conversion_type_params defined." + measure_references_for_metric = (conversion_type_params.base_measure.measure_reference,) + else: + measure_references_for_metric = tuple( + input_measure.measure_reference for input_measure in metric.input_measures + ) source_candidates_for_measure_nodes = tuple( MeasureGroupByItemSourceNode( diff --git a/metricflow/query/validation_rules/metric_time_requirements.py b/metricflow/query/validation_rules/metric_time_requirements.py index 4e1151e590..fdc2d2c6e5 100644 --- a/metricflow/query/validation_rules/metric_time_requirements.py +++ b/metricflow/query/validation_rules/metric_time_requirements.py @@ -74,7 +74,7 @@ def validate_metric_in_resolution_dag( metric = self._get_metric(metric_reference) query_includes_metric_time = self._group_by_items_include_metric_time(resolver_input_for_query) - if metric.type is MetricType.SIMPLE: + if metric.type is MetricType.SIMPLE or metric.type is MetricType.CONVERSION: return MetricFlowQueryResolutionIssueSet.empty_instance() elif metric.type is MetricType.CUMULATIVE: if ( From da5c8b26d6b98bb195c9f186a802a0ba6e05226e Mon Sep 17 00:00:00 2001 From: Will Deng Date: Sat, 16 Dec 2023 02:08:15 -0500 Subject: [PATCH 13/14] updated snapshots --- ...st_convert_query_semantic_model__plan0.sql | 52 +- ...le_semantic_model_with_measures__plan0.sql | 100 +- ...semantic_model_without_measures__plan0.sql | 52 +- ...st_convert_query_semantic_model__plan0.sql | 52 +- ...le_semantic_model_with_measures__plan0.sql | 100 +- ...semantic_model_without_measures__plan0.sql | 52 +- ...st_convert_query_semantic_model__plan0.sql | 52 +- ...le_semantic_model_with_measures__plan0.sql | 100 +- ...semantic_model_without_measures__plan0.sql | 52 +- ...st_convert_query_semantic_model__plan0.sql | 52 +- ...le_semantic_model_with_measures__plan0.sql | 100 +- ...semantic_model_without_measures__plan0.sql | 52 +- ...st_convert_query_semantic_model__plan0.sql | 52 +- ...le_semantic_model_with_measures__plan0.sql | 100 +- ...semantic_model_without_measures__plan0.sql | 52 +- ...st_convert_query_semantic_model__plan0.sql | 52 +- ...le_semantic_model_with_measures__plan0.sql | 100 +- ...semantic_model_without_measures__plan0.sql | 52 +- .../test_cumulative_metric__plan0.sql | 52 +- ...est_cumulative_metric__plan0_optimized.sql | 2 +- ...cumulative_metric_grain_to_date__plan0.sql | 52 +- ..._metric_grain_to_date__plan0_optimized.sql | 2 +- .../test_cumulative_metric_no_ds__plan0.sql | 52 +- ...mulative_metric_no_ds__plan0_optimized.sql | 2 +- ...est_cumulative_metric_no_window__plan0.sql | 52 +- ...tive_metric_no_window__plan0_optimized.sql | 2 +- ..._no_window_with_time_constraint__plan0.sql | 52 +- ..._with_time_constraint__plan0_optimized.sql | 2 +- ...ive_metric_with_time_constraint__plan0.sql | 52 +- ..._with_time_constraint__plan0_optimized.sql | 2 +- .../test_cumulative_metric__plan0.sql | 52 +- ...est_cumulative_metric__plan0_optimized.sql | 2 +- ...cumulative_metric_grain_to_date__plan0.sql | 52 +- ..._metric_grain_to_date__plan0_optimized.sql | 2 +- .../test_cumulative_metric_no_ds__plan0.sql | 52 +- ...mulative_metric_no_ds__plan0_optimized.sql | 2 +- ...est_cumulative_metric_no_window__plan0.sql | 52 +- ...tive_metric_no_window__plan0_optimized.sql | 2 +- ..._no_window_with_time_constraint__plan0.sql | 52 +- ..._with_time_constraint__plan0_optimized.sql | 2 +- ...ive_metric_with_time_constraint__plan0.sql | 52 +- ..._with_time_constraint__plan0_optimized.sql | 2 +- .../DuckDB/test_cumulative_metric__plan0.sql | 52 +- ...est_cumulative_metric__plan0_optimized.sql | 2 +- ...cumulative_metric_grain_to_date__plan0.sql | 52 +- ..._metric_grain_to_date__plan0_optimized.sql | 2 +- .../test_cumulative_metric_no_ds__plan0.sql | 52 +- ...mulative_metric_no_ds__plan0_optimized.sql | 2 +- ...est_cumulative_metric_no_window__plan0.sql | 52 +- ...tive_metric_no_window__plan0_optimized.sql | 2 +- ..._no_window_with_time_constraint__plan0.sql | 52 +- ..._with_time_constraint__plan0_optimized.sql | 2 +- ...ive_metric_with_time_constraint__plan0.sql | 52 +- ..._with_time_constraint__plan0_optimized.sql | 2 +- .../test_cumulative_metric__plan0.sql | 52 +- ...est_cumulative_metric__plan0_optimized.sql | 2 +- ...cumulative_metric_grain_to_date__plan0.sql | 52 +- ..._metric_grain_to_date__plan0_optimized.sql | 2 +- .../test_cumulative_metric_no_ds__plan0.sql | 52 +- ...mulative_metric_no_ds__plan0_optimized.sql | 2 +- ...est_cumulative_metric_no_window__plan0.sql | 52 +- ...tive_metric_no_window__plan0_optimized.sql | 2 +- ..._no_window_with_time_constraint__plan0.sql | 52 +- ..._with_time_constraint__plan0_optimized.sql | 2 +- ...ive_metric_with_time_constraint__plan0.sql | 52 +- ..._with_time_constraint__plan0_optimized.sql | 2 +- .../test_cumulative_metric__plan0.sql | 52 +- ...est_cumulative_metric__plan0_optimized.sql | 2 +- ...cumulative_metric_grain_to_date__plan0.sql | 52 +- ..._metric_grain_to_date__plan0_optimized.sql | 2 +- .../test_cumulative_metric_no_ds__plan0.sql | 52 +- ...mulative_metric_no_ds__plan0_optimized.sql | 2 +- ...est_cumulative_metric_no_window__plan0.sql | 52 +- ...tive_metric_no_window__plan0_optimized.sql | 2 +- ..._no_window_with_time_constraint__plan0.sql | 52 +- ..._with_time_constraint__plan0_optimized.sql | 2 +- ...ive_metric_with_time_constraint__plan0.sql | 52 +- ..._with_time_constraint__plan0_optimized.sql | 2 +- .../test_cumulative_metric__plan0.sql | 52 +- ...est_cumulative_metric__plan0_optimized.sql | 2 +- ...cumulative_metric_grain_to_date__plan0.sql | 52 +- ..._metric_grain_to_date__plan0_optimized.sql | 2 +- .../test_cumulative_metric_no_ds__plan0.sql | 52 +- ...mulative_metric_no_ds__plan0_optimized.sql | 2 +- ...est_cumulative_metric_no_window__plan0.sql | 52 +- ...tive_metric_no_window__plan0_optimized.sql | 2 +- ..._no_window_with_time_constraint__plan0.sql | 52 +- ..._with_time_constraint__plan0_optimized.sql | 2 +- ...ive_metric_with_time_constraint__plan0.sql | 52 +- ..._with_time_constraint__plan0_optimized.sql | 2 +- .../DataflowPlan/test_cyclic_join__dfp_0.xml | 6 +- .../test_common_semantic_model__dfp_0.xml | 12 +- ...indow_or_grain_with_metric_time__dfp_0.xml | 4 +- ...ow_or_grain_without_metric_time__dfp_0.xml | 4 +- ...t_cumulative_metric_with_window__dfp_0.xml | 4 +- ..._derived_metric_offset_to_grain__dfp_0.xml | 4 +- ...st_derived_metric_offset_window__dfp_0.xml | 2 +- ..._metric_offset_with_granularity__dfp_0.xml | 2 +- ...erived_offset_cumulative_metric__dfp_0.xml | 2 +- .../test_distinct_values_plan__dfp_0.xml | 2 +- ..._distinct_values_plan_with_join__dfp_0.xml | 4 +- ..._if_no_time_dimension_requested__dfp_0.xml | 2 +- ...in_to_time_spine_derived_metric__dfp_0.xml | 4 +- ..._to_time_spine_with_metric_time__dfp_0.xml | 2 +- ...time_spine_with_non_metric_time__dfp_0.xml | 2 +- .../DataflowPlan/test_joined_plan__dfp_0.xml | 6 +- .../test_limit_rows_plan__dfp_0.xml | 2 +- .../test_measure_constraint_plan__dfp_0.xml | 14 +- ...traint_with_reused_measure_plan__dfp_0.xml | 4 +- ...mantic_model_ratio_metrics_plan__dfp_0.xml | 14 +- .../test_multihop_join_plan__dfp_0.xml | 8 +- .../test_multiple_metrics_plan__dfp_0.xml | 4 +- ...erived_metric_with_outer_offset__dfp_0.xml | 2 +- .../test_order_by_plan__dfp_0.xml | 2 +- .../test_primary_entity_dimension__dfp_0.xml | 2 +- .../DataflowPlan/test_simple_plan__dfp_0.xml | 2 +- ...mantic_model_ratio_metrics_plan__dfp_0.xml | 12 +- .../test_where_constrained_plan__dfp_0.xml | 6 +- ...constrained_plan_time_dimension__dfp_0.xml | 2 +- ...ained_with_common_linkable_plan__dfp_0.xml | 6 +- .../BigQuery/test_joined_plan__ep_0.xml | 6 +- .../test_multihop_joined_plan__ep_0.xml | 22 +- .../Databricks/test_joined_plan__ep_0.xml | 8 +- .../test_multihop_joined_plan__ep_0.xml | 22 +- .../DuckDB/test_joined_plan__ep_0.xml | 8 +- .../test_multihop_joined_plan__ep_0.xml | 22 +- .../Postgres/test_joined_plan__ep_0.xml | 8 +- .../test_multihop_joined_plan__ep_0.xml | 22 +- .../Redshift/test_joined_plan__ep_0.xml | 8 +- .../test_multihop_joined_plan__ep_0.xml | 22 +- .../Snowflake/test_joined_plan__ep_0.xml | 8 +- .../test_multihop_joined_plan__ep_0.xml | 22 +- ...ompute_metrics_node_simple_expr__plan0.xml | 2 +- .../test_compute_metrics_node__plan0.sql | 112 +- ..._compute_metrics_node__plan0_optimized.sql | 6 +- ...o_from_multiple_semantic_models__plan0.sql | 322 ++--- ...tiple_semantic_models__plan0_optimized.sql | 14 +- ...atio_from_single_semantic_model__plan0.sql | 112 +- ...single_semantic_model__plan0_optimized.sql | 6 +- ...ompute_metrics_node_simple_expr__plan0.sql | 112 +- ...rics_node_simple_expr__plan0_optimized.sql | 6 +- ...on_with_joined_where_constraint__plan0.sql | 164 +-- ...ined_where_constraint__plan0_optimized.sql | 10 +- .../test_dimensions_requiring_join__plan0.sql | 164 +-- ...nsions_requiring_join__plan0_optimized.sql | 10 +- .../BigQuery/test_multi_join_node__plan0.sql | 224 ++-- .../test_multi_join_node__plan0_optimized.sql | 4 +- .../BigQuery/test_single_join_node__plan0.sql | 112 +- ...test_single_join_node__plan0_optimized.sql | 4 +- .../test_compute_metrics_node__plan0.sql | 112 +- ..._compute_metrics_node__plan0_optimized.sql | 8 +- ...o_from_multiple_semantic_models__plan0.sql | 322 ++--- ...tiple_semantic_models__plan0_optimized.sql | 18 +- ...atio_from_single_semantic_model__plan0.sql | 112 +- ...single_semantic_model__plan0_optimized.sql | 8 +- ...ompute_metrics_node_simple_expr__plan0.sql | 112 +- ...rics_node_simple_expr__plan0_optimized.sql | 8 +- ...on_with_joined_where_constraint__plan0.sql | 164 +-- ...ined_where_constraint__plan0_optimized.sql | 10 +- .../test_dimensions_requiring_join__plan0.sql | 164 +-- ...nsions_requiring_join__plan0_optimized.sql | 14 +- .../test_multi_join_node__plan0.sql | 224 ++-- .../test_multi_join_node__plan0_optimized.sql | 4 +- .../test_single_join_node__plan0.sql | 112 +- ...test_single_join_node__plan0_optimized.sql | 4 +- .../test_compute_metrics_node__plan0.sql | 112 +- ..._compute_metrics_node__plan0_optimized.sql | 8 +- ...o_from_multiple_semantic_models__plan0.sql | 322 ++--- ...tiple_semantic_models__plan0_optimized.sql | 18 +- ...atio_from_single_semantic_model__plan0.sql | 112 +- ...single_semantic_model__plan0_optimized.sql | 8 +- ...ompute_metrics_node_simple_expr__plan0.sql | 112 +- ...rics_node_simple_expr__plan0_optimized.sql | 8 +- ...on_with_joined_where_constraint__plan0.sql | 164 +-- ...ined_where_constraint__plan0_optimized.sql | 10 +- .../test_dimensions_requiring_join__plan0.sql | 164 +-- ...nsions_requiring_join__plan0_optimized.sql | 14 +- .../DuckDB/test_multi_join_node__plan0.sql | 224 ++-- .../test_multi_join_node__plan0_optimized.sql | 4 +- .../DuckDB/test_single_join_node__plan0.sql | 112 +- ...test_single_join_node__plan0_optimized.sql | 4 +- .../test_compute_metrics_node__plan0.sql | 112 +- ..._compute_metrics_node__plan0_optimized.sql | 8 +- ...o_from_multiple_semantic_models__plan0.sql | 322 ++--- ...tiple_semantic_models__plan0_optimized.sql | 18 +- ...atio_from_single_semantic_model__plan0.sql | 112 +- ...single_semantic_model__plan0_optimized.sql | 8 +- ...ompute_metrics_node_simple_expr__plan0.sql | 112 +- ...rics_node_simple_expr__plan0_optimized.sql | 8 +- ...on_with_joined_where_constraint__plan0.sql | 164 +-- ...ined_where_constraint__plan0_optimized.sql | 10 +- .../test_dimensions_requiring_join__plan0.sql | 164 +-- ...nsions_requiring_join__plan0_optimized.sql | 14 +- .../Postgres/test_multi_join_node__plan0.sql | 224 ++-- .../test_multi_join_node__plan0_optimized.sql | 4 +- .../Postgres/test_single_join_node__plan0.sql | 112 +- ...test_single_join_node__plan0_optimized.sql | 4 +- .../test_compute_metrics_node__plan0.sql | 112 +- ..._compute_metrics_node__plan0_optimized.sql | 8 +- ...o_from_multiple_semantic_models__plan0.sql | 322 ++--- ...tiple_semantic_models__plan0_optimized.sql | 18 +- ...atio_from_single_semantic_model__plan0.sql | 112 +- ...single_semantic_model__plan0_optimized.sql | 8 +- ...ompute_metrics_node_simple_expr__plan0.sql | 112 +- ...rics_node_simple_expr__plan0_optimized.sql | 8 +- ...on_with_joined_where_constraint__plan0.sql | 164 +-- ...ined_where_constraint__plan0_optimized.sql | 10 +- .../test_dimensions_requiring_join__plan0.sql | 164 +-- ...nsions_requiring_join__plan0_optimized.sql | 14 +- .../Redshift/test_multi_join_node__plan0.sql | 224 ++-- .../test_multi_join_node__plan0_optimized.sql | 4 +- .../Redshift/test_single_join_node__plan0.sql | 112 +- ...test_single_join_node__plan0_optimized.sql | 4 +- .../test_compute_metrics_node__plan0.sql | 112 +- ..._compute_metrics_node__plan0_optimized.sql | 8 +- ...o_from_multiple_semantic_models__plan0.sql | 322 ++--- ...tiple_semantic_models__plan0_optimized.sql | 18 +- ...atio_from_single_semantic_model__plan0.sql | 112 +- ...single_semantic_model__plan0_optimized.sql | 8 +- ...ompute_metrics_node_simple_expr__plan0.sql | 112 +- ...rics_node_simple_expr__plan0_optimized.sql | 8 +- ...on_with_joined_where_constraint__plan0.sql | 164 +-- ...ined_where_constraint__plan0_optimized.sql | 10 +- .../test_dimensions_requiring_join__plan0.sql | 164 +-- ...nsions_requiring_join__plan0_optimized.sql | 14 +- .../Snowflake/test_multi_join_node__plan0.sql | 224 ++-- .../test_multi_join_node__plan0_optimized.sql | 4 +- .../test_single_join_node__plan0.sql | 112 +- ...test_single_join_node__plan0_optimized.sql | 4 +- .../test_compute_metrics_node__plan0.xml | 120 +- ...o_from_multiple_semantic_models__plan0.xml | 1080 ++++++++--------- ...atio_from_single_semantic_model__plan0.xml | 120 +- ...ompute_metrics_node_simple_expr__plan0.xml | 120 +- ...on_with_joined_where_constraint__plan0.xml | 178 +-- .../test_dimensions_requiring_join__plan0.xml | 178 +-- .../test_multi_join_node__plan0.xml | 240 ++-- .../test_single_join_node__plan0.xml | 120 +- ...nth_dimension_and_offset_window__plan0.sql | 32 +- ...ion_and_offset_window__plan0_optimized.sql | 6 +- ...nth_dimension_and_offset_window__plan0.sql | 32 +- ...ion_and_offset_window__plan0_optimized.sql | 6 +- ...nth_dimension_and_offset_window__plan0.sql | 32 +- ...ion_and_offset_window__plan0_optimized.sql | 6 +- ...nth_dimension_and_offset_window__plan0.sql | 32 +- ...ion_and_offset_window__plan0_optimized.sql | 6 +- ...nth_dimension_and_offset_window__plan0.sql | 32 +- ...ion_and_offset_window__plan0_optimized.sql | 6 +- ...nth_dimension_and_offset_window__plan0.sql | 32 +- ...ion_and_offset_window__plan0_optimized.sql | 6 +- ...values_with_a_join_and_a_filter__plan0.sql | 164 +-- ...h_a_join_and_a_filter__plan0_optimized.sql | 10 +- .../test_dimensions_requiring_join__plan0.sql | 164 +-- ...nsions_requiring_join__plan0_optimized.sql | 10 +- ...values_with_a_join_and_a_filter__plan0.sql | 164 +-- ...h_a_join_and_a_filter__plan0_optimized.sql | 10 +- .../test_dimensions_requiring_join__plan0.sql | 164 +-- ...nsions_requiring_join__plan0_optimized.sql | 14 +- ...values_with_a_join_and_a_filter__plan0.sql | 164 +-- ...h_a_join_and_a_filter__plan0_optimized.sql | 10 +- .../test_dimensions_requiring_join__plan0.sql | 164 +-- ...nsions_requiring_join__plan0_optimized.sql | 14 +- ...values_with_a_join_and_a_filter__plan0.sql | 164 +-- ...h_a_join_and_a_filter__plan0_optimized.sql | 10 +- .../test_dimensions_requiring_join__plan0.sql | 164 +-- ...nsions_requiring_join__plan0_optimized.sql | 14 +- ...values_with_a_join_and_a_filter__plan0.sql | 164 +-- ...h_a_join_and_a_filter__plan0_optimized.sql | 10 +- .../test_dimensions_requiring_join__plan0.sql | 164 +-- ...nsions_requiring_join__plan0_optimized.sql | 14 +- ...values_with_a_join_and_a_filter__plan0.sql | 164 +-- ...h_a_join_and_a_filter__plan0_optimized.sql | 10 +- .../test_dimensions_requiring_join__plan0.sql | 164 +-- ...nsions_requiring_join__plan0_optimized.sql | 14 +- ...values_with_a_join_and_a_filter__plan0.xml | 178 +-- .../test_dimensions_requiring_join__plan0.xml | 178 +-- ...uery_with_metric_time_dimension__plan0.xml | 426 +++---- .../BigQuery/test_distinct_values__plan0.sql | 112 +- .../test_distinct_values__plan0_optimized.sql | 2 +- ...th_where_constraint_on_join_dim__plan0.sql | 112 +- ...onstraint_on_join_dim__plan0_optimized.sql | 6 +- .../test_join_to_scd_dimension__plan0.sql | 270 ++--- ...join_to_scd_dimension__plan0_optimized.sql | 14 +- ...al_dimension_using_local_entity__plan0.sql | 112 +- ...on_using_local_entity__plan0_optimized.sql | 2 +- .../test_measure_constraint__plan0.sql | 224 ++-- ...st_measure_constraint__plan0_optimized.sql | 12 +- ..._multiple_sources_no_dimensions__plan0.sql | 112 +- ...sources_no_dimensions__plan0_optimized.sql | 2 +- ...multi_hop_through_scd_dimension__plan0.sql | 322 ++--- ...through_scd_dimension__plan0_optimized.sql | 16 +- ...test_multi_hop_to_scd_dimension__plan0.sql | 266 ++-- ..._hop_to_scd_dimension__plan0_optimized.sql | 16 +- .../BigQuery/test_multihop_node__plan0.sql | 238 ++-- .../test_multihop_node__plan0_optimized.sql | 22 +- ..._multiple_metrics_no_dimensions__plan0.sql | 112 +- ...metrics_no_dimensions__plan0_optimized.sql | 2 +- .../BigQuery/test_partitioned_join__plan0.sql | 240 ++-- ...test_partitioned_join__plan0_optimized.sql | 10 +- .../test_distinct_values__plan0.sql | 112 +- .../test_distinct_values__plan0_optimized.sql | 2 +- ...th_where_constraint_on_join_dim__plan0.sql | 112 +- ...onstraint_on_join_dim__plan0_optimized.sql | 6 +- .../test_join_to_scd_dimension__plan0.sql | 270 ++--- ...join_to_scd_dimension__plan0_optimized.sql | 14 +- ...al_dimension_using_local_entity__plan0.sql | 112 +- ...on_using_local_entity__plan0_optimized.sql | 2 +- .../test_measure_constraint__plan0.sql | 224 ++-- ...st_measure_constraint__plan0_optimized.sql | 12 +- ..._multiple_sources_no_dimensions__plan0.sql | 112 +- ...sources_no_dimensions__plan0_optimized.sql | 2 +- ...multi_hop_through_scd_dimension__plan0.sql | 322 ++--- ...through_scd_dimension__plan0_optimized.sql | 16 +- ...test_multi_hop_to_scd_dimension__plan0.sql | 266 ++-- ..._hop_to_scd_dimension__plan0_optimized.sql | 16 +- .../Databricks/test_multihop_node__plan0.sql | 238 ++-- .../test_multihop_node__plan0_optimized.sql | 22 +- ..._multiple_metrics_no_dimensions__plan0.sql | 112 +- ...metrics_no_dimensions__plan0_optimized.sql | 2 +- .../test_partitioned_join__plan0.sql | 240 ++-- ...test_partitioned_join__plan0_optimized.sql | 12 +- .../DuckDB/test_distinct_values__plan0.sql | 112 +- .../test_distinct_values__plan0_optimized.sql | 2 +- ...th_where_constraint_on_join_dim__plan0.sql | 112 +- ...onstraint_on_join_dim__plan0_optimized.sql | 6 +- .../test_join_to_scd_dimension__plan0.sql | 270 ++--- ...join_to_scd_dimension__plan0_optimized.sql | 14 +- ...al_dimension_using_local_entity__plan0.sql | 112 +- ...on_using_local_entity__plan0_optimized.sql | 2 +- .../DuckDB/test_measure_constraint__plan0.sql | 224 ++-- ...st_measure_constraint__plan0_optimized.sql | 12 +- ..._multiple_sources_no_dimensions__plan0.sql | 112 +- ...sources_no_dimensions__plan0_optimized.sql | 2 +- ...multi_hop_through_scd_dimension__plan0.sql | 322 ++--- ...through_scd_dimension__plan0_optimized.sql | 16 +- ...test_multi_hop_to_scd_dimension__plan0.sql | 266 ++-- ..._hop_to_scd_dimension__plan0_optimized.sql | 16 +- .../DuckDB/test_multihop_node__plan0.sql | 238 ++-- .../test_multihop_node__plan0_optimized.sql | 22 +- ..._multiple_metrics_no_dimensions__plan0.sql | 112 +- ...metrics_no_dimensions__plan0_optimized.sql | 2 +- .../DuckDB/test_partitioned_join__plan0.sql | 240 ++-- ...test_partitioned_join__plan0_optimized.sql | 12 +- .../Postgres/test_distinct_values__plan0.sql | 112 +- .../test_distinct_values__plan0_optimized.sql | 2 +- ...th_where_constraint_on_join_dim__plan0.sql | 112 +- ...onstraint_on_join_dim__plan0_optimized.sql | 6 +- .../test_join_to_scd_dimension__plan0.sql | 270 ++--- ...join_to_scd_dimension__plan0_optimized.sql | 14 +- ...al_dimension_using_local_entity__plan0.sql | 112 +- ...on_using_local_entity__plan0_optimized.sql | 2 +- .../test_measure_constraint__plan0.sql | 224 ++-- ...st_measure_constraint__plan0_optimized.sql | 12 +- ..._multiple_sources_no_dimensions__plan0.sql | 112 +- ...sources_no_dimensions__plan0_optimized.sql | 2 +- ...multi_hop_through_scd_dimension__plan0.sql | 322 ++--- ...through_scd_dimension__plan0_optimized.sql | 16 +- ...test_multi_hop_to_scd_dimension__plan0.sql | 266 ++-- ..._hop_to_scd_dimension__plan0_optimized.sql | 16 +- .../Postgres/test_multihop_node__plan0.sql | 238 ++-- .../test_multihop_node__plan0_optimized.sql | 22 +- ..._multiple_metrics_no_dimensions__plan0.sql | 112 +- ...metrics_no_dimensions__plan0_optimized.sql | 2 +- .../Postgres/test_partitioned_join__plan0.sql | 240 ++-- ...test_partitioned_join__plan0_optimized.sql | 12 +- .../Redshift/test_distinct_values__plan0.sql | 112 +- .../test_distinct_values__plan0_optimized.sql | 2 +- ...th_where_constraint_on_join_dim__plan0.sql | 112 +- ...onstraint_on_join_dim__plan0_optimized.sql | 6 +- .../test_join_to_scd_dimension__plan0.sql | 270 ++--- ...join_to_scd_dimension__plan0_optimized.sql | 14 +- ...al_dimension_using_local_entity__plan0.sql | 112 +- ...on_using_local_entity__plan0_optimized.sql | 2 +- .../test_measure_constraint__plan0.sql | 224 ++-- ...st_measure_constraint__plan0_optimized.sql | 12 +- ..._multiple_sources_no_dimensions__plan0.sql | 112 +- ...sources_no_dimensions__plan0_optimized.sql | 2 +- ...multi_hop_through_scd_dimension__plan0.sql | 322 ++--- ...through_scd_dimension__plan0_optimized.sql | 16 +- ...test_multi_hop_to_scd_dimension__plan0.sql | 266 ++-- ..._hop_to_scd_dimension__plan0_optimized.sql | 16 +- .../Redshift/test_multihop_node__plan0.sql | 238 ++-- .../test_multihop_node__plan0_optimized.sql | 22 +- ..._multiple_metrics_no_dimensions__plan0.sql | 112 +- ...metrics_no_dimensions__plan0_optimized.sql | 2 +- .../Redshift/test_partitioned_join__plan0.sql | 240 ++-- ...test_partitioned_join__plan0_optimized.sql | 12 +- .../Snowflake/test_distinct_values__plan0.sql | 112 +- .../test_distinct_values__plan0_optimized.sql | 2 +- ...th_where_constraint_on_join_dim__plan0.sql | 112 +- ...onstraint_on_join_dim__plan0_optimized.sql | 6 +- .../test_join_to_scd_dimension__plan0.sql | 270 ++--- ...join_to_scd_dimension__plan0_optimized.sql | 14 +- ...al_dimension_using_local_entity__plan0.sql | 112 +- ...on_using_local_entity__plan0_optimized.sql | 2 +- .../test_measure_constraint__plan0.sql | 224 ++-- ...st_measure_constraint__plan0_optimized.sql | 12 +- ..._multiple_sources_no_dimensions__plan0.sql | 112 +- ...sources_no_dimensions__plan0_optimized.sql | 2 +- ...multi_hop_through_scd_dimension__plan0.sql | 322 ++--- ...through_scd_dimension__plan0_optimized.sql | 16 +- ...test_multi_hop_to_scd_dimension__plan0.sql | 266 ++-- ..._hop_to_scd_dimension__plan0_optimized.sql | 16 +- .../Snowflake/test_multihop_node__plan0.sql | 238 ++-- .../test_multihop_node__plan0_optimized.sql | 22 +- ..._multiple_metrics_no_dimensions__plan0.sql | 112 +- ...metrics_no_dimensions__plan0_optimized.sql | 2 +- .../test_partitioned_join__plan0.sql | 240 ++-- ...test_partitioned_join__plan0_optimized.sql | 12 +- .../dict/test_get_names__result0.txt | 9 +- ...2_metrics_from_1_semantic_model__dfp_0.xml | 12 +- ..._metrics_from_2_semantic_models__dfp_0.xml | 6 +- ...o_metrics_from_1_semantic_model__dfp_0.xml | 8 +- ..._metrics_from_2_semantic_models__dfp_0.xml | 8 +- ...constrained_metric_not_combined__dfp_0.xml | 4 +- .../test_derived_metric__dfp_0.xml | 4 +- ..._metric_with_non_derived_metric__dfp_0.xml | 6 +- .../test_nested_derived_metric__dfp_0.xml | 8 +- 417 files changed, 15276 insertions(+), 15269 deletions(-) diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/BigQuery/test_convert_query_semantic_model__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/BigQuery/test_convert_query_semantic_model__plan0.sql index 19a328a12f..4bd9dd2362 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/BigQuery/test_convert_query_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/BigQuery/test_convert_query_semantic_model__plan0.sql @@ -1,28 +1,28 @@ -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC(revenue_src_10006.created_at, day) AS ds__day - , DATE_TRUNC(revenue_src_10006.created_at, isoweek) AS ds__week - , DATE_TRUNC(revenue_src_10006.created_at, month) AS ds__month - , DATE_TRUNC(revenue_src_10006.created_at, quarter) AS ds__quarter - , DATE_TRUNC(revenue_src_10006.created_at, year) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM revenue_src_10006.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_10006.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC(revenue_src_10006.created_at, day) AS company__ds__day - , DATE_TRUNC(revenue_src_10006.created_at, isoweek) AS company__ds__week - , DATE_TRUNC(revenue_src_10006.created_at, month) AS company__ds__month - , DATE_TRUNC(revenue_src_10006.created_at, quarter) AS company__ds__quarter - , DATE_TRUNC(revenue_src_10006.created_at, year) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , IF(EXTRACT(dayofweek FROM revenue_src_10006.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_10006.created_at) - 1) AS company__ds__extract_dow - , EXTRACT(dayofyear FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user -FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC(revenue_src_10007.created_at, day) AS ds__day + , DATE_TRUNC(revenue_src_10007.created_at, isoweek) AS ds__week + , DATE_TRUNC(revenue_src_10007.created_at, month) AS ds__month + , DATE_TRUNC(revenue_src_10007.created_at, quarter) AS ds__quarter + , DATE_TRUNC(revenue_src_10007.created_at, year) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM revenue_src_10007.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_10007.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC(revenue_src_10007.created_at, day) AS company__ds__day + , DATE_TRUNC(revenue_src_10007.created_at, isoweek) AS company__ds__week + , DATE_TRUNC(revenue_src_10007.created_at, month) AS company__ds__month + , DATE_TRUNC(revenue_src_10007.created_at, quarter) AS company__ds__quarter + , DATE_TRUNC(revenue_src_10007.created_at, year) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , IF(EXTRACT(dayofweek FROM revenue_src_10007.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_10007.created_at) - 1) AS company__ds__extract_dow + , EXTRACT(dayofyear FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user +FROM ***************************.fct_revenue revenue_src_10007 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/BigQuery/test_convert_table_semantic_model_with_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/BigQuery/test_convert_table_semantic_model_with_measures__plan0.sql index 284de08fda..64b103e126 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/BigQuery/test_convert_table_semantic_model_with_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/BigQuery/test_convert_table_semantic_model_with_measures__plan0.sql @@ -1,53 +1,53 @@ -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , DATE_TRUNC(id_verifications_src_10003.ds, day) AS ds__day - , DATE_TRUNC(id_verifications_src_10003.ds, isoweek) AS ds__week - , DATE_TRUNC(id_verifications_src_10003.ds, month) AS ds__month - , DATE_TRUNC(id_verifications_src_10003.ds, quarter) AS ds__quarter - , DATE_TRUNC(id_verifications_src_10003.ds, year) AS ds__year - , EXTRACT(year FROM id_verifications_src_10003.ds) AS ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds) AS ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds) AS ds__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM id_verifications_src_10003.ds) = 1, 7, EXTRACT(dayofweek FROM id_verifications_src_10003.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM id_verifications_src_10003.ds) AS ds__extract_doy - , DATE_TRUNC(id_verifications_src_10003.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(id_verifications_src_10003.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(id_verifications_src_10003.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(id_verifications_src_10003.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(id_verifications_src_10003.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM id_verifications_src_10003.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM id_verifications_src_10003.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_doy - , id_verifications_src_10003.verification_type - , DATE_TRUNC(id_verifications_src_10003.ds, day) AS verification__ds__day - , DATE_TRUNC(id_verifications_src_10003.ds, isoweek) AS verification__ds__week - , DATE_TRUNC(id_verifications_src_10003.ds, month) AS verification__ds__month - , DATE_TRUNC(id_verifications_src_10003.ds, quarter) AS verification__ds__quarter - , DATE_TRUNC(id_verifications_src_10003.ds, year) AS verification__ds__year - , EXTRACT(year FROM id_verifications_src_10003.ds) AS verification__ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds) AS verification__ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds) AS verification__ds__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds) AS verification__ds__extract_day - , IF(EXTRACT(dayofweek FROM id_verifications_src_10003.ds) = 1, 7, EXTRACT(dayofweek FROM id_verifications_src_10003.ds) - 1) AS verification__ds__extract_dow - , EXTRACT(dayofyear FROM id_verifications_src_10003.ds) AS verification__ds__extract_doy - , DATE_TRUNC(id_verifications_src_10003.ds_partitioned, day) AS verification__ds_partitioned__day - , DATE_TRUNC(id_verifications_src_10003.ds_partitioned, isoweek) AS verification__ds_partitioned__week - , DATE_TRUNC(id_verifications_src_10003.ds_partitioned, month) AS verification__ds_partitioned__month - , DATE_TRUNC(id_verifications_src_10003.ds_partitioned, quarter) AS verification__ds_partitioned__quarter - , DATE_TRUNC(id_verifications_src_10003.ds_partitioned, year) AS verification__ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM id_verifications_src_10003.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM id_verifications_src_10003.ds_partitioned) - 1) AS verification__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_doy - , id_verifications_src_10003.verification_type AS verification__verification_type - , id_verifications_src_10003.verification_id AS verification - , id_verifications_src_10003.user_id AS user - , id_verifications_src_10003.user_id AS verification__user -FROM ***************************.fct_id_verifications id_verifications_src_10003 + , DATE_TRUNC(id_verifications_src_10004.ds, day) AS ds__day + , DATE_TRUNC(id_verifications_src_10004.ds, isoweek) AS ds__week + , DATE_TRUNC(id_verifications_src_10004.ds, month) AS ds__month + , DATE_TRUNC(id_verifications_src_10004.ds, quarter) AS ds__quarter + , DATE_TRUNC(id_verifications_src_10004.ds, year) AS ds__year + , EXTRACT(year FROM id_verifications_src_10004.ds) AS ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds) AS ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds) AS ds__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM id_verifications_src_10004.ds) = 1, 7, EXTRACT(dayofweek FROM id_verifications_src_10004.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM id_verifications_src_10004.ds) AS ds__extract_doy + , DATE_TRUNC(id_verifications_src_10004.ds_partitioned, day) AS ds_partitioned__day + , DATE_TRUNC(id_verifications_src_10004.ds_partitioned, isoweek) AS ds_partitioned__week + , DATE_TRUNC(id_verifications_src_10004.ds_partitioned, month) AS ds_partitioned__month + , DATE_TRUNC(id_verifications_src_10004.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATE_TRUNC(id_verifications_src_10004.ds_partitioned, year) AS ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM id_verifications_src_10004.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM id_verifications_src_10004.ds_partitioned) - 1) AS ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_doy + , id_verifications_src_10004.verification_type + , DATE_TRUNC(id_verifications_src_10004.ds, day) AS verification__ds__day + , DATE_TRUNC(id_verifications_src_10004.ds, isoweek) AS verification__ds__week + , DATE_TRUNC(id_verifications_src_10004.ds, month) AS verification__ds__month + , DATE_TRUNC(id_verifications_src_10004.ds, quarter) AS verification__ds__quarter + , DATE_TRUNC(id_verifications_src_10004.ds, year) AS verification__ds__year + , EXTRACT(year FROM id_verifications_src_10004.ds) AS verification__ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds) AS verification__ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds) AS verification__ds__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds) AS verification__ds__extract_day + , IF(EXTRACT(dayofweek FROM id_verifications_src_10004.ds) = 1, 7, EXTRACT(dayofweek FROM id_verifications_src_10004.ds) - 1) AS verification__ds__extract_dow + , EXTRACT(dayofyear FROM id_verifications_src_10004.ds) AS verification__ds__extract_doy + , DATE_TRUNC(id_verifications_src_10004.ds_partitioned, day) AS verification__ds_partitioned__day + , DATE_TRUNC(id_verifications_src_10004.ds_partitioned, isoweek) AS verification__ds_partitioned__week + , DATE_TRUNC(id_verifications_src_10004.ds_partitioned, month) AS verification__ds_partitioned__month + , DATE_TRUNC(id_verifications_src_10004.ds_partitioned, quarter) AS verification__ds_partitioned__quarter + , DATE_TRUNC(id_verifications_src_10004.ds_partitioned, year) AS verification__ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM id_verifications_src_10004.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM id_verifications_src_10004.ds_partitioned) - 1) AS verification__ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_doy + , id_verifications_src_10004.verification_type AS verification__verification_type + , id_verifications_src_10004.verification_id AS verification + , id_verifications_src_10004.user_id AS user + , id_verifications_src_10004.user_id AS verification__user +FROM ***************************.fct_id_verifications id_verifications_src_10004 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/BigQuery/test_convert_table_semantic_model_without_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/BigQuery/test_convert_table_semantic_model_without_measures__plan0.sql index 7248145008..7b29d6211b 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/BigQuery/test_convert_table_semantic_model_without_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/BigQuery/test_convert_table_semantic_model_without_measures__plan0.sql @@ -1,28 +1,28 @@ -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC(users_latest_src_10008.ds, day) AS ds_latest__day - , DATE_TRUNC(users_latest_src_10008.ds, isoweek) AS ds_latest__week - , DATE_TRUNC(users_latest_src_10008.ds, month) AS ds_latest__month - , DATE_TRUNC(users_latest_src_10008.ds, quarter) AS ds_latest__quarter - , DATE_TRUNC(users_latest_src_10008.ds, year) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS ds_latest__extract_day - , IF(EXTRACT(dayofweek FROM users_latest_src_10008.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_10008.ds) - 1) AS ds_latest__extract_dow - , EXTRACT(dayofyear FROM users_latest_src_10008.ds) AS ds_latest__extract_doy - , users_latest_src_10008.home_state_latest - , DATE_TRUNC(users_latest_src_10008.ds, day) AS user__ds_latest__day - , DATE_TRUNC(users_latest_src_10008.ds, isoweek) AS user__ds_latest__week - , DATE_TRUNC(users_latest_src_10008.ds, month) AS user__ds_latest__month - , DATE_TRUNC(users_latest_src_10008.ds, quarter) AS user__ds_latest__quarter - , DATE_TRUNC(users_latest_src_10008.ds, year) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS user__ds_latest__extract_day - , IF(EXTRACT(dayofweek FROM users_latest_src_10008.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_10008.ds) - 1) AS user__ds_latest__extract_dow - , EXTRACT(dayofyear FROM users_latest_src_10008.ds) AS user__ds_latest__extract_doy - , users_latest_src_10008.home_state_latest AS user__home_state_latest - , users_latest_src_10008.user_id AS user -FROM ***************************.dim_users_latest users_latest_src_10008 + DATE_TRUNC(users_latest_src_10009.ds, day) AS ds_latest__day + , DATE_TRUNC(users_latest_src_10009.ds, isoweek) AS ds_latest__week + , DATE_TRUNC(users_latest_src_10009.ds, month) AS ds_latest__month + , DATE_TRUNC(users_latest_src_10009.ds, quarter) AS ds_latest__quarter + , DATE_TRUNC(users_latest_src_10009.ds, year) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS ds_latest__extract_day + , IF(EXTRACT(dayofweek FROM users_latest_src_10009.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_10009.ds) - 1) AS ds_latest__extract_dow + , EXTRACT(dayofyear FROM users_latest_src_10009.ds) AS ds_latest__extract_doy + , users_latest_src_10009.home_state_latest + , DATE_TRUNC(users_latest_src_10009.ds, day) AS user__ds_latest__day + , DATE_TRUNC(users_latest_src_10009.ds, isoweek) AS user__ds_latest__week + , DATE_TRUNC(users_latest_src_10009.ds, month) AS user__ds_latest__month + , DATE_TRUNC(users_latest_src_10009.ds, quarter) AS user__ds_latest__quarter + , DATE_TRUNC(users_latest_src_10009.ds, year) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS user__ds_latest__extract_day + , IF(EXTRACT(dayofweek FROM users_latest_src_10009.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_10009.ds) - 1) AS user__ds_latest__extract_dow + , EXTRACT(dayofyear FROM users_latest_src_10009.ds) AS user__ds_latest__extract_doy + , users_latest_src_10009.home_state_latest AS user__home_state_latest + , users_latest_src_10009.user_id AS user +FROM ***************************.dim_users_latest users_latest_src_10009 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Databricks/test_convert_query_semantic_model__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Databricks/test_convert_query_semantic_model__plan0.sql index e66d6dddc3..94cb5e96f9 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Databricks/test_convert_query_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Databricks/test_convert_query_semantic_model__plan0.sql @@ -1,28 +1,28 @@ -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_10006.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_10006.created_at) AS company__ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user -FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_10007.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_10007.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_10007.created_at) AS company__ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS company__ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS company__ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS company__ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_10007.created_at) AS company__ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user +FROM ***************************.fct_revenue revenue_src_10007 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Databricks/test_convert_table_semantic_model_with_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Databricks/test_convert_table_semantic_model_with_measures__plan0.sql index d600e88591..862e48e108 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Databricks/test_convert_table_semantic_model_with_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Databricks/test_convert_table_semantic_model_with_measures__plan0.sql @@ -1,53 +1,53 @@ -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , DATE_TRUNC('day', id_verifications_src_10003.ds) AS ds__day - , DATE_TRUNC('week', id_verifications_src_10003.ds) AS ds__week - , DATE_TRUNC('month', id_verifications_src_10003.ds) AS ds__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS ds__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds) AS ds__year - , EXTRACT(year FROM id_verifications_src_10003.ds) AS ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds) AS ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds) AS ds__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM id_verifications_src_10003.ds) AS ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds) AS ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_doy - , id_verifications_src_10003.verification_type - , DATE_TRUNC('day', id_verifications_src_10003.ds) AS verification__ds__day - , DATE_TRUNC('week', id_verifications_src_10003.ds) AS verification__ds__week - , DATE_TRUNC('month', id_verifications_src_10003.ds) AS verification__ds__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS verification__ds__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds) AS verification__ds__year - , EXTRACT(year FROM id_verifications_src_10003.ds) AS verification__ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds) AS verification__ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds) AS verification__ds__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds) AS verification__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM id_verifications_src_10003.ds) AS verification__ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds) AS verification__ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_doy - , id_verifications_src_10003.verification_type AS verification__verification_type - , id_verifications_src_10003.verification_id AS verification - , id_verifications_src_10003.user_id AS user - , id_verifications_src_10003.user_id AS verification__user -FROM ***************************.fct_id_verifications id_verifications_src_10003 + , DATE_TRUNC('day', id_verifications_src_10004.ds) AS ds__day + , DATE_TRUNC('week', id_verifications_src_10004.ds) AS ds__week + , DATE_TRUNC('month', id_verifications_src_10004.ds) AS ds__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds) AS ds__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds) AS ds__year + , EXTRACT(year FROM id_verifications_src_10004.ds) AS ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds) AS ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds) AS ds__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM id_verifications_src_10004.ds) AS ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds) AS ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_doy + , id_verifications_src_10004.verification_type + , DATE_TRUNC('day', id_verifications_src_10004.ds) AS verification__ds__day + , DATE_TRUNC('week', id_verifications_src_10004.ds) AS verification__ds__week + , DATE_TRUNC('month', id_verifications_src_10004.ds) AS verification__ds__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds) AS verification__ds__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds) AS verification__ds__year + , EXTRACT(year FROM id_verifications_src_10004.ds) AS verification__ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds) AS verification__ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds) AS verification__ds__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds) AS verification__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM id_verifications_src_10004.ds) AS verification__ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds) AS verification__ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_doy + , id_verifications_src_10004.verification_type AS verification__verification_type + , id_verifications_src_10004.verification_id AS verification + , id_verifications_src_10004.user_id AS user + , id_verifications_src_10004.user_id AS verification__user +FROM ***************************.fct_id_verifications id_verifications_src_10004 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Databricks/test_convert_table_semantic_model_without_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Databricks/test_convert_table_semantic_model_without_measures__plan0.sql index b0c9ffa482..e7f784069a 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Databricks/test_convert_table_semantic_model_without_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Databricks/test_convert_table_semantic_model_without_measures__plan0.sql @@ -1,28 +1,28 @@ -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_10008.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS ds_latest__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_10008.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS ds_latest__extract_doy - , users_latest_src_10008.home_state_latest - , DATE_TRUNC('day', users_latest_src_10008.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS user__ds_latest__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_10008.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS user__ds_latest__extract_doy - , users_latest_src_10008.home_state_latest AS user__home_state_latest - , users_latest_src_10008.user_id AS user -FROM ***************************.dim_users_latest users_latest_src_10008 + DATE_TRUNC('day', users_latest_src_10009.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS ds_latest__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_10009.ds) AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS ds_latest__extract_doy + , users_latest_src_10009.home_state_latest + , DATE_TRUNC('day', users_latest_src_10009.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS user__ds_latest__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_10009.ds) AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS user__ds_latest__extract_doy + , users_latest_src_10009.home_state_latest AS user__home_state_latest + , users_latest_src_10009.user_id AS user +FROM ***************************.dim_users_latest users_latest_src_10009 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/DuckDB/test_convert_query_semantic_model__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/DuckDB/test_convert_query_semantic_model__plan0.sql index 042424c85d..b86ca7f0bc 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/DuckDB/test_convert_query_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/DuckDB/test_convert_query_semantic_model__plan0.sql @@ -1,28 +1,28 @@ -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , EXTRACT(isodow FROM revenue_src_10006.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , EXTRACT(isodow FROM revenue_src_10006.created_at) AS company__ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user -FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_10007.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , EXTRACT(isodow FROM revenue_src_10007.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_10007.created_at) AS company__ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS company__ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS company__ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS company__ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , EXTRACT(isodow FROM revenue_src_10007.created_at) AS company__ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user +FROM ***************************.fct_revenue revenue_src_10007 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/DuckDB/test_convert_table_semantic_model_with_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/DuckDB/test_convert_table_semantic_model_with_measures__plan0.sql index 26f04aefa0..932b17398b 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/DuckDB/test_convert_table_semantic_model_with_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/DuckDB/test_convert_table_semantic_model_with_measures__plan0.sql @@ -1,53 +1,53 @@ -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , DATE_TRUNC('day', id_verifications_src_10003.ds) AS ds__day - , DATE_TRUNC('week', id_verifications_src_10003.ds) AS ds__week - , DATE_TRUNC('month', id_verifications_src_10003.ds) AS ds__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS ds__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds) AS ds__year - , EXTRACT(year FROM id_verifications_src_10003.ds) AS ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds) AS ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds) AS ds__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds) AS ds__extract_day - , EXTRACT(isodow FROM id_verifications_src_10003.ds) AS ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds) AS ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_doy - , id_verifications_src_10003.verification_type - , DATE_TRUNC('day', id_verifications_src_10003.ds) AS verification__ds__day - , DATE_TRUNC('week', id_verifications_src_10003.ds) AS verification__ds__week - , DATE_TRUNC('month', id_verifications_src_10003.ds) AS verification__ds__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS verification__ds__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds) AS verification__ds__year - , EXTRACT(year FROM id_verifications_src_10003.ds) AS verification__ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds) AS verification__ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds) AS verification__ds__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds) AS verification__ds__extract_day - , EXTRACT(isodow FROM id_verifications_src_10003.ds) AS verification__ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds) AS verification__ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_day - , EXTRACT(isodow FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_doy - , id_verifications_src_10003.verification_type AS verification__verification_type - , id_verifications_src_10003.verification_id AS verification - , id_verifications_src_10003.user_id AS user - , id_verifications_src_10003.user_id AS verification__user -FROM ***************************.fct_id_verifications id_verifications_src_10003 + , DATE_TRUNC('day', id_verifications_src_10004.ds) AS ds__day + , DATE_TRUNC('week', id_verifications_src_10004.ds) AS ds__week + , DATE_TRUNC('month', id_verifications_src_10004.ds) AS ds__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds) AS ds__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds) AS ds__year + , EXTRACT(year FROM id_verifications_src_10004.ds) AS ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds) AS ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds) AS ds__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds) AS ds__extract_day + , EXTRACT(isodow FROM id_verifications_src_10004.ds) AS ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds) AS ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_doy + , id_verifications_src_10004.verification_type + , DATE_TRUNC('day', id_verifications_src_10004.ds) AS verification__ds__day + , DATE_TRUNC('week', id_verifications_src_10004.ds) AS verification__ds__week + , DATE_TRUNC('month', id_verifications_src_10004.ds) AS verification__ds__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds) AS verification__ds__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds) AS verification__ds__year + , EXTRACT(year FROM id_verifications_src_10004.ds) AS verification__ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds) AS verification__ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds) AS verification__ds__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds) AS verification__ds__extract_day + , EXTRACT(isodow FROM id_verifications_src_10004.ds) AS verification__ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds) AS verification__ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_day + , EXTRACT(isodow FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_doy + , id_verifications_src_10004.verification_type AS verification__verification_type + , id_verifications_src_10004.verification_id AS verification + , id_verifications_src_10004.user_id AS user + , id_verifications_src_10004.user_id AS verification__user +FROM ***************************.fct_id_verifications id_verifications_src_10004 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/DuckDB/test_convert_table_semantic_model_without_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/DuckDB/test_convert_table_semantic_model_without_measures__plan0.sql index 9542d63f41..013c4e0878 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/DuckDB/test_convert_table_semantic_model_without_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/DuckDB/test_convert_table_semantic_model_without_measures__plan0.sql @@ -1,28 +1,28 @@ -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_10008.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_10008.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS ds_latest__extract_doy - , users_latest_src_10008.home_state_latest - , DATE_TRUNC('day', users_latest_src_10008.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS user__ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_10008.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS user__ds_latest__extract_doy - , users_latest_src_10008.home_state_latest AS user__home_state_latest - , users_latest_src_10008.user_id AS user -FROM ***************************.dim_users_latest users_latest_src_10008 + DATE_TRUNC('day', users_latest_src_10009.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS ds_latest__extract_day + , EXTRACT(isodow FROM users_latest_src_10009.ds) AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS ds_latest__extract_doy + , users_latest_src_10009.home_state_latest + , DATE_TRUNC('day', users_latest_src_10009.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS user__ds_latest__extract_day + , EXTRACT(isodow FROM users_latest_src_10009.ds) AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS user__ds_latest__extract_doy + , users_latest_src_10009.home_state_latest AS user__home_state_latest + , users_latest_src_10009.user_id AS user +FROM ***************************.dim_users_latest users_latest_src_10009 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Postgres/test_convert_query_semantic_model__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Postgres/test_convert_query_semantic_model__plan0.sql index 042424c85d..b86ca7f0bc 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Postgres/test_convert_query_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Postgres/test_convert_query_semantic_model__plan0.sql @@ -1,28 +1,28 @@ -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , EXTRACT(isodow FROM revenue_src_10006.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , EXTRACT(isodow FROM revenue_src_10006.created_at) AS company__ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user -FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_10007.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , EXTRACT(isodow FROM revenue_src_10007.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_10007.created_at) AS company__ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS company__ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS company__ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS company__ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , EXTRACT(isodow FROM revenue_src_10007.created_at) AS company__ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user +FROM ***************************.fct_revenue revenue_src_10007 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Postgres/test_convert_table_semantic_model_with_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Postgres/test_convert_table_semantic_model_with_measures__plan0.sql index 26f04aefa0..932b17398b 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Postgres/test_convert_table_semantic_model_with_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Postgres/test_convert_table_semantic_model_with_measures__plan0.sql @@ -1,53 +1,53 @@ -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , DATE_TRUNC('day', id_verifications_src_10003.ds) AS ds__day - , DATE_TRUNC('week', id_verifications_src_10003.ds) AS ds__week - , DATE_TRUNC('month', id_verifications_src_10003.ds) AS ds__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS ds__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds) AS ds__year - , EXTRACT(year FROM id_verifications_src_10003.ds) AS ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds) AS ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds) AS ds__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds) AS ds__extract_day - , EXTRACT(isodow FROM id_verifications_src_10003.ds) AS ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds) AS ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_doy - , id_verifications_src_10003.verification_type - , DATE_TRUNC('day', id_verifications_src_10003.ds) AS verification__ds__day - , DATE_TRUNC('week', id_verifications_src_10003.ds) AS verification__ds__week - , DATE_TRUNC('month', id_verifications_src_10003.ds) AS verification__ds__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS verification__ds__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds) AS verification__ds__year - , EXTRACT(year FROM id_verifications_src_10003.ds) AS verification__ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds) AS verification__ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds) AS verification__ds__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds) AS verification__ds__extract_day - , EXTRACT(isodow FROM id_verifications_src_10003.ds) AS verification__ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds) AS verification__ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_day - , EXTRACT(isodow FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_doy - , id_verifications_src_10003.verification_type AS verification__verification_type - , id_verifications_src_10003.verification_id AS verification - , id_verifications_src_10003.user_id AS user - , id_verifications_src_10003.user_id AS verification__user -FROM ***************************.fct_id_verifications id_verifications_src_10003 + , DATE_TRUNC('day', id_verifications_src_10004.ds) AS ds__day + , DATE_TRUNC('week', id_verifications_src_10004.ds) AS ds__week + , DATE_TRUNC('month', id_verifications_src_10004.ds) AS ds__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds) AS ds__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds) AS ds__year + , EXTRACT(year FROM id_verifications_src_10004.ds) AS ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds) AS ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds) AS ds__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds) AS ds__extract_day + , EXTRACT(isodow FROM id_verifications_src_10004.ds) AS ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds) AS ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_doy + , id_verifications_src_10004.verification_type + , DATE_TRUNC('day', id_verifications_src_10004.ds) AS verification__ds__day + , DATE_TRUNC('week', id_verifications_src_10004.ds) AS verification__ds__week + , DATE_TRUNC('month', id_verifications_src_10004.ds) AS verification__ds__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds) AS verification__ds__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds) AS verification__ds__year + , EXTRACT(year FROM id_verifications_src_10004.ds) AS verification__ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds) AS verification__ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds) AS verification__ds__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds) AS verification__ds__extract_day + , EXTRACT(isodow FROM id_verifications_src_10004.ds) AS verification__ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds) AS verification__ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_day + , EXTRACT(isodow FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_doy + , id_verifications_src_10004.verification_type AS verification__verification_type + , id_verifications_src_10004.verification_id AS verification + , id_verifications_src_10004.user_id AS user + , id_verifications_src_10004.user_id AS verification__user +FROM ***************************.fct_id_verifications id_verifications_src_10004 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Postgres/test_convert_table_semantic_model_without_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Postgres/test_convert_table_semantic_model_without_measures__plan0.sql index 9542d63f41..013c4e0878 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Postgres/test_convert_table_semantic_model_without_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Postgres/test_convert_table_semantic_model_without_measures__plan0.sql @@ -1,28 +1,28 @@ -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_10008.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_10008.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS ds_latest__extract_doy - , users_latest_src_10008.home_state_latest - , DATE_TRUNC('day', users_latest_src_10008.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS user__ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_10008.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS user__ds_latest__extract_doy - , users_latest_src_10008.home_state_latest AS user__home_state_latest - , users_latest_src_10008.user_id AS user -FROM ***************************.dim_users_latest users_latest_src_10008 + DATE_TRUNC('day', users_latest_src_10009.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS ds_latest__extract_day + , EXTRACT(isodow FROM users_latest_src_10009.ds) AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS ds_latest__extract_doy + , users_latest_src_10009.home_state_latest + , DATE_TRUNC('day', users_latest_src_10009.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS user__ds_latest__extract_day + , EXTRACT(isodow FROM users_latest_src_10009.ds) AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS user__ds_latest__extract_doy + , users_latest_src_10009.home_state_latest AS user__home_state_latest + , users_latest_src_10009.user_id AS user +FROM ***************************.dim_users_latest users_latest_src_10009 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Redshift/test_convert_query_semantic_model__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Redshift/test_convert_query_semantic_model__plan0.sql index 7a37739860..6ce9b03523 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Redshift/test_convert_query_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Redshift/test_convert_query_semantic_model__plan0.sql @@ -1,28 +1,28 @@ -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM revenue_src_10006.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_10006.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_10006.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , CASE WHEN EXTRACT(dow FROM revenue_src_10006.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_10006.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_10006.created_at) END AS company__ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user -FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_10007.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM revenue_src_10007.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_10007.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_10007.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_10007.created_at) AS company__ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS company__ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS company__ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS company__ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , CASE WHEN EXTRACT(dow FROM revenue_src_10007.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_10007.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_10007.created_at) END AS company__ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user +FROM ***************************.fct_revenue revenue_src_10007 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Redshift/test_convert_table_semantic_model_with_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Redshift/test_convert_table_semantic_model_with_measures__plan0.sql index 0e76cd4de4..5f55d10c39 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Redshift/test_convert_table_semantic_model_with_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Redshift/test_convert_table_semantic_model_with_measures__plan0.sql @@ -1,53 +1,53 @@ -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , DATE_TRUNC('day', id_verifications_src_10003.ds) AS ds__day - , DATE_TRUNC('week', id_verifications_src_10003.ds) AS ds__week - , DATE_TRUNC('month', id_verifications_src_10003.ds) AS ds__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS ds__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds) AS ds__year - , EXTRACT(year FROM id_verifications_src_10003.ds) AS ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds) AS ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds) AS ds__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM id_verifications_src_10003.ds) = 0 THEN EXTRACT(dow FROM id_verifications_src_10003.ds) + 7 ELSE EXTRACT(dow FROM id_verifications_src_10003.ds) END AS ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds) AS ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM id_verifications_src_10003.ds_partitioned) = 0 THEN EXTRACT(dow FROM id_verifications_src_10003.ds_partitioned) + 7 ELSE EXTRACT(dow FROM id_verifications_src_10003.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_doy - , id_verifications_src_10003.verification_type - , DATE_TRUNC('day', id_verifications_src_10003.ds) AS verification__ds__day - , DATE_TRUNC('week', id_verifications_src_10003.ds) AS verification__ds__week - , DATE_TRUNC('month', id_verifications_src_10003.ds) AS verification__ds__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS verification__ds__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds) AS verification__ds__year - , EXTRACT(year FROM id_verifications_src_10003.ds) AS verification__ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds) AS verification__ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds) AS verification__ds__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds) AS verification__ds__extract_day - , CASE WHEN EXTRACT(dow FROM id_verifications_src_10003.ds) = 0 THEN EXTRACT(dow FROM id_verifications_src_10003.ds) + 7 ELSE EXTRACT(dow FROM id_verifications_src_10003.ds) END AS verification__ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds) AS verification__ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM id_verifications_src_10003.ds_partitioned) = 0 THEN EXTRACT(dow FROM id_verifications_src_10003.ds_partitioned) + 7 ELSE EXTRACT(dow FROM id_verifications_src_10003.ds_partitioned) END AS verification__ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_doy - , id_verifications_src_10003.verification_type AS verification__verification_type - , id_verifications_src_10003.verification_id AS verification - , id_verifications_src_10003.user_id AS user - , id_verifications_src_10003.user_id AS verification__user -FROM ***************************.fct_id_verifications id_verifications_src_10003 + , DATE_TRUNC('day', id_verifications_src_10004.ds) AS ds__day + , DATE_TRUNC('week', id_verifications_src_10004.ds) AS ds__week + , DATE_TRUNC('month', id_verifications_src_10004.ds) AS ds__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds) AS ds__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds) AS ds__year + , EXTRACT(year FROM id_verifications_src_10004.ds) AS ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds) AS ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds) AS ds__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM id_verifications_src_10004.ds) = 0 THEN EXTRACT(dow FROM id_verifications_src_10004.ds) + 7 ELSE EXTRACT(dow FROM id_verifications_src_10004.ds) END AS ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds) AS ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM id_verifications_src_10004.ds_partitioned) = 0 THEN EXTRACT(dow FROM id_verifications_src_10004.ds_partitioned) + 7 ELSE EXTRACT(dow FROM id_verifications_src_10004.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_doy + , id_verifications_src_10004.verification_type + , DATE_TRUNC('day', id_verifications_src_10004.ds) AS verification__ds__day + , DATE_TRUNC('week', id_verifications_src_10004.ds) AS verification__ds__week + , DATE_TRUNC('month', id_verifications_src_10004.ds) AS verification__ds__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds) AS verification__ds__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds) AS verification__ds__year + , EXTRACT(year FROM id_verifications_src_10004.ds) AS verification__ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds) AS verification__ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds) AS verification__ds__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds) AS verification__ds__extract_day + , CASE WHEN EXTRACT(dow FROM id_verifications_src_10004.ds) = 0 THEN EXTRACT(dow FROM id_verifications_src_10004.ds) + 7 ELSE EXTRACT(dow FROM id_verifications_src_10004.ds) END AS verification__ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds) AS verification__ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM id_verifications_src_10004.ds_partitioned) = 0 THEN EXTRACT(dow FROM id_verifications_src_10004.ds_partitioned) + 7 ELSE EXTRACT(dow FROM id_verifications_src_10004.ds_partitioned) END AS verification__ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_doy + , id_verifications_src_10004.verification_type AS verification__verification_type + , id_verifications_src_10004.verification_id AS verification + , id_verifications_src_10004.user_id AS user + , id_verifications_src_10004.user_id AS verification__user +FROM ***************************.fct_id_verifications id_verifications_src_10004 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Redshift/test_convert_table_semantic_model_without_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Redshift/test_convert_table_semantic_model_without_measures__plan0.sql index 4d2d3bc182..9eb9f5d335 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Redshift/test_convert_table_semantic_model_without_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Redshift/test_convert_table_semantic_model_without_measures__plan0.sql @@ -1,28 +1,28 @@ -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_10008.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS ds_latest__extract_day - , CASE WHEN EXTRACT(dow FROM users_latest_src_10008.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_10008.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_10008.ds) END AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS ds_latest__extract_doy - , users_latest_src_10008.home_state_latest - , DATE_TRUNC('day', users_latest_src_10008.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS user__ds_latest__extract_day - , CASE WHEN EXTRACT(dow FROM users_latest_src_10008.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_10008.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_10008.ds) END AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS user__ds_latest__extract_doy - , users_latest_src_10008.home_state_latest AS user__home_state_latest - , users_latest_src_10008.user_id AS user -FROM ***************************.dim_users_latest users_latest_src_10008 + DATE_TRUNC('day', users_latest_src_10009.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS ds_latest__extract_day + , CASE WHEN EXTRACT(dow FROM users_latest_src_10009.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_10009.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_10009.ds) END AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS ds_latest__extract_doy + , users_latest_src_10009.home_state_latest + , DATE_TRUNC('day', users_latest_src_10009.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS user__ds_latest__extract_day + , CASE WHEN EXTRACT(dow FROM users_latest_src_10009.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_10009.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_10009.ds) END AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS user__ds_latest__extract_doy + , users_latest_src_10009.home_state_latest AS user__home_state_latest + , users_latest_src_10009.user_id AS user +FROM ***************************.dim_users_latest users_latest_src_10009 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Snowflake/test_convert_query_semantic_model__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Snowflake/test_convert_query_semantic_model__plan0.sql index 847aa5e171..c1b61e86bb 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Snowflake/test_convert_query_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Snowflake/test_convert_query_semantic_model__plan0.sql @@ -1,28 +1,28 @@ -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM revenue_src_10006.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , EXTRACT(dayofweekiso FROM revenue_src_10006.created_at) AS company__ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user -FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_10007.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM revenue_src_10007.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_10007.created_at) AS company__ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS company__ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS company__ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS company__ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , EXTRACT(dayofweekiso FROM revenue_src_10007.created_at) AS company__ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user +FROM ***************************.fct_revenue revenue_src_10007 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Snowflake/test_convert_table_semantic_model_with_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Snowflake/test_convert_table_semantic_model_with_measures__plan0.sql index c3becf3fc8..e40305597f 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Snowflake/test_convert_table_semantic_model_with_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Snowflake/test_convert_table_semantic_model_with_measures__plan0.sql @@ -1,53 +1,53 @@ -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , DATE_TRUNC('day', id_verifications_src_10003.ds) AS ds__day - , DATE_TRUNC('week', id_verifications_src_10003.ds) AS ds__week - , DATE_TRUNC('month', id_verifications_src_10003.ds) AS ds__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS ds__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds) AS ds__year - , EXTRACT(year FROM id_verifications_src_10003.ds) AS ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds) AS ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds) AS ds__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM id_verifications_src_10003.ds) AS ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds) AS ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_doy - , id_verifications_src_10003.verification_type - , DATE_TRUNC('day', id_verifications_src_10003.ds) AS verification__ds__day - , DATE_TRUNC('week', id_verifications_src_10003.ds) AS verification__ds__week - , DATE_TRUNC('month', id_verifications_src_10003.ds) AS verification__ds__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS verification__ds__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds) AS verification__ds__year - , EXTRACT(year FROM id_verifications_src_10003.ds) AS verification__ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds) AS verification__ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds) AS verification__ds__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds) AS verification__ds__extract_day - , EXTRACT(dayofweekiso FROM id_verifications_src_10003.ds) AS verification__ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds) AS verification__ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_doy - , id_verifications_src_10003.verification_type AS verification__verification_type - , id_verifications_src_10003.verification_id AS verification - , id_verifications_src_10003.user_id AS user - , id_verifications_src_10003.user_id AS verification__user -FROM ***************************.fct_id_verifications id_verifications_src_10003 + , DATE_TRUNC('day', id_verifications_src_10004.ds) AS ds__day + , DATE_TRUNC('week', id_verifications_src_10004.ds) AS ds__week + , DATE_TRUNC('month', id_verifications_src_10004.ds) AS ds__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds) AS ds__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds) AS ds__year + , EXTRACT(year FROM id_verifications_src_10004.ds) AS ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds) AS ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds) AS ds__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM id_verifications_src_10004.ds) AS ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds) AS ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_doy + , id_verifications_src_10004.verification_type + , DATE_TRUNC('day', id_verifications_src_10004.ds) AS verification__ds__day + , DATE_TRUNC('week', id_verifications_src_10004.ds) AS verification__ds__week + , DATE_TRUNC('month', id_verifications_src_10004.ds) AS verification__ds__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds) AS verification__ds__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds) AS verification__ds__year + , EXTRACT(year FROM id_verifications_src_10004.ds) AS verification__ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds) AS verification__ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds) AS verification__ds__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds) AS verification__ds__extract_day + , EXTRACT(dayofweekiso FROM id_verifications_src_10004.ds) AS verification__ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds) AS verification__ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_doy + , id_verifications_src_10004.verification_type AS verification__verification_type + , id_verifications_src_10004.verification_id AS verification + , id_verifications_src_10004.user_id AS user + , id_verifications_src_10004.user_id AS verification__user +FROM ***************************.fct_id_verifications id_verifications_src_10004 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Snowflake/test_convert_table_semantic_model_without_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Snowflake/test_convert_table_semantic_model_without_measures__plan0.sql index 397bd30737..b8df56ea6e 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Snowflake/test_convert_table_semantic_model_without_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Snowflake/test_convert_table_semantic_model_without_measures__plan0.sql @@ -1,28 +1,28 @@ -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_10008.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS ds_latest__extract_day - , EXTRACT(dayofweekiso FROM users_latest_src_10008.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS ds_latest__extract_doy - , users_latest_src_10008.home_state_latest - , DATE_TRUNC('day', users_latest_src_10008.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS user__ds_latest__extract_day - , EXTRACT(dayofweekiso FROM users_latest_src_10008.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS user__ds_latest__extract_doy - , users_latest_src_10008.home_state_latest AS user__home_state_latest - , users_latest_src_10008.user_id AS user -FROM ***************************.dim_users_latest users_latest_src_10008 + DATE_TRUNC('day', users_latest_src_10009.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS ds_latest__extract_day + , EXTRACT(dayofweekiso FROM users_latest_src_10009.ds) AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS ds_latest__extract_doy + , users_latest_src_10009.home_state_latest + , DATE_TRUNC('day', users_latest_src_10009.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS user__ds_latest__extract_day + , EXTRACT(dayofweekiso FROM users_latest_src_10009.ds) AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS user__ds_latest__extract_doy + , users_latest_src_10009.home_state_latest AS user__home_state_latest + , users_latest_src_10009.user_id AS user +FROM ***************************.dim_users_latest users_latest_src_10009 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric__plan0.sql index afa8a0e0f3..de71c5fb21 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric__plan0.sql @@ -55,32 +55,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC(revenue_src_10006.created_at, day) AS ds__day - , DATE_TRUNC(revenue_src_10006.created_at, isoweek) AS ds__week - , DATE_TRUNC(revenue_src_10006.created_at, month) AS ds__month - , DATE_TRUNC(revenue_src_10006.created_at, quarter) AS ds__quarter - , DATE_TRUNC(revenue_src_10006.created_at, year) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM revenue_src_10006.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_10006.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC(revenue_src_10006.created_at, day) AS company__ds__day - , DATE_TRUNC(revenue_src_10006.created_at, isoweek) AS company__ds__week - , DATE_TRUNC(revenue_src_10006.created_at, month) AS company__ds__month - , DATE_TRUNC(revenue_src_10006.created_at, quarter) AS company__ds__quarter - , DATE_TRUNC(revenue_src_10006.created_at, year) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , IF(EXTRACT(dayofweek FROM revenue_src_10006.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_10006.created_at) - 1) AS company__ds__extract_dow - , EXTRACT(dayofyear FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user - FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC(revenue_src_10007.created_at, day) AS ds__day + , DATE_TRUNC(revenue_src_10007.created_at, isoweek) AS ds__week + , DATE_TRUNC(revenue_src_10007.created_at, month) AS ds__month + , DATE_TRUNC(revenue_src_10007.created_at, quarter) AS ds__quarter + , DATE_TRUNC(revenue_src_10007.created_at, year) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM revenue_src_10007.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_10007.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC(revenue_src_10007.created_at, day) AS company__ds__day + , DATE_TRUNC(revenue_src_10007.created_at, isoweek) AS company__ds__week + , DATE_TRUNC(revenue_src_10007.created_at, month) AS company__ds__month + , DATE_TRUNC(revenue_src_10007.created_at, quarter) AS company__ds__quarter + , DATE_TRUNC(revenue_src_10007.created_at, year) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , IF(EXTRACT(dayofweek FROM revenue_src_10007.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_10007.created_at) - 1) AS company__ds__extract_dow + , EXTRACT(dayofyear FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user + FROM ***************************.fct_revenue revenue_src_10007 ) subq_0 ) subq_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric__plan0_optimized.sql index b6ff9f7d86..15636ea177 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric__plan0_optimized.sql @@ -7,6 +7,6 @@ SELECT DATE_TRUNC(created_at, month) AS ds__month , SUM(revenue) AS trailing_2_months_revenue -FROM ***************************.fct_revenue revenue_src_10006 +FROM ***************************.fct_revenue revenue_src_10007 GROUP BY ds__month diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_grain_to_date__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_grain_to_date__plan0.sql index c9d7d2faa1..0d2e548a31 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_grain_to_date__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_grain_to_date__plan0.sql @@ -55,32 +55,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC(revenue_src_10006.created_at, day) AS ds__day - , DATE_TRUNC(revenue_src_10006.created_at, isoweek) AS ds__week - , DATE_TRUNC(revenue_src_10006.created_at, month) AS ds__month - , DATE_TRUNC(revenue_src_10006.created_at, quarter) AS ds__quarter - , DATE_TRUNC(revenue_src_10006.created_at, year) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM revenue_src_10006.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_10006.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC(revenue_src_10006.created_at, day) AS company__ds__day - , DATE_TRUNC(revenue_src_10006.created_at, isoweek) AS company__ds__week - , DATE_TRUNC(revenue_src_10006.created_at, month) AS company__ds__month - , DATE_TRUNC(revenue_src_10006.created_at, quarter) AS company__ds__quarter - , DATE_TRUNC(revenue_src_10006.created_at, year) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , IF(EXTRACT(dayofweek FROM revenue_src_10006.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_10006.created_at) - 1) AS company__ds__extract_dow - , EXTRACT(dayofyear FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user - FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC(revenue_src_10007.created_at, day) AS ds__day + , DATE_TRUNC(revenue_src_10007.created_at, isoweek) AS ds__week + , DATE_TRUNC(revenue_src_10007.created_at, month) AS ds__month + , DATE_TRUNC(revenue_src_10007.created_at, quarter) AS ds__quarter + , DATE_TRUNC(revenue_src_10007.created_at, year) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM revenue_src_10007.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_10007.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC(revenue_src_10007.created_at, day) AS company__ds__day + , DATE_TRUNC(revenue_src_10007.created_at, isoweek) AS company__ds__week + , DATE_TRUNC(revenue_src_10007.created_at, month) AS company__ds__month + , DATE_TRUNC(revenue_src_10007.created_at, quarter) AS company__ds__quarter + , DATE_TRUNC(revenue_src_10007.created_at, year) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , IF(EXTRACT(dayofweek FROM revenue_src_10007.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_10007.created_at) - 1) AS company__ds__extract_dow + , EXTRACT(dayofyear FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user + FROM ***************************.fct_revenue revenue_src_10007 ) subq_0 ) subq_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_grain_to_date__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_grain_to_date__plan0_optimized.sql index c21f67d4dd..c7246651d4 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_grain_to_date__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_grain_to_date__plan0_optimized.sql @@ -7,6 +7,6 @@ SELECT DATE_TRUNC(created_at, month) AS ds__month , SUM(revenue) AS revenue_mtd -FROM ***************************.fct_revenue revenue_src_10006 +FROM ***************************.fct_revenue revenue_src_10007 GROUP BY ds__month diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_ds__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_ds__plan0.sql index 2c7d07c454..ad2d825f25 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_ds__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_ds__plan0.sql @@ -52,32 +52,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC(revenue_src_10006.created_at, day) AS ds__day - , DATE_TRUNC(revenue_src_10006.created_at, isoweek) AS ds__week - , DATE_TRUNC(revenue_src_10006.created_at, month) AS ds__month - , DATE_TRUNC(revenue_src_10006.created_at, quarter) AS ds__quarter - , DATE_TRUNC(revenue_src_10006.created_at, year) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM revenue_src_10006.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_10006.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC(revenue_src_10006.created_at, day) AS company__ds__day - , DATE_TRUNC(revenue_src_10006.created_at, isoweek) AS company__ds__week - , DATE_TRUNC(revenue_src_10006.created_at, month) AS company__ds__month - , DATE_TRUNC(revenue_src_10006.created_at, quarter) AS company__ds__quarter - , DATE_TRUNC(revenue_src_10006.created_at, year) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , IF(EXTRACT(dayofweek FROM revenue_src_10006.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_10006.created_at) - 1) AS company__ds__extract_dow - , EXTRACT(dayofyear FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user - FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC(revenue_src_10007.created_at, day) AS ds__day + , DATE_TRUNC(revenue_src_10007.created_at, isoweek) AS ds__week + , DATE_TRUNC(revenue_src_10007.created_at, month) AS ds__month + , DATE_TRUNC(revenue_src_10007.created_at, quarter) AS ds__quarter + , DATE_TRUNC(revenue_src_10007.created_at, year) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM revenue_src_10007.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_10007.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC(revenue_src_10007.created_at, day) AS company__ds__day + , DATE_TRUNC(revenue_src_10007.created_at, isoweek) AS company__ds__week + , DATE_TRUNC(revenue_src_10007.created_at, month) AS company__ds__month + , DATE_TRUNC(revenue_src_10007.created_at, quarter) AS company__ds__quarter + , DATE_TRUNC(revenue_src_10007.created_at, year) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , IF(EXTRACT(dayofweek FROM revenue_src_10007.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_10007.created_at) - 1) AS company__ds__extract_dow + , EXTRACT(dayofyear FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user + FROM ***************************.fct_revenue revenue_src_10007 ) subq_0 ) subq_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_ds__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_ds__plan0_optimized.sql index ba2c45a4ca..30e9e6946d 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_ds__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_ds__plan0_optimized.sql @@ -6,4 +6,4 @@ -- Compute Metrics via Expressions SELECT SUM(revenue) AS trailing_2_months_revenue -FROM ***************************.fct_revenue revenue_src_10006 +FROM ***************************.fct_revenue revenue_src_10007 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window__plan0.sql index 777b8b4e5c..812a5a3df7 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window__plan0.sql @@ -55,32 +55,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC(revenue_src_10006.created_at, day) AS ds__day - , DATE_TRUNC(revenue_src_10006.created_at, isoweek) AS ds__week - , DATE_TRUNC(revenue_src_10006.created_at, month) AS ds__month - , DATE_TRUNC(revenue_src_10006.created_at, quarter) AS ds__quarter - , DATE_TRUNC(revenue_src_10006.created_at, year) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM revenue_src_10006.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_10006.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC(revenue_src_10006.created_at, day) AS company__ds__day - , DATE_TRUNC(revenue_src_10006.created_at, isoweek) AS company__ds__week - , DATE_TRUNC(revenue_src_10006.created_at, month) AS company__ds__month - , DATE_TRUNC(revenue_src_10006.created_at, quarter) AS company__ds__quarter - , DATE_TRUNC(revenue_src_10006.created_at, year) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , IF(EXTRACT(dayofweek FROM revenue_src_10006.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_10006.created_at) - 1) AS company__ds__extract_dow - , EXTRACT(dayofyear FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user - FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC(revenue_src_10007.created_at, day) AS ds__day + , DATE_TRUNC(revenue_src_10007.created_at, isoweek) AS ds__week + , DATE_TRUNC(revenue_src_10007.created_at, month) AS ds__month + , DATE_TRUNC(revenue_src_10007.created_at, quarter) AS ds__quarter + , DATE_TRUNC(revenue_src_10007.created_at, year) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM revenue_src_10007.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_10007.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC(revenue_src_10007.created_at, day) AS company__ds__day + , DATE_TRUNC(revenue_src_10007.created_at, isoweek) AS company__ds__week + , DATE_TRUNC(revenue_src_10007.created_at, month) AS company__ds__month + , DATE_TRUNC(revenue_src_10007.created_at, quarter) AS company__ds__quarter + , DATE_TRUNC(revenue_src_10007.created_at, year) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , IF(EXTRACT(dayofweek FROM revenue_src_10007.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_10007.created_at) - 1) AS company__ds__extract_dow + , EXTRACT(dayofyear FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user + FROM ***************************.fct_revenue revenue_src_10007 ) subq_0 ) subq_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window__plan0_optimized.sql index eebbf50011..2593a184e9 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window__plan0_optimized.sql @@ -7,6 +7,6 @@ SELECT DATE_TRUNC(created_at, month) AS ds__month , SUM(revenue) AS revenue_all_time -FROM ***************************.fct_revenue revenue_src_10006 +FROM ***************************.fct_revenue revenue_src_10007 GROUP BY ds__month diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index ea0b27e65b..d5a1be0f94 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -94,32 +94,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC(revenue_src_10006.created_at, day) AS ds__day - , DATE_TRUNC(revenue_src_10006.created_at, isoweek) AS ds__week - , DATE_TRUNC(revenue_src_10006.created_at, month) AS ds__month - , DATE_TRUNC(revenue_src_10006.created_at, quarter) AS ds__quarter - , DATE_TRUNC(revenue_src_10006.created_at, year) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM revenue_src_10006.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_10006.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC(revenue_src_10006.created_at, day) AS company__ds__day - , DATE_TRUNC(revenue_src_10006.created_at, isoweek) AS company__ds__week - , DATE_TRUNC(revenue_src_10006.created_at, month) AS company__ds__month - , DATE_TRUNC(revenue_src_10006.created_at, quarter) AS company__ds__quarter - , DATE_TRUNC(revenue_src_10006.created_at, year) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , IF(EXTRACT(dayofweek FROM revenue_src_10006.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_10006.created_at) - 1) AS company__ds__extract_dow - , EXTRACT(dayofyear FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user - FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC(revenue_src_10007.created_at, day) AS ds__day + , DATE_TRUNC(revenue_src_10007.created_at, isoweek) AS ds__week + , DATE_TRUNC(revenue_src_10007.created_at, month) AS ds__month + , DATE_TRUNC(revenue_src_10007.created_at, quarter) AS ds__quarter + , DATE_TRUNC(revenue_src_10007.created_at, year) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM revenue_src_10007.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_10007.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC(revenue_src_10007.created_at, day) AS company__ds__day + , DATE_TRUNC(revenue_src_10007.created_at, isoweek) AS company__ds__week + , DATE_TRUNC(revenue_src_10007.created_at, month) AS company__ds__month + , DATE_TRUNC(revenue_src_10007.created_at, quarter) AS company__ds__quarter + , DATE_TRUNC(revenue_src_10007.created_at, year) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , IF(EXTRACT(dayofweek FROM revenue_src_10007.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_10007.created_at) - 1) AS company__ds__extract_dow + , EXTRACT(dayofyear FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user + FROM ***************************.fct_revenue revenue_src_10007 ) subq_0 ) subq_1 WHERE subq_1.metric_time__day BETWEEN '2000-01-01' AND '2020-01-01' diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index aa655a506a..7fd7a7751f 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -8,7 +8,7 @@ SELECT DATE_TRUNC(created_at, month) AS ds__month , SUM(revenue) AS revenue_all_time -FROM ***************************.fct_revenue revenue_src_10006 +FROM ***************************.fct_revenue revenue_src_10007 WHERE DATE_TRUNC(created_at, day) BETWEEN '2000-01-01' AND '2020-01-01' GROUP BY ds__month diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0.sql index 02f70d25bb..8be394c2d3 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0.sql @@ -145,32 +145,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC(revenue_src_10006.created_at, day) AS ds__day - , DATE_TRUNC(revenue_src_10006.created_at, isoweek) AS ds__week - , DATE_TRUNC(revenue_src_10006.created_at, month) AS ds__month - , DATE_TRUNC(revenue_src_10006.created_at, quarter) AS ds__quarter - , DATE_TRUNC(revenue_src_10006.created_at, year) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM revenue_src_10006.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_10006.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC(revenue_src_10006.created_at, day) AS company__ds__day - , DATE_TRUNC(revenue_src_10006.created_at, isoweek) AS company__ds__week - , DATE_TRUNC(revenue_src_10006.created_at, month) AS company__ds__month - , DATE_TRUNC(revenue_src_10006.created_at, quarter) AS company__ds__quarter - , DATE_TRUNC(revenue_src_10006.created_at, year) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , IF(EXTRACT(dayofweek FROM revenue_src_10006.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_10006.created_at) - 1) AS company__ds__extract_dow - , EXTRACT(dayofyear FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user - FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC(revenue_src_10007.created_at, day) AS ds__day + , DATE_TRUNC(revenue_src_10007.created_at, isoweek) AS ds__week + , DATE_TRUNC(revenue_src_10007.created_at, month) AS ds__month + , DATE_TRUNC(revenue_src_10007.created_at, quarter) AS ds__quarter + , DATE_TRUNC(revenue_src_10007.created_at, year) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM revenue_src_10007.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_10007.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC(revenue_src_10007.created_at, day) AS company__ds__day + , DATE_TRUNC(revenue_src_10007.created_at, isoweek) AS company__ds__week + , DATE_TRUNC(revenue_src_10007.created_at, month) AS company__ds__month + , DATE_TRUNC(revenue_src_10007.created_at, quarter) AS company__ds__quarter + , DATE_TRUNC(revenue_src_10007.created_at, year) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , IF(EXTRACT(dayofweek FROM revenue_src_10007.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_10007.created_at) - 1) AS company__ds__extract_dow + , EXTRACT(dayofyear FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user + FROM ***************************.fct_revenue revenue_src_10007 ) subq_0 ) subq_1 WHERE subq_1.metric_time__day BETWEEN '2019-11-01' AND '2020-01-01' diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index ef1a5f85e5..64c276d3bd 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -22,7 +22,7 @@ INNER JOIN ( DATE_TRUNC(created_at, day) AS metric_time__day , DATE_TRUNC(created_at, month) AS metric_time__month , revenue AS txn_revenue - FROM ***************************.fct_revenue revenue_src_10006 + FROM ***************************.fct_revenue revenue_src_10007 WHERE DATE_TRUNC(created_at, day) BETWEEN '2019-11-01' AND '2020-01-01' ) subq_11 ON diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric__plan0.sql index 72257900d1..8e11af172d 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric__plan0.sql @@ -55,32 +55,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_10006.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_10006.created_at) AS company__ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user - FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_10007.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_10007.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_10007.created_at) AS company__ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS company__ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS company__ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS company__ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_10007.created_at) AS company__ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user + FROM ***************************.fct_revenue revenue_src_10007 ) subq_0 ) subq_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric__plan0_optimized.sql index 6596468bca..efe2244b0f 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric__plan0_optimized.sql @@ -7,6 +7,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS trailing_2_months_revenue -FROM ***************************.fct_revenue revenue_src_10006 +FROM ***************************.fct_revenue revenue_src_10007 GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_grain_to_date__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_grain_to_date__plan0.sql index 7ee47bd1e6..de8d290b71 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_grain_to_date__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_grain_to_date__plan0.sql @@ -55,32 +55,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_10006.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_10006.created_at) AS company__ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user - FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_10007.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_10007.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_10007.created_at) AS company__ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS company__ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS company__ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS company__ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_10007.created_at) AS company__ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user + FROM ***************************.fct_revenue revenue_src_10007 ) subq_0 ) subq_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_grain_to_date__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_grain_to_date__plan0_optimized.sql index 06853be07e..a44bb5a72b 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_grain_to_date__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_grain_to_date__plan0_optimized.sql @@ -7,6 +7,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS revenue_mtd -FROM ***************************.fct_revenue revenue_src_10006 +FROM ***************************.fct_revenue revenue_src_10007 GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_ds__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_ds__plan0.sql index 0f0e838642..5cd4d1796e 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_ds__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_ds__plan0.sql @@ -52,32 +52,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_10006.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_10006.created_at) AS company__ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user - FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_10007.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_10007.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_10007.created_at) AS company__ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS company__ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS company__ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS company__ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_10007.created_at) AS company__ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user + FROM ***************************.fct_revenue revenue_src_10007 ) subq_0 ) subq_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_ds__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_ds__plan0_optimized.sql index ba2c45a4ca..30e9e6946d 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_ds__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_ds__plan0_optimized.sql @@ -6,4 +6,4 @@ -- Compute Metrics via Expressions SELECT SUM(revenue) AS trailing_2_months_revenue -FROM ***************************.fct_revenue revenue_src_10006 +FROM ***************************.fct_revenue revenue_src_10007 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window__plan0.sql index f63f9071b0..86fa446aec 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window__plan0.sql @@ -55,32 +55,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_10006.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_10006.created_at) AS company__ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user - FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_10007.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_10007.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_10007.created_at) AS company__ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS company__ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS company__ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS company__ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_10007.created_at) AS company__ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user + FROM ***************************.fct_revenue revenue_src_10007 ) subq_0 ) subq_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window__plan0_optimized.sql index 220fb6083c..ccf3a0f545 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window__plan0_optimized.sql @@ -7,6 +7,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS revenue_all_time -FROM ***************************.fct_revenue revenue_src_10006 +FROM ***************************.fct_revenue revenue_src_10007 GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index 692c080b72..cab6fd0874 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -94,32 +94,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_10006.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_10006.created_at) AS company__ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user - FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_10007.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_10007.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_10007.created_at) AS company__ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS company__ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS company__ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS company__ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_10007.created_at) AS company__ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user + FROM ***************************.fct_revenue revenue_src_10007 ) subq_0 ) subq_1 WHERE subq_1.metric_time__day BETWEEN '2000-01-01' AND '2020-01-01' diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index dfc97e9ec9..626c4d3de3 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -8,7 +8,7 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS revenue_all_time -FROM ***************************.fct_revenue revenue_src_10006 +FROM ***************************.fct_revenue revenue_src_10007 WHERE DATE_TRUNC('day', created_at) BETWEEN '2000-01-01' AND '2020-01-01' GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0.sql index b3ed84f97d..c24b6f9a53 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0.sql @@ -145,32 +145,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_10006.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_10006.created_at) AS company__ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user - FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_10007.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_10007.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_10007.created_at) AS company__ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS company__ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS company__ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS company__ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_10007.created_at) AS company__ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user + FROM ***************************.fct_revenue revenue_src_10007 ) subq_0 ) subq_1 WHERE subq_1.metric_time__day BETWEEN '2019-11-01' AND '2020-01-01' diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index 5b70e3b1bf..e07bcfae32 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -22,7 +22,7 @@ INNER JOIN ( DATE_TRUNC('day', created_at) AS metric_time__day , DATE_TRUNC('month', created_at) AS metric_time__month , revenue AS txn_revenue - FROM ***************************.fct_revenue revenue_src_10006 + FROM ***************************.fct_revenue revenue_src_10007 WHERE DATE_TRUNC('day', created_at) BETWEEN '2019-11-01' AND '2020-01-01' ) subq_11 ON diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric__plan0.sql index e9c34e79c1..8e782b48da 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric__plan0.sql @@ -55,32 +55,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , EXTRACT(isodow FROM revenue_src_10006.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , EXTRACT(isodow FROM revenue_src_10006.created_at) AS company__ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user - FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_10007.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , EXTRACT(isodow FROM revenue_src_10007.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_10007.created_at) AS company__ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS company__ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS company__ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS company__ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , EXTRACT(isodow FROM revenue_src_10007.created_at) AS company__ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user + FROM ***************************.fct_revenue revenue_src_10007 ) subq_0 ) subq_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric__plan0_optimized.sql index 6596468bca..efe2244b0f 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric__plan0_optimized.sql @@ -7,6 +7,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS trailing_2_months_revenue -FROM ***************************.fct_revenue revenue_src_10006 +FROM ***************************.fct_revenue revenue_src_10007 GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_grain_to_date__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_grain_to_date__plan0.sql index 3f894968de..fb7c5634e7 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_grain_to_date__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_grain_to_date__plan0.sql @@ -55,32 +55,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , EXTRACT(isodow FROM revenue_src_10006.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , EXTRACT(isodow FROM revenue_src_10006.created_at) AS company__ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user - FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_10007.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , EXTRACT(isodow FROM revenue_src_10007.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_10007.created_at) AS company__ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS company__ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS company__ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS company__ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , EXTRACT(isodow FROM revenue_src_10007.created_at) AS company__ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user + FROM ***************************.fct_revenue revenue_src_10007 ) subq_0 ) subq_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_grain_to_date__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_grain_to_date__plan0_optimized.sql index 06853be07e..a44bb5a72b 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_grain_to_date__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_grain_to_date__plan0_optimized.sql @@ -7,6 +7,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS revenue_mtd -FROM ***************************.fct_revenue revenue_src_10006 +FROM ***************************.fct_revenue revenue_src_10007 GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_ds__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_ds__plan0.sql index 2db07399cd..cf42f8c8c9 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_ds__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_ds__plan0.sql @@ -52,32 +52,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , EXTRACT(isodow FROM revenue_src_10006.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , EXTRACT(isodow FROM revenue_src_10006.created_at) AS company__ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user - FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_10007.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , EXTRACT(isodow FROM revenue_src_10007.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_10007.created_at) AS company__ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS company__ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS company__ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS company__ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , EXTRACT(isodow FROM revenue_src_10007.created_at) AS company__ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user + FROM ***************************.fct_revenue revenue_src_10007 ) subq_0 ) subq_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_ds__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_ds__plan0_optimized.sql index ba2c45a4ca..30e9e6946d 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_ds__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_ds__plan0_optimized.sql @@ -6,4 +6,4 @@ -- Compute Metrics via Expressions SELECT SUM(revenue) AS trailing_2_months_revenue -FROM ***************************.fct_revenue revenue_src_10006 +FROM ***************************.fct_revenue revenue_src_10007 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window__plan0.sql index 883b02bd6e..2e2e9a1615 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window__plan0.sql @@ -55,32 +55,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , EXTRACT(isodow FROM revenue_src_10006.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , EXTRACT(isodow FROM revenue_src_10006.created_at) AS company__ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user - FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_10007.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , EXTRACT(isodow FROM revenue_src_10007.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_10007.created_at) AS company__ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS company__ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS company__ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS company__ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , EXTRACT(isodow FROM revenue_src_10007.created_at) AS company__ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user + FROM ***************************.fct_revenue revenue_src_10007 ) subq_0 ) subq_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window__plan0_optimized.sql index 220fb6083c..ccf3a0f545 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window__plan0_optimized.sql @@ -7,6 +7,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS revenue_all_time -FROM ***************************.fct_revenue revenue_src_10006 +FROM ***************************.fct_revenue revenue_src_10007 GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index 672f04d4d2..f8f9b92af1 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -94,32 +94,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , EXTRACT(isodow FROM revenue_src_10006.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , EXTRACT(isodow FROM revenue_src_10006.created_at) AS company__ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user - FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_10007.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , EXTRACT(isodow FROM revenue_src_10007.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_10007.created_at) AS company__ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS company__ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS company__ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS company__ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , EXTRACT(isodow FROM revenue_src_10007.created_at) AS company__ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user + FROM ***************************.fct_revenue revenue_src_10007 ) subq_0 ) subq_1 WHERE subq_1.metric_time__day BETWEEN '2000-01-01' AND '2020-01-01' diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index dfc97e9ec9..626c4d3de3 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -8,7 +8,7 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS revenue_all_time -FROM ***************************.fct_revenue revenue_src_10006 +FROM ***************************.fct_revenue revenue_src_10007 WHERE DATE_TRUNC('day', created_at) BETWEEN '2000-01-01' AND '2020-01-01' GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_time_constraint__plan0.sql index 2afa239f5c..b0b8fc7f6f 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_time_constraint__plan0.sql @@ -145,32 +145,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , EXTRACT(isodow FROM revenue_src_10006.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , EXTRACT(isodow FROM revenue_src_10006.created_at) AS company__ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user - FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_10007.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , EXTRACT(isodow FROM revenue_src_10007.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_10007.created_at) AS company__ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS company__ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS company__ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS company__ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , EXTRACT(isodow FROM revenue_src_10007.created_at) AS company__ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user + FROM ***************************.fct_revenue revenue_src_10007 ) subq_0 ) subq_1 WHERE subq_1.metric_time__day BETWEEN '2019-11-01' AND '2020-01-01' diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index a07cb2047d..aeca8a05d9 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -22,7 +22,7 @@ INNER JOIN ( DATE_TRUNC('day', created_at) AS metric_time__day , DATE_TRUNC('month', created_at) AS metric_time__month , revenue AS txn_revenue - FROM ***************************.fct_revenue revenue_src_10006 + FROM ***************************.fct_revenue revenue_src_10007 WHERE DATE_TRUNC('day', created_at) BETWEEN '2019-11-01' AND '2020-01-01' ) subq_11 ON diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric__plan0.sql index e9c34e79c1..8e782b48da 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric__plan0.sql @@ -55,32 +55,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , EXTRACT(isodow FROM revenue_src_10006.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , EXTRACT(isodow FROM revenue_src_10006.created_at) AS company__ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user - FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_10007.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , EXTRACT(isodow FROM revenue_src_10007.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_10007.created_at) AS company__ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS company__ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS company__ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS company__ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , EXTRACT(isodow FROM revenue_src_10007.created_at) AS company__ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user + FROM ***************************.fct_revenue revenue_src_10007 ) subq_0 ) subq_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric__plan0_optimized.sql index 6596468bca..efe2244b0f 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric__plan0_optimized.sql @@ -7,6 +7,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS trailing_2_months_revenue -FROM ***************************.fct_revenue revenue_src_10006 +FROM ***************************.fct_revenue revenue_src_10007 GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_grain_to_date__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_grain_to_date__plan0.sql index 3f894968de..fb7c5634e7 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_grain_to_date__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_grain_to_date__plan0.sql @@ -55,32 +55,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , EXTRACT(isodow FROM revenue_src_10006.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , EXTRACT(isodow FROM revenue_src_10006.created_at) AS company__ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user - FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_10007.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , EXTRACT(isodow FROM revenue_src_10007.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_10007.created_at) AS company__ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS company__ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS company__ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS company__ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , EXTRACT(isodow FROM revenue_src_10007.created_at) AS company__ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user + FROM ***************************.fct_revenue revenue_src_10007 ) subq_0 ) subq_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_grain_to_date__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_grain_to_date__plan0_optimized.sql index 06853be07e..a44bb5a72b 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_grain_to_date__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_grain_to_date__plan0_optimized.sql @@ -7,6 +7,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS revenue_mtd -FROM ***************************.fct_revenue revenue_src_10006 +FROM ***************************.fct_revenue revenue_src_10007 GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_ds__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_ds__plan0.sql index 2db07399cd..cf42f8c8c9 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_ds__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_ds__plan0.sql @@ -52,32 +52,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , EXTRACT(isodow FROM revenue_src_10006.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , EXTRACT(isodow FROM revenue_src_10006.created_at) AS company__ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user - FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_10007.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , EXTRACT(isodow FROM revenue_src_10007.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_10007.created_at) AS company__ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS company__ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS company__ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS company__ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , EXTRACT(isodow FROM revenue_src_10007.created_at) AS company__ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user + FROM ***************************.fct_revenue revenue_src_10007 ) subq_0 ) subq_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_ds__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_ds__plan0_optimized.sql index ba2c45a4ca..30e9e6946d 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_ds__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_ds__plan0_optimized.sql @@ -6,4 +6,4 @@ -- Compute Metrics via Expressions SELECT SUM(revenue) AS trailing_2_months_revenue -FROM ***************************.fct_revenue revenue_src_10006 +FROM ***************************.fct_revenue revenue_src_10007 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window__plan0.sql index 883b02bd6e..2e2e9a1615 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window__plan0.sql @@ -55,32 +55,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , EXTRACT(isodow FROM revenue_src_10006.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , EXTRACT(isodow FROM revenue_src_10006.created_at) AS company__ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user - FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_10007.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , EXTRACT(isodow FROM revenue_src_10007.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_10007.created_at) AS company__ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS company__ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS company__ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS company__ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , EXTRACT(isodow FROM revenue_src_10007.created_at) AS company__ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user + FROM ***************************.fct_revenue revenue_src_10007 ) subq_0 ) subq_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window__plan0_optimized.sql index 220fb6083c..ccf3a0f545 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window__plan0_optimized.sql @@ -7,6 +7,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS revenue_all_time -FROM ***************************.fct_revenue revenue_src_10006 +FROM ***************************.fct_revenue revenue_src_10007 GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index 672f04d4d2..f8f9b92af1 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -94,32 +94,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , EXTRACT(isodow FROM revenue_src_10006.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , EXTRACT(isodow FROM revenue_src_10006.created_at) AS company__ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user - FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_10007.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , EXTRACT(isodow FROM revenue_src_10007.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_10007.created_at) AS company__ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS company__ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS company__ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS company__ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , EXTRACT(isodow FROM revenue_src_10007.created_at) AS company__ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user + FROM ***************************.fct_revenue revenue_src_10007 ) subq_0 ) subq_1 WHERE subq_1.metric_time__day BETWEEN '2000-01-01' AND '2020-01-01' diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index dfc97e9ec9..626c4d3de3 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -8,7 +8,7 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS revenue_all_time -FROM ***************************.fct_revenue revenue_src_10006 +FROM ***************************.fct_revenue revenue_src_10007 WHERE DATE_TRUNC('day', created_at) BETWEEN '2000-01-01' AND '2020-01-01' GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0.sql index 7b83bc743e..fe5aede2c9 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0.sql @@ -145,32 +145,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , EXTRACT(isodow FROM revenue_src_10006.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , EXTRACT(isodow FROM revenue_src_10006.created_at) AS company__ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user - FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_10007.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , EXTRACT(isodow FROM revenue_src_10007.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_10007.created_at) AS company__ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS company__ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS company__ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS company__ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , EXTRACT(isodow FROM revenue_src_10007.created_at) AS company__ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user + FROM ***************************.fct_revenue revenue_src_10007 ) subq_0 ) subq_1 WHERE subq_1.metric_time__day BETWEEN '2019-11-01' AND '2020-01-01' diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index d9f814c03e..be9486e423 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -22,7 +22,7 @@ INNER JOIN ( DATE_TRUNC('day', created_at) AS metric_time__day , DATE_TRUNC('month', created_at) AS metric_time__month , revenue AS txn_revenue - FROM ***************************.fct_revenue revenue_src_10006 + FROM ***************************.fct_revenue revenue_src_10007 WHERE DATE_TRUNC('day', created_at) BETWEEN '2019-11-01' AND '2020-01-01' ) subq_11 ON diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric__plan0.sql index 4f23d5e988..fd2e82bd9b 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric__plan0.sql @@ -55,32 +55,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM revenue_src_10006.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_10006.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_10006.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , CASE WHEN EXTRACT(dow FROM revenue_src_10006.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_10006.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_10006.created_at) END AS company__ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user - FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_10007.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM revenue_src_10007.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_10007.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_10007.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_10007.created_at) AS company__ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS company__ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS company__ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS company__ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , CASE WHEN EXTRACT(dow FROM revenue_src_10007.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_10007.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_10007.created_at) END AS company__ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user + FROM ***************************.fct_revenue revenue_src_10007 ) subq_0 ) subq_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric__plan0_optimized.sql index 6596468bca..efe2244b0f 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric__plan0_optimized.sql @@ -7,6 +7,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS trailing_2_months_revenue -FROM ***************************.fct_revenue revenue_src_10006 +FROM ***************************.fct_revenue revenue_src_10007 GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_grain_to_date__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_grain_to_date__plan0.sql index 9f419a21e4..d7a6cea5e2 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_grain_to_date__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_grain_to_date__plan0.sql @@ -55,32 +55,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM revenue_src_10006.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_10006.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_10006.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , CASE WHEN EXTRACT(dow FROM revenue_src_10006.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_10006.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_10006.created_at) END AS company__ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user - FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_10007.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM revenue_src_10007.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_10007.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_10007.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_10007.created_at) AS company__ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS company__ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS company__ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS company__ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , CASE WHEN EXTRACT(dow FROM revenue_src_10007.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_10007.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_10007.created_at) END AS company__ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user + FROM ***************************.fct_revenue revenue_src_10007 ) subq_0 ) subq_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_grain_to_date__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_grain_to_date__plan0_optimized.sql index 06853be07e..a44bb5a72b 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_grain_to_date__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_grain_to_date__plan0_optimized.sql @@ -7,6 +7,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS revenue_mtd -FROM ***************************.fct_revenue revenue_src_10006 +FROM ***************************.fct_revenue revenue_src_10007 GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_ds__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_ds__plan0.sql index 226fe6d125..bf110f16b9 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_ds__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_ds__plan0.sql @@ -52,32 +52,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM revenue_src_10006.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_10006.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_10006.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , CASE WHEN EXTRACT(dow FROM revenue_src_10006.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_10006.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_10006.created_at) END AS company__ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user - FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_10007.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM revenue_src_10007.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_10007.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_10007.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_10007.created_at) AS company__ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS company__ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS company__ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS company__ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , CASE WHEN EXTRACT(dow FROM revenue_src_10007.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_10007.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_10007.created_at) END AS company__ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user + FROM ***************************.fct_revenue revenue_src_10007 ) subq_0 ) subq_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_ds__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_ds__plan0_optimized.sql index ba2c45a4ca..30e9e6946d 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_ds__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_ds__plan0_optimized.sql @@ -6,4 +6,4 @@ -- Compute Metrics via Expressions SELECT SUM(revenue) AS trailing_2_months_revenue -FROM ***************************.fct_revenue revenue_src_10006 +FROM ***************************.fct_revenue revenue_src_10007 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window__plan0.sql index 41828b2675..6c79a40275 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window__plan0.sql @@ -55,32 +55,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM revenue_src_10006.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_10006.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_10006.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , CASE WHEN EXTRACT(dow FROM revenue_src_10006.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_10006.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_10006.created_at) END AS company__ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user - FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_10007.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM revenue_src_10007.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_10007.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_10007.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_10007.created_at) AS company__ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS company__ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS company__ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS company__ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , CASE WHEN EXTRACT(dow FROM revenue_src_10007.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_10007.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_10007.created_at) END AS company__ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user + FROM ***************************.fct_revenue revenue_src_10007 ) subq_0 ) subq_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window__plan0_optimized.sql index 220fb6083c..ccf3a0f545 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window__plan0_optimized.sql @@ -7,6 +7,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS revenue_all_time -FROM ***************************.fct_revenue revenue_src_10006 +FROM ***************************.fct_revenue revenue_src_10007 GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index af59e47a92..2f393acaab 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -94,32 +94,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM revenue_src_10006.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_10006.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_10006.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , CASE WHEN EXTRACT(dow FROM revenue_src_10006.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_10006.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_10006.created_at) END AS company__ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user - FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_10007.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM revenue_src_10007.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_10007.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_10007.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_10007.created_at) AS company__ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS company__ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS company__ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS company__ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , CASE WHEN EXTRACT(dow FROM revenue_src_10007.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_10007.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_10007.created_at) END AS company__ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user + FROM ***************************.fct_revenue revenue_src_10007 ) subq_0 ) subq_1 WHERE subq_1.metric_time__day BETWEEN '2000-01-01' AND '2020-01-01' diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index dfc97e9ec9..626c4d3de3 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -8,7 +8,7 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS revenue_all_time -FROM ***************************.fct_revenue revenue_src_10006 +FROM ***************************.fct_revenue revenue_src_10007 WHERE DATE_TRUNC('day', created_at) BETWEEN '2000-01-01' AND '2020-01-01' GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0.sql index d26ac1871a..cf1553ca5a 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0.sql @@ -145,32 +145,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM revenue_src_10006.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_10006.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_10006.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , CASE WHEN EXTRACT(dow FROM revenue_src_10006.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_10006.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_10006.created_at) END AS company__ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user - FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_10007.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM revenue_src_10007.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_10007.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_10007.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_10007.created_at) AS company__ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS company__ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS company__ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS company__ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , CASE WHEN EXTRACT(dow FROM revenue_src_10007.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_10007.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_10007.created_at) END AS company__ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user + FROM ***************************.fct_revenue revenue_src_10007 ) subq_0 ) subq_1 WHERE subq_1.metric_time__day BETWEEN '2019-11-01' AND '2020-01-01' diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index 5b70e3b1bf..e07bcfae32 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -22,7 +22,7 @@ INNER JOIN ( DATE_TRUNC('day', created_at) AS metric_time__day , DATE_TRUNC('month', created_at) AS metric_time__month , revenue AS txn_revenue - FROM ***************************.fct_revenue revenue_src_10006 + FROM ***************************.fct_revenue revenue_src_10007 WHERE DATE_TRUNC('day', created_at) BETWEEN '2019-11-01' AND '2020-01-01' ) subq_11 ON diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric__plan0.sql index 59e98524b7..7d05945b26 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric__plan0.sql @@ -55,32 +55,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM revenue_src_10006.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , EXTRACT(dayofweekiso FROM revenue_src_10006.created_at) AS company__ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user - FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_10007.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM revenue_src_10007.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_10007.created_at) AS company__ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS company__ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS company__ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS company__ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , EXTRACT(dayofweekiso FROM revenue_src_10007.created_at) AS company__ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user + FROM ***************************.fct_revenue revenue_src_10007 ) subq_0 ) subq_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric__plan0_optimized.sql index 6596468bca..efe2244b0f 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric__plan0_optimized.sql @@ -7,6 +7,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS trailing_2_months_revenue -FROM ***************************.fct_revenue revenue_src_10006 +FROM ***************************.fct_revenue revenue_src_10007 GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_grain_to_date__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_grain_to_date__plan0.sql index ad25f27c56..bc77d193e1 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_grain_to_date__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_grain_to_date__plan0.sql @@ -55,32 +55,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM revenue_src_10006.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , EXTRACT(dayofweekiso FROM revenue_src_10006.created_at) AS company__ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user - FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_10007.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM revenue_src_10007.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_10007.created_at) AS company__ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS company__ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS company__ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS company__ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , EXTRACT(dayofweekiso FROM revenue_src_10007.created_at) AS company__ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user + FROM ***************************.fct_revenue revenue_src_10007 ) subq_0 ) subq_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_grain_to_date__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_grain_to_date__plan0_optimized.sql index 06853be07e..a44bb5a72b 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_grain_to_date__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_grain_to_date__plan0_optimized.sql @@ -7,6 +7,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS revenue_mtd -FROM ***************************.fct_revenue revenue_src_10006 +FROM ***************************.fct_revenue revenue_src_10007 GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_ds__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_ds__plan0.sql index 9633c0a6ea..4dae379c23 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_ds__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_ds__plan0.sql @@ -52,32 +52,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM revenue_src_10006.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , EXTRACT(dayofweekiso FROM revenue_src_10006.created_at) AS company__ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user - FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_10007.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM revenue_src_10007.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_10007.created_at) AS company__ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS company__ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS company__ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS company__ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , EXTRACT(dayofweekiso FROM revenue_src_10007.created_at) AS company__ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user + FROM ***************************.fct_revenue revenue_src_10007 ) subq_0 ) subq_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_ds__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_ds__plan0_optimized.sql index ba2c45a4ca..30e9e6946d 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_ds__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_ds__plan0_optimized.sql @@ -6,4 +6,4 @@ -- Compute Metrics via Expressions SELECT SUM(revenue) AS trailing_2_months_revenue -FROM ***************************.fct_revenue revenue_src_10006 +FROM ***************************.fct_revenue revenue_src_10007 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window__plan0.sql index 722eaf2886..c7747a8b63 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window__plan0.sql @@ -55,32 +55,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM revenue_src_10006.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , EXTRACT(dayofweekiso FROM revenue_src_10006.created_at) AS company__ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user - FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_10007.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM revenue_src_10007.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_10007.created_at) AS company__ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS company__ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS company__ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS company__ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , EXTRACT(dayofweekiso FROM revenue_src_10007.created_at) AS company__ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user + FROM ***************************.fct_revenue revenue_src_10007 ) subq_0 ) subq_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window__plan0_optimized.sql index 220fb6083c..ccf3a0f545 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window__plan0_optimized.sql @@ -7,6 +7,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS revenue_all_time -FROM ***************************.fct_revenue revenue_src_10006 +FROM ***************************.fct_revenue revenue_src_10007 GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index 2f993be406..0647e65d7f 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -94,32 +94,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM revenue_src_10006.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , EXTRACT(dayofweekiso FROM revenue_src_10006.created_at) AS company__ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user - FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_10007.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM revenue_src_10007.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_10007.created_at) AS company__ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS company__ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS company__ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS company__ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , EXTRACT(dayofweekiso FROM revenue_src_10007.created_at) AS company__ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user + FROM ***************************.fct_revenue revenue_src_10007 ) subq_0 ) subq_1 WHERE subq_1.metric_time__day BETWEEN '2000-01-01' AND '2020-01-01' diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index dfc97e9ec9..626c4d3de3 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -8,7 +8,7 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS revenue_all_time -FROM ***************************.fct_revenue revenue_src_10006 +FROM ***************************.fct_revenue revenue_src_10007 WHERE DATE_TRUNC('day', created_at) BETWEEN '2000-01-01' AND '2020-01-01' GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0.sql index baaff08bb6..5f19de2215 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0.sql @@ -145,32 +145,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_10006.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM revenue_src_10006.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day - , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week - , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month - , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter - , DATE_TRUNC('year', revenue_src_10006.created_at) AS company__ds__year - , EXTRACT(year FROM revenue_src_10006.created_at) AS company__ds__extract_year - , EXTRACT(quarter FROM revenue_src_10006.created_at) AS company__ds__extract_quarter - , EXTRACT(month FROM revenue_src_10006.created_at) AS company__ds__extract_month - , EXTRACT(day FROM revenue_src_10006.created_at) AS company__ds__extract_day - , EXTRACT(dayofweekiso FROM revenue_src_10006.created_at) AS company__ds__extract_dow - , EXTRACT(doy FROM revenue_src_10006.created_at) AS company__ds__extract_doy - , revenue_src_10006.user_id AS user - , revenue_src_10006.user_id AS company__user - FROM ***************************.fct_revenue revenue_src_10006 + revenue_src_10007.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_10007.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM revenue_src_10007.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_10007.created_at) AS company__ds__day + , DATE_TRUNC('week', revenue_src_10007.created_at) AS company__ds__week + , DATE_TRUNC('month', revenue_src_10007.created_at) AS company__ds__month + , DATE_TRUNC('quarter', revenue_src_10007.created_at) AS company__ds__quarter + , DATE_TRUNC('year', revenue_src_10007.created_at) AS company__ds__year + , EXTRACT(year FROM revenue_src_10007.created_at) AS company__ds__extract_year + , EXTRACT(quarter FROM revenue_src_10007.created_at) AS company__ds__extract_quarter + , EXTRACT(month FROM revenue_src_10007.created_at) AS company__ds__extract_month + , EXTRACT(day FROM revenue_src_10007.created_at) AS company__ds__extract_day + , EXTRACT(dayofweekiso FROM revenue_src_10007.created_at) AS company__ds__extract_dow + , EXTRACT(doy FROM revenue_src_10007.created_at) AS company__ds__extract_doy + , revenue_src_10007.user_id AS user + , revenue_src_10007.user_id AS company__user + FROM ***************************.fct_revenue revenue_src_10007 ) subq_0 ) subq_1 WHERE subq_1.metric_time__day BETWEEN '2019-11-01' AND '2020-01-01' diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index 5b70e3b1bf..e07bcfae32 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -22,7 +22,7 @@ INNER JOIN ( DATE_TRUNC('day', created_at) AS metric_time__day , DATE_TRUNC('month', created_at) AS metric_time__month , revenue AS txn_revenue - FROM ***************************.fct_revenue revenue_src_10006 + FROM ***************************.fct_revenue revenue_src_10007 WHERE DATE_TRUNC('day', created_at) BETWEEN '2019-11-01' AND '2020-01-01' ) subq_11 ON diff --git a/metricflow/test/snapshots/test_cyclic_join.py/DataflowPlan/test_cyclic_join__dfp_0.xml b/metricflow/test/snapshots/test_cyclic_join.py/DataflowPlan/test_cyclic_join__dfp_0.xml index 510611daaf..c3d520b39f 100644 --- a/metricflow/test/snapshots/test_cyclic_join.py/DataflowPlan/test_cyclic_join__dfp_0.xml +++ b/metricflow/test/snapshots/test_cyclic_join.py/DataflowPlan/test_cyclic_join__dfp_0.xml @@ -61,12 +61,12 @@ - + - + @@ -89,7 +89,7 @@ - + diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_common_semantic_model__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_common_semantic_model__dfp_0.xml index 99061839c1..8c15f6c100 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_common_semantic_model__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_common_semantic_model__dfp_0.xml @@ -79,7 +79,7 @@ - + @@ -96,12 +96,12 @@ - + - + @@ -185,7 +185,7 @@ - + @@ -202,12 +202,12 @@ - + - + diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_cumulative_metric_no_window_or_grain_with_metric_time__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_cumulative_metric_no_window_or_grain_with_metric_time__dfp_0.xml index 07c1cf0b90..4a0dd87951 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_cumulative_metric_no_window_or_grain_with_metric_time__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_cumulative_metric_no_window_or_grain_with_metric_time__dfp_0.xml @@ -38,12 +38,12 @@ - + - + diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_cumulative_metric_no_window_or_grain_without_metric_time__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_cumulative_metric_no_window_or_grain_without_metric_time__dfp_0.xml index b46aae1d6e..8270fff2c3 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_cumulative_metric_no_window_or_grain_without_metric_time__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_cumulative_metric_no_window_or_grain_without_metric_time__dfp_0.xml @@ -28,12 +28,12 @@ - + - + diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_cumulative_metric_with_window__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_cumulative_metric_with_window__dfp_0.xml index 8ab0f1bb08..dae89d21f9 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_cumulative_metric_with_window__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_cumulative_metric_with_window__dfp_0.xml @@ -38,12 +38,12 @@ - + - + diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_to_grain__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_to_grain__dfp_0.xml index d639638086..c412254afb 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_to_grain__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_to_grain__dfp_0.xml @@ -53,7 +53,7 @@ - + @@ -113,7 +113,7 @@ - + diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_window__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_window__dfp_0.xml index 1499e61ee9..2c3d7849b0 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_window__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_window__dfp_0.xml @@ -66,7 +66,7 @@ - + diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_with_granularity__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_with_granularity__dfp_0.xml index bef4e50147..7e13107d4c 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_with_granularity__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_with_granularity__dfp_0.xml @@ -66,7 +66,7 @@ - + diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_offset_cumulative_metric__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_offset_cumulative_metric__dfp_0.xml index 1178ac5cba..882aaf1576 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_offset_cumulative_metric__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_offset_cumulative_metric__dfp_0.xml @@ -69,7 +69,7 @@ - + diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_distinct_values_plan__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_distinct_values_plan__dfp_0.xml index f222418611..bc88e60b4f 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_distinct_values_plan__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_distinct_values_plan__dfp_0.xml @@ -40,7 +40,7 @@ - + diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_distinct_values_plan_with_join__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_distinct_values_plan_with_join__dfp_0.xml index 720015e76a..a7651ddf4d 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_distinct_values_plan_with_join__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_distinct_values_plan_with_join__dfp_0.xml @@ -57,7 +57,7 @@ - + @@ -75,7 +75,7 @@ - + diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_dont_join_to_time_spine_if_no_time_dimension_requested__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_dont_join_to_time_spine_if_no_time_dimension_requested__dfp_0.xml index 7d687dd6d5..7d0b5f5f3d 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_dont_join_to_time_spine_if_no_time_dimension_requested__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_dont_join_to_time_spine_if_no_time_dimension_requested__dfp_0.xml @@ -33,7 +33,7 @@ - + diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_derived_metric__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_derived_metric__dfp_0.xml index 47685e1624..90eec4c377 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_derived_metric__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_derived_metric__dfp_0.xml @@ -67,7 +67,7 @@ - + @@ -144,7 +144,7 @@ - + diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_with_metric_time__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_with_metric_time__dfp_0.xml index 7f851c1783..0e80f4db7f 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_with_metric_time__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_with_metric_time__dfp_0.xml @@ -54,7 +54,7 @@ - + diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_with_non_metric_time__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_with_non_metric_time__dfp_0.xml index 162e2061a0..73a1c16304 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_with_non_metric_time__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_with_non_metric_time__dfp_0.xml @@ -40,7 +40,7 @@ - + diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_joined_plan__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_joined_plan__dfp_0.xml index 4b98ec3365..b3c1dd3eb1 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_joined_plan__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_joined_plan__dfp_0.xml @@ -70,7 +70,7 @@ - + @@ -87,12 +87,12 @@ - + - + diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_limit_rows_plan__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_limit_rows_plan__dfp_0.xml index a3ceaf37a9..400879d7a2 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_limit_rows_plan__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_limit_rows_plan__dfp_0.xml @@ -44,7 +44,7 @@ - + diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_measure_constraint_plan__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_measure_constraint_plan__dfp_0.xml index b380475c4f..aca0998c6c 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_measure_constraint_plan__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_measure_constraint_plan__dfp_0.xml @@ -131,7 +131,7 @@ - + @@ -147,12 +147,12 @@ - + - + @@ -280,7 +280,7 @@ - + @@ -296,12 +296,12 @@ - + - + @@ -351,7 +351,7 @@ - + diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_measure_constraint_with_reused_measure_plan__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_measure_constraint_with_reused_measure_plan__dfp_0.xml index f2381a7789..b74a7149be 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_measure_constraint_with_reused_measure_plan__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_measure_constraint_with_reused_measure_plan__dfp_0.xml @@ -99,7 +99,7 @@ - + @@ -147,7 +147,7 @@ - + diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_multi_semantic_model_ratio_metrics_plan__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_multi_semantic_model_ratio_metrics_plan__dfp_0.xml index a8cd2a96ed..0b271a7442 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_multi_semantic_model_ratio_metrics_plan__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_multi_semantic_model_ratio_metrics_plan__dfp_0.xml @@ -89,7 +89,7 @@ - + @@ -106,12 +106,12 @@ - + - + @@ -190,12 +190,12 @@ - + - + @@ -212,12 +212,12 @@ - + - + diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_multihop_join_plan__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_multihop_join_plan__dfp_0.xml index 895e1bcd1b..d4aaa02c60 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_multihop_join_plan__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_multihop_join_plan__dfp_0.xml @@ -80,12 +80,12 @@ - + - + @@ -140,7 +140,7 @@ - + @@ -347,7 +347,7 @@ - + diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_multiple_metrics_plan__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_multiple_metrics_plan__dfp_0.xml index 5768b4b593..128020a39a 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_multiple_metrics_plan__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_multiple_metrics_plan__dfp_0.xml @@ -47,7 +47,7 @@ - + @@ -97,7 +97,7 @@ - + diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_nested_derived_metric_with_outer_offset__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_nested_derived_metric_with_outer_offset__dfp_0.xml index b901742279..0f786a70a0 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_nested_derived_metric_with_outer_offset__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_nested_derived_metric_with_outer_offset__dfp_0.xml @@ -92,7 +92,7 @@ - + diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_order_by_plan__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_order_by_plan__dfp_0.xml index 5c14fade18..6fb7a7ba88 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_order_by_plan__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_order_by_plan__dfp_0.xml @@ -62,7 +62,7 @@ - + diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_primary_entity_dimension__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_primary_entity_dimension__dfp_0.xml index 02a48b5e93..7c50967037 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_primary_entity_dimension__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_primary_entity_dimension__dfp_0.xml @@ -37,7 +37,7 @@ - + diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_simple_plan__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_simple_plan__dfp_0.xml index 02a48b5e93..7c50967037 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_simple_plan__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_simple_plan__dfp_0.xml @@ -37,7 +37,7 @@ - + diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_single_semantic_model_ratio_metrics_plan__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_single_semantic_model_ratio_metrics_plan__dfp_0.xml index 8d4232cd99..9ba3db2335 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_single_semantic_model_ratio_metrics_plan__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_single_semantic_model_ratio_metrics_plan__dfp_0.xml @@ -89,7 +89,7 @@ - + @@ -106,12 +106,12 @@ - + - + @@ -195,7 +195,7 @@ - + @@ -212,12 +212,12 @@ - + - + diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_where_constrained_plan__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_where_constrained_plan__dfp_0.xml index eadd0c296c..36082e469f 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_where_constrained_plan__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_where_constrained_plan__dfp_0.xml @@ -109,7 +109,7 @@ - + @@ -126,12 +126,12 @@ - + - + diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_where_constrained_plan_time_dimension__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_where_constrained_plan_time_dimension__dfp_0.xml index f249c3469d..749880ff74 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_where_constrained_plan_time_dimension__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_where_constrained_plan_time_dimension__dfp_0.xml @@ -87,7 +87,7 @@ - + diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_where_constrained_with_common_linkable_plan__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_where_constrained_with_common_linkable_plan__dfp_0.xml index edec9fcdc8..53e8e35f03 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_where_constrained_with_common_linkable_plan__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_where_constrained_with_common_linkable_plan__dfp_0.xml @@ -86,7 +86,7 @@ - + @@ -103,12 +103,12 @@ - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_joined_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_joined_plan__ep_0.xml index 4141b27cc2..b9a1524a5f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_joined_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_joined_plan__ep_0.xml @@ -10,7 +10,7 @@ - + @@ -24,9 +24,9 @@ - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_multihop_joined_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_multihop_joined_plan__ep_0.xml index b76e1367e7..bcfcddc821 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_multihop_joined_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_multihop_joined_plan__ep_0.xml @@ -10,31 +10,31 @@ - - + + - - - - + + + + - + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_joined_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_joined_plan__ep_0.xml index 99c2c23a43..e224019fce 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_joined_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_joined_plan__ep_0.xml @@ -10,7 +10,7 @@ - + @@ -24,11 +24,11 @@ - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_multihop_joined_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_multihop_joined_plan__ep_0.xml index ab375ac0d1..c5d17a25a0 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_multihop_joined_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_multihop_joined_plan__ep_0.xml @@ -10,31 +10,31 @@ - - + + - - - - + + + + - + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/DuckDB/test_joined_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/DuckDB/test_joined_plan__ep_0.xml index 99c2c23a43..e224019fce 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/DuckDB/test_joined_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/DuckDB/test_joined_plan__ep_0.xml @@ -10,7 +10,7 @@ - + @@ -24,11 +24,11 @@ - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/DuckDB/test_multihop_joined_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/DuckDB/test_multihop_joined_plan__ep_0.xml index ab375ac0d1..c5d17a25a0 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/DuckDB/test_multihop_joined_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/DuckDB/test_multihop_joined_plan__ep_0.xml @@ -10,31 +10,31 @@ - - + + - - - - + + + + - + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_joined_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_joined_plan__ep_0.xml index 99c2c23a43..e224019fce 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_joined_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_joined_plan__ep_0.xml @@ -10,7 +10,7 @@ - + @@ -24,11 +24,11 @@ - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_multihop_joined_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_multihop_joined_plan__ep_0.xml index ab375ac0d1..c5d17a25a0 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_multihop_joined_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_multihop_joined_plan__ep_0.xml @@ -10,31 +10,31 @@ - - + + - - - - + + + + - + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_joined_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_joined_plan__ep_0.xml index 99c2c23a43..e224019fce 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_joined_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_joined_plan__ep_0.xml @@ -10,7 +10,7 @@ - + @@ -24,11 +24,11 @@ - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_multihop_joined_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_multihop_joined_plan__ep_0.xml index ab375ac0d1..c5d17a25a0 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_multihop_joined_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_multihop_joined_plan__ep_0.xml @@ -10,31 +10,31 @@ - - + + - - - - + + + + - + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_joined_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_joined_plan__ep_0.xml index 99c2c23a43..e224019fce 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_joined_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_joined_plan__ep_0.xml @@ -10,7 +10,7 @@ - + @@ -24,11 +24,11 @@ - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_multihop_joined_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_multihop_joined_plan__ep_0.xml index ab375ac0d1..c5d17a25a0 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_multihop_joined_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_multihop_joined_plan__ep_0.xml @@ -10,31 +10,31 @@ - - + + - - - - + + + + - + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/DataflowPlan/test_compute_metrics_node_simple_expr__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/DataflowPlan/test_compute_metrics_node_simple_expr__plan0.xml index 1281c43f7b..6c1b6b607c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/DataflowPlan/test_compute_metrics_node_simple_expr__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/DataflowPlan/test_compute_metrics_node_simple_expr__plan0.xml @@ -60,7 +60,7 @@ - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node__plan0.sql index 64f68f8924..173ec5067e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node__plan0.sql @@ -125,62 +125,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_2 ) subq_3 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node__plan0_optimized.sql index 19bdffaa82..39399152fe 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node__plan0_optimized.sql @@ -3,7 +3,7 @@ -- Compute Metrics via Expressions SELECT subq_7.listing AS listing - , listings_latest_src_10004.country AS listing__country_latest + , listings_latest_src_10005.country AS listing__country_latest , SUM(subq_7.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -15,9 +15,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_7 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_7.listing = listings_latest_src_10004.listing_id + subq_7.listing = listings_latest_src_10005.listing_id GROUP BY listing , listing__country_latest diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql index 76675b4f55..5ba27edb24 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql @@ -319,62 +319,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_3 ) subq_4 ) subq_5 @@ -487,55 +487,55 @@ FROM ( -- Read Elements From Semantic Model 'views_source' SELECT 1 AS views - , DATE_TRUNC(views_source_src_10009.ds, day) AS ds__day - , DATE_TRUNC(views_source_src_10009.ds, isoweek) AS ds__week - , DATE_TRUNC(views_source_src_10009.ds, month) AS ds__month - , DATE_TRUNC(views_source_src_10009.ds, quarter) AS ds__quarter - , DATE_TRUNC(views_source_src_10009.ds, year) AS ds__year - , EXTRACT(year FROM views_source_src_10009.ds) AS ds__extract_year - , EXTRACT(quarter FROM views_source_src_10009.ds) AS ds__extract_quarter - , EXTRACT(month FROM views_source_src_10009.ds) AS ds__extract_month - , EXTRACT(day FROM views_source_src_10009.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM views_source_src_10009.ds) = 1, 7, EXTRACT(dayofweek FROM views_source_src_10009.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM views_source_src_10009.ds) AS ds__extract_doy - , DATE_TRUNC(views_source_src_10009.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(views_source_src_10009.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(views_source_src_10009.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(views_source_src_10009.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(views_source_src_10009.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM views_source_src_10009.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM views_source_src_10009.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(views_source_src_10009.ds, day) AS view__ds__day - , DATE_TRUNC(views_source_src_10009.ds, isoweek) AS view__ds__week - , DATE_TRUNC(views_source_src_10009.ds, month) AS view__ds__month - , DATE_TRUNC(views_source_src_10009.ds, quarter) AS view__ds__quarter - , DATE_TRUNC(views_source_src_10009.ds, year) AS view__ds__year - , EXTRACT(year FROM views_source_src_10009.ds) AS view__ds__extract_year - , EXTRACT(quarter FROM views_source_src_10009.ds) AS view__ds__extract_quarter - , EXTRACT(month FROM views_source_src_10009.ds) AS view__ds__extract_month - , EXTRACT(day FROM views_source_src_10009.ds) AS view__ds__extract_day - , IF(EXTRACT(dayofweek FROM views_source_src_10009.ds) = 1, 7, EXTRACT(dayofweek FROM views_source_src_10009.ds) - 1) AS view__ds__extract_dow - , EXTRACT(dayofyear FROM views_source_src_10009.ds) AS view__ds__extract_doy - , DATE_TRUNC(views_source_src_10009.ds_partitioned, day) AS view__ds_partitioned__day - , DATE_TRUNC(views_source_src_10009.ds_partitioned, isoweek) AS view__ds_partitioned__week - , DATE_TRUNC(views_source_src_10009.ds_partitioned, month) AS view__ds_partitioned__month - , DATE_TRUNC(views_source_src_10009.ds_partitioned, quarter) AS view__ds_partitioned__quarter - , DATE_TRUNC(views_source_src_10009.ds_partitioned, year) AS view__ds_partitioned__year - , EXTRACT(year FROM views_source_src_10009.ds_partitioned) AS view__ds_partitioned__extract_year - , EXTRACT(quarter FROM views_source_src_10009.ds_partitioned) AS view__ds_partitioned__extract_quarter - , EXTRACT(month FROM views_source_src_10009.ds_partitioned) AS view__ds_partitioned__extract_month - , EXTRACT(day FROM views_source_src_10009.ds_partitioned) AS view__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM views_source_src_10009.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM views_source_src_10009.ds_partitioned) - 1) AS view__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM views_source_src_10009.ds_partitioned) AS view__ds_partitioned__extract_doy - , views_source_src_10009.listing_id AS listing - , views_source_src_10009.user_id AS user - , views_source_src_10009.listing_id AS view__listing - , views_source_src_10009.user_id AS view__user - FROM ***************************.fct_views views_source_src_10009 + , DATE_TRUNC(views_source_src_10010.ds, day) AS ds__day + , DATE_TRUNC(views_source_src_10010.ds, isoweek) AS ds__week + , DATE_TRUNC(views_source_src_10010.ds, month) AS ds__month + , DATE_TRUNC(views_source_src_10010.ds, quarter) AS ds__quarter + , DATE_TRUNC(views_source_src_10010.ds, year) AS ds__year + , EXTRACT(year FROM views_source_src_10010.ds) AS ds__extract_year + , EXTRACT(quarter FROM views_source_src_10010.ds) AS ds__extract_quarter + , EXTRACT(month FROM views_source_src_10010.ds) AS ds__extract_month + , EXTRACT(day FROM views_source_src_10010.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM views_source_src_10010.ds) = 1, 7, EXTRACT(dayofweek FROM views_source_src_10010.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM views_source_src_10010.ds) AS ds__extract_doy + , DATE_TRUNC(views_source_src_10010.ds_partitioned, day) AS ds_partitioned__day + , DATE_TRUNC(views_source_src_10010.ds_partitioned, isoweek) AS ds_partitioned__week + , DATE_TRUNC(views_source_src_10010.ds_partitioned, month) AS ds_partitioned__month + , DATE_TRUNC(views_source_src_10010.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATE_TRUNC(views_source_src_10010.ds_partitioned, year) AS ds_partitioned__year + , EXTRACT(year FROM views_source_src_10010.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM views_source_src_10010.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM views_source_src_10010.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM views_source_src_10010.ds_partitioned) AS ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM views_source_src_10010.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM views_source_src_10010.ds_partitioned) - 1) AS ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM views_source_src_10010.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC(views_source_src_10010.ds, day) AS view__ds__day + , DATE_TRUNC(views_source_src_10010.ds, isoweek) AS view__ds__week + , DATE_TRUNC(views_source_src_10010.ds, month) AS view__ds__month + , DATE_TRUNC(views_source_src_10010.ds, quarter) AS view__ds__quarter + , DATE_TRUNC(views_source_src_10010.ds, year) AS view__ds__year + , EXTRACT(year FROM views_source_src_10010.ds) AS view__ds__extract_year + , EXTRACT(quarter FROM views_source_src_10010.ds) AS view__ds__extract_quarter + , EXTRACT(month FROM views_source_src_10010.ds) AS view__ds__extract_month + , EXTRACT(day FROM views_source_src_10010.ds) AS view__ds__extract_day + , IF(EXTRACT(dayofweek FROM views_source_src_10010.ds) = 1, 7, EXTRACT(dayofweek FROM views_source_src_10010.ds) - 1) AS view__ds__extract_dow + , EXTRACT(dayofyear FROM views_source_src_10010.ds) AS view__ds__extract_doy + , DATE_TRUNC(views_source_src_10010.ds_partitioned, day) AS view__ds_partitioned__day + , DATE_TRUNC(views_source_src_10010.ds_partitioned, isoweek) AS view__ds_partitioned__week + , DATE_TRUNC(views_source_src_10010.ds_partitioned, month) AS view__ds_partitioned__month + , DATE_TRUNC(views_source_src_10010.ds_partitioned, quarter) AS view__ds_partitioned__quarter + , DATE_TRUNC(views_source_src_10010.ds_partitioned, year) AS view__ds_partitioned__year + , EXTRACT(year FROM views_source_src_10010.ds_partitioned) AS view__ds_partitioned__extract_year + , EXTRACT(quarter FROM views_source_src_10010.ds_partitioned) AS view__ds_partitioned__extract_quarter + , EXTRACT(month FROM views_source_src_10010.ds_partitioned) AS view__ds_partitioned__extract_month + , EXTRACT(day FROM views_source_src_10010.ds_partitioned) AS view__ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM views_source_src_10010.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM views_source_src_10010.ds_partitioned) - 1) AS view__ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM views_source_src_10010.ds_partitioned) AS view__ds_partitioned__extract_doy + , views_source_src_10010.listing_id AS listing + , views_source_src_10010.user_id AS user + , views_source_src_10010.listing_id AS view__listing + , views_source_src_10010.user_id AS view__user + FROM ***************************.fct_views views_source_src_10010 ) subq_10 ) subq_11 ) subq_12 @@ -619,62 +619,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_13 ) subq_14 ) subq_15 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql index c7350f6401..7b521a57b4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql @@ -18,7 +18,7 @@ FROM ( -- Compute Metrics via Expressions SELECT subq_23.ds__day AS ds__day - , listings_latest_src_10004.country AS listing__country_latest + , listings_latest_src_10005.country AS listing__country_latest , SUM(subq_23.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -32,9 +32,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_23 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_23.listing = listings_latest_src_10004.listing_id + subq_23.listing = listings_latest_src_10005.listing_id GROUP BY ds__day , listing__country_latest @@ -47,7 +47,7 @@ FROM ( -- Compute Metrics via Expressions SELECT subq_33.ds__day AS ds__day - , listings_latest_src_10004.country AS listing__country_latest + , listings_latest_src_10005.country AS listing__country_latest , SUM(subq_33.views) AS views FROM ( -- Read Elements From Semantic Model 'views_source' @@ -58,12 +58,12 @@ FROM ( DATE_TRUNC(ds, day) AS ds__day , listing_id AS listing , 1 AS views - FROM ***************************.fct_views views_source_src_10009 + FROM ***************************.fct_views views_source_src_10010 ) subq_33 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_33.listing = listings_latest_src_10004.listing_id + subq_33.listing = listings_latest_src_10005.listing_id GROUP BY ds__day , listing__country_latest diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql index d64a637c21..00bfec8ed3 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql @@ -128,62 +128,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_2 ) subq_3 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql index 0eb54f3dd6..e02fd7055e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql @@ -8,7 +8,7 @@ FROM ( -- Aggregate Measures SELECT subq_7.listing AS listing - , listings_latest_src_10004.country AS listing__country_latest + , listings_latest_src_10005.country AS listing__country_latest , SUM(subq_7.bookings) AS bookings , COUNT(DISTINCT subq_7.bookers) AS bookers FROM ( @@ -22,9 +22,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_7 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_7.listing = listings_latest_src_10004.listing_id + subq_7.listing = listings_latest_src_10005.listing_id GROUP BY listing , listing__country_latest diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_simple_expr__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_simple_expr__plan0.sql index 659363e294..455c86dc0a 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_simple_expr__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_simple_expr__plan0.sql @@ -125,62 +125,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_2 ) subq_3 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_simple_expr__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_simple_expr__plan0_optimized.sql index 92beb90978..f1638ec98c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_simple_expr__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_simple_expr__plan0_optimized.sql @@ -8,13 +8,13 @@ FROM ( -- Aggregate Measures SELECT bookings_source_src_10001.listing_id AS listing - , listings_latest_src_10004.country AS listing__country_latest + , listings_latest_src_10005.country AS listing__country_latest , SUM(bookings_source_src_10001.booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - bookings_source_src_10001.listing_id = listings_latest_src_10004.listing_id + bookings_source_src_10001.listing_id = listings_latest_src_10005.listing_id GROUP BY listing , listing__country_latest diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimension_with_joined_where_constraint__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimension_with_joined_where_constraint__plan0.sql index f5bebeea26..9bdc72909f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimension_with_joined_where_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimension_with_joined_where_constraint__plan0.sql @@ -126,62 +126,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: @@ -192,32 +192,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC(users_latest_src_10008.ds, day) AS ds_latest__day - , DATE_TRUNC(users_latest_src_10008.ds, isoweek) AS ds_latest__week - , DATE_TRUNC(users_latest_src_10008.ds, month) AS ds_latest__month - , DATE_TRUNC(users_latest_src_10008.ds, quarter) AS ds_latest__quarter - , DATE_TRUNC(users_latest_src_10008.ds, year) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS ds_latest__extract_day - , IF(EXTRACT(dayofweek FROM users_latest_src_10008.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_10008.ds) - 1) AS ds_latest__extract_dow - , EXTRACT(dayofyear FROM users_latest_src_10008.ds) AS ds_latest__extract_doy - , users_latest_src_10008.home_state_latest - , DATE_TRUNC(users_latest_src_10008.ds, day) AS user__ds_latest__day - , DATE_TRUNC(users_latest_src_10008.ds, isoweek) AS user__ds_latest__week - , DATE_TRUNC(users_latest_src_10008.ds, month) AS user__ds_latest__month - , DATE_TRUNC(users_latest_src_10008.ds, quarter) AS user__ds_latest__quarter - , DATE_TRUNC(users_latest_src_10008.ds, year) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS user__ds_latest__extract_day - , IF(EXTRACT(dayofweek FROM users_latest_src_10008.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_10008.ds) - 1) AS user__ds_latest__extract_dow - , EXTRACT(dayofyear FROM users_latest_src_10008.ds) AS user__ds_latest__extract_doy - , users_latest_src_10008.home_state_latest AS user__home_state_latest - , users_latest_src_10008.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_10008 + DATE_TRUNC(users_latest_src_10009.ds, day) AS ds_latest__day + , DATE_TRUNC(users_latest_src_10009.ds, isoweek) AS ds_latest__week + , DATE_TRUNC(users_latest_src_10009.ds, month) AS ds_latest__month + , DATE_TRUNC(users_latest_src_10009.ds, quarter) AS ds_latest__quarter + , DATE_TRUNC(users_latest_src_10009.ds, year) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS ds_latest__extract_day + , IF(EXTRACT(dayofweek FROM users_latest_src_10009.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_10009.ds) - 1) AS ds_latest__extract_dow + , EXTRACT(dayofyear FROM users_latest_src_10009.ds) AS ds_latest__extract_doy + , users_latest_src_10009.home_state_latest + , DATE_TRUNC(users_latest_src_10009.ds, day) AS user__ds_latest__day + , DATE_TRUNC(users_latest_src_10009.ds, isoweek) AS user__ds_latest__week + , DATE_TRUNC(users_latest_src_10009.ds, month) AS user__ds_latest__month + , DATE_TRUNC(users_latest_src_10009.ds, quarter) AS user__ds_latest__quarter + , DATE_TRUNC(users_latest_src_10009.ds, year) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS user__ds_latest__extract_day + , IF(EXTRACT(dayofweek FROM users_latest_src_10009.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_10009.ds) - 1) AS user__ds_latest__extract_dow + , EXTRACT(dayofyear FROM users_latest_src_10009.ds) AS user__ds_latest__extract_doy + , users_latest_src_10009.home_state_latest AS user__home_state_latest + , users_latest_src_10009.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_10009 ) subq_1 ) subq_2 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimension_with_joined_where_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimension_with_joined_where_constraint__plan0_optimized.sql index 28fb7a0251..bbb933bac0 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimension_with_joined_where_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimension_with_joined_where_constraint__plan0_optimized.sql @@ -6,13 +6,13 @@ SELECT FROM ( -- Join Standard Outputs SELECT - listings_latest_src_10004.country AS listing__country_latest - , users_latest_src_10008.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings_latest listings_latest_src_10004 + listings_latest_src_10005.country AS listing__country_latest + , users_latest_src_10009.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings_latest listings_latest_src_10005 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_10008 + ***************************.dim_users_latest users_latest_src_10009 ON - listings_latest_src_10004.user_id = users_latest_src_10008.user_id + listings_latest_src_10005.user_id = users_latest_src_10009.user_id ) subq_8 WHERE listing__country_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimensions_requiring_join__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimensions_requiring_join__plan0.sql index 20ea6ad5b2..b06d4edf2e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimensions_requiring_join__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimensions_requiring_join__plan0.sql @@ -67,62 +67,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: @@ -133,32 +133,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC(users_latest_src_10008.ds, day) AS ds_latest__day - , DATE_TRUNC(users_latest_src_10008.ds, isoweek) AS ds_latest__week - , DATE_TRUNC(users_latest_src_10008.ds, month) AS ds_latest__month - , DATE_TRUNC(users_latest_src_10008.ds, quarter) AS ds_latest__quarter - , DATE_TRUNC(users_latest_src_10008.ds, year) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS ds_latest__extract_day - , IF(EXTRACT(dayofweek FROM users_latest_src_10008.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_10008.ds) - 1) AS ds_latest__extract_dow - , EXTRACT(dayofyear FROM users_latest_src_10008.ds) AS ds_latest__extract_doy - , users_latest_src_10008.home_state_latest - , DATE_TRUNC(users_latest_src_10008.ds, day) AS user__ds_latest__day - , DATE_TRUNC(users_latest_src_10008.ds, isoweek) AS user__ds_latest__week - , DATE_TRUNC(users_latest_src_10008.ds, month) AS user__ds_latest__month - , DATE_TRUNC(users_latest_src_10008.ds, quarter) AS user__ds_latest__quarter - , DATE_TRUNC(users_latest_src_10008.ds, year) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS user__ds_latest__extract_day - , IF(EXTRACT(dayofweek FROM users_latest_src_10008.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_10008.ds) - 1) AS user__ds_latest__extract_dow - , EXTRACT(dayofyear FROM users_latest_src_10008.ds) AS user__ds_latest__extract_doy - , users_latest_src_10008.home_state_latest AS user__home_state_latest - , users_latest_src_10008.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_10008 + DATE_TRUNC(users_latest_src_10009.ds, day) AS ds_latest__day + , DATE_TRUNC(users_latest_src_10009.ds, isoweek) AS ds_latest__week + , DATE_TRUNC(users_latest_src_10009.ds, month) AS ds_latest__month + , DATE_TRUNC(users_latest_src_10009.ds, quarter) AS ds_latest__quarter + , DATE_TRUNC(users_latest_src_10009.ds, year) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS ds_latest__extract_day + , IF(EXTRACT(dayofweek FROM users_latest_src_10009.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_10009.ds) - 1) AS ds_latest__extract_dow + , EXTRACT(dayofyear FROM users_latest_src_10009.ds) AS ds_latest__extract_doy + , users_latest_src_10009.home_state_latest + , DATE_TRUNC(users_latest_src_10009.ds, day) AS user__ds_latest__day + , DATE_TRUNC(users_latest_src_10009.ds, isoweek) AS user__ds_latest__week + , DATE_TRUNC(users_latest_src_10009.ds, month) AS user__ds_latest__month + , DATE_TRUNC(users_latest_src_10009.ds, quarter) AS user__ds_latest__quarter + , DATE_TRUNC(users_latest_src_10009.ds, year) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS user__ds_latest__extract_day + , IF(EXTRACT(dayofweek FROM users_latest_src_10009.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_10009.ds) - 1) AS user__ds_latest__extract_dow + , EXTRACT(dayofyear FROM users_latest_src_10009.ds) AS user__ds_latest__extract_doy + , users_latest_src_10009.home_state_latest AS user__home_state_latest + , users_latest_src_10009.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_10009 ) subq_1 ) subq_2 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimensions_requiring_join__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimensions_requiring_join__plan0_optimized.sql index 0d442e4a0f..52bb1235c2 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimensions_requiring_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimensions_requiring_join__plan0_optimized.sql @@ -2,13 +2,13 @@ -- Pass Only Elements: -- ['user__home_state_latest', 'listing__is_lux_latest'] SELECT - listings_latest_src_10004.is_lux AS listing__is_lux_latest - , users_latest_src_10008.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_10004 + listings_latest_src_10005.is_lux AS listing__is_lux_latest + , users_latest_src_10009.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_10005 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_10008 + ***************************.dim_users_latest users_latest_src_10009 ON - listings_latest_src_10004.user_id = users_latest_src_10008.user_id + listings_latest_src_10005.user_id = users_latest_src_10009.user_id GROUP BY listing__is_lux_latest , user__home_state_latest diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multi_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multi_join_node__plan0.sql index 6c1bbda280..058edfef06 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multi_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multi_join_node__plan0.sql @@ -114,62 +114,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_2 ) subq_3 ON @@ -184,62 +184,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_4 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multi_join_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multi_join_node__plan0_optimized.sql index 8180d208b3..ddfc1d9706 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multi_join_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multi_join_node__plan0_optimized.sql @@ -20,7 +20,7 @@ LEFT OUTER JOIN ( SELECT listing_id AS listing , country AS country_latest - FROM ***************************.dim_listings_latest listings_latest_src_10004 + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_9 ON subq_7.listing = subq_9.listing @@ -31,7 +31,7 @@ LEFT OUTER JOIN ( SELECT listing_id AS listing , country AS country_latest - FROM ***************************.dim_listings_latest listings_latest_src_10004 + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_11 ON subq_7.listing = subq_11.listing diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_single_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_single_join_node__plan0.sql index d90e563318..4a85720c46 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_single_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_single_join_node__plan0.sql @@ -112,62 +112,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_2 ) subq_3 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_single_join_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_single_join_node__plan0_optimized.sql index 480a2c9f56..9202940446 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_single_join_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_single_join_node__plan0_optimized.sql @@ -12,6 +12,6 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_5 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_5.listing = listings_latest_src_10004.listing_id + subq_5.listing = listings_latest_src_10005.listing_id diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node__plan0.sql index 379c4ecb15..14df912c02 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node__plan0.sql @@ -125,62 +125,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_2 ) subq_3 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node__plan0_optimized.sql index 7a53d1c84e..9e5210f489 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node__plan0_optimized.sql @@ -3,7 +3,7 @@ -- Compute Metrics via Expressions SELECT subq_7.listing AS listing - , listings_latest_src_10004.country AS listing__country_latest + , listings_latest_src_10005.country AS listing__country_latest , SUM(subq_7.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -15,9 +15,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_7 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_7.listing = listings_latest_src_10004.listing_id + subq_7.listing = listings_latest_src_10005.listing_id GROUP BY subq_7.listing - , listings_latest_src_10004.country + , listings_latest_src_10005.country diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql index d2342c5daa..a01915f83f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql @@ -319,62 +319,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_3 ) subq_4 ) subq_5 @@ -487,55 +487,55 @@ FROM ( -- Read Elements From Semantic Model 'views_source' SELECT 1 AS views - , DATE_TRUNC('day', views_source_src_10009.ds) AS ds__day - , DATE_TRUNC('week', views_source_src_10009.ds) AS ds__week - , DATE_TRUNC('month', views_source_src_10009.ds) AS ds__month - , DATE_TRUNC('quarter', views_source_src_10009.ds) AS ds__quarter - , DATE_TRUNC('year', views_source_src_10009.ds) AS ds__year - , EXTRACT(year FROM views_source_src_10009.ds) AS ds__extract_year - , EXTRACT(quarter FROM views_source_src_10009.ds) AS ds__extract_quarter - , EXTRACT(month FROM views_source_src_10009.ds) AS ds__extract_month - , EXTRACT(day FROM views_source_src_10009.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM views_source_src_10009.ds) AS ds__extract_dow - , EXTRACT(doy FROM views_source_src_10009.ds) AS ds__extract_doy - , DATE_TRUNC('day', views_source_src_10009.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', views_source_src_10009.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', views_source_src_10009.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', views_source_src_10009.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', views_source_src_10009.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', views_source_src_10009.ds) AS view__ds__day - , DATE_TRUNC('week', views_source_src_10009.ds) AS view__ds__week - , DATE_TRUNC('month', views_source_src_10009.ds) AS view__ds__month - , DATE_TRUNC('quarter', views_source_src_10009.ds) AS view__ds__quarter - , DATE_TRUNC('year', views_source_src_10009.ds) AS view__ds__year - , EXTRACT(year FROM views_source_src_10009.ds) AS view__ds__extract_year - , EXTRACT(quarter FROM views_source_src_10009.ds) AS view__ds__extract_quarter - , EXTRACT(month FROM views_source_src_10009.ds) AS view__ds__extract_month - , EXTRACT(day FROM views_source_src_10009.ds) AS view__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM views_source_src_10009.ds) AS view__ds__extract_dow - , EXTRACT(doy FROM views_source_src_10009.ds) AS view__ds__extract_doy - , DATE_TRUNC('day', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__day - , DATE_TRUNC('week', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__week - , DATE_TRUNC('month', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__month - , DATE_TRUNC('quarter', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__quarter - , DATE_TRUNC('year', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__year - , EXTRACT(year FROM views_source_src_10009.ds_partitioned) AS view__ds_partitioned__extract_year - , EXTRACT(quarter FROM views_source_src_10009.ds_partitioned) AS view__ds_partitioned__extract_quarter - , EXTRACT(month FROM views_source_src_10009.ds_partitioned) AS view__ds_partitioned__extract_month - , EXTRACT(day FROM views_source_src_10009.ds_partitioned) AS view__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM views_source_src_10009.ds_partitioned) AS view__ds_partitioned__extract_dow - , EXTRACT(doy FROM views_source_src_10009.ds_partitioned) AS view__ds_partitioned__extract_doy - , views_source_src_10009.listing_id AS listing - , views_source_src_10009.user_id AS user - , views_source_src_10009.listing_id AS view__listing - , views_source_src_10009.user_id AS view__user - FROM ***************************.fct_views views_source_src_10009 + , DATE_TRUNC('day', views_source_src_10010.ds) AS ds__day + , DATE_TRUNC('week', views_source_src_10010.ds) AS ds__week + , DATE_TRUNC('month', views_source_src_10010.ds) AS ds__month + , DATE_TRUNC('quarter', views_source_src_10010.ds) AS ds__quarter + , DATE_TRUNC('year', views_source_src_10010.ds) AS ds__year + , EXTRACT(year FROM views_source_src_10010.ds) AS ds__extract_year + , EXTRACT(quarter FROM views_source_src_10010.ds) AS ds__extract_quarter + , EXTRACT(month FROM views_source_src_10010.ds) AS ds__extract_month + , EXTRACT(day FROM views_source_src_10010.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM views_source_src_10010.ds) AS ds__extract_dow + , EXTRACT(doy FROM views_source_src_10010.ds) AS ds__extract_doy + , DATE_TRUNC('day', views_source_src_10010.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', views_source_src_10010.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', views_source_src_10010.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', views_source_src_10010.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', views_source_src_10010.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM views_source_src_10010.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM views_source_src_10010.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM views_source_src_10010.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM views_source_src_10010.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM views_source_src_10010.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM views_source_src_10010.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', views_source_src_10010.ds) AS view__ds__day + , DATE_TRUNC('week', views_source_src_10010.ds) AS view__ds__week + , DATE_TRUNC('month', views_source_src_10010.ds) AS view__ds__month + , DATE_TRUNC('quarter', views_source_src_10010.ds) AS view__ds__quarter + , DATE_TRUNC('year', views_source_src_10010.ds) AS view__ds__year + , EXTRACT(year FROM views_source_src_10010.ds) AS view__ds__extract_year + , EXTRACT(quarter FROM views_source_src_10010.ds) AS view__ds__extract_quarter + , EXTRACT(month FROM views_source_src_10010.ds) AS view__ds__extract_month + , EXTRACT(day FROM views_source_src_10010.ds) AS view__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM views_source_src_10010.ds) AS view__ds__extract_dow + , EXTRACT(doy FROM views_source_src_10010.ds) AS view__ds__extract_doy + , DATE_TRUNC('day', views_source_src_10010.ds_partitioned) AS view__ds_partitioned__day + , DATE_TRUNC('week', views_source_src_10010.ds_partitioned) AS view__ds_partitioned__week + , DATE_TRUNC('month', views_source_src_10010.ds_partitioned) AS view__ds_partitioned__month + , DATE_TRUNC('quarter', views_source_src_10010.ds_partitioned) AS view__ds_partitioned__quarter + , DATE_TRUNC('year', views_source_src_10010.ds_partitioned) AS view__ds_partitioned__year + , EXTRACT(year FROM views_source_src_10010.ds_partitioned) AS view__ds_partitioned__extract_year + , EXTRACT(quarter FROM views_source_src_10010.ds_partitioned) AS view__ds_partitioned__extract_quarter + , EXTRACT(month FROM views_source_src_10010.ds_partitioned) AS view__ds_partitioned__extract_month + , EXTRACT(day FROM views_source_src_10010.ds_partitioned) AS view__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM views_source_src_10010.ds_partitioned) AS view__ds_partitioned__extract_dow + , EXTRACT(doy FROM views_source_src_10010.ds_partitioned) AS view__ds_partitioned__extract_doy + , views_source_src_10010.listing_id AS listing + , views_source_src_10010.user_id AS user + , views_source_src_10010.listing_id AS view__listing + , views_source_src_10010.user_id AS view__user + FROM ***************************.fct_views views_source_src_10010 ) subq_10 ) subq_11 ) subq_12 @@ -619,62 +619,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_13 ) subq_14 ) subq_15 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql index 635bfacdef..ee6adb1fd6 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql @@ -18,7 +18,7 @@ FROM ( -- Compute Metrics via Expressions SELECT subq_23.ds__day AS ds__day - , listings_latest_src_10004.country AS listing__country_latest + , listings_latest_src_10005.country AS listing__country_latest , SUM(subq_23.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -32,12 +32,12 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_23 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_23.listing = listings_latest_src_10004.listing_id + subq_23.listing = listings_latest_src_10005.listing_id GROUP BY subq_23.ds__day - , listings_latest_src_10004.country + , listings_latest_src_10005.country ) subq_30 FULL OUTER JOIN ( -- Join Standard Outputs @@ -47,7 +47,7 @@ FROM ( -- Compute Metrics via Expressions SELECT subq_33.ds__day AS ds__day - , listings_latest_src_10004.country AS listing__country_latest + , listings_latest_src_10005.country AS listing__country_latest , SUM(subq_33.views) AS views FROM ( -- Read Elements From Semantic Model 'views_source' @@ -58,15 +58,15 @@ FROM ( DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS views - FROM ***************************.fct_views views_source_src_10009 + FROM ***************************.fct_views views_source_src_10010 ) subq_33 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_33.listing = listings_latest_src_10004.listing_id + subq_33.listing = listings_latest_src_10005.listing_id GROUP BY subq_33.ds__day - , listings_latest_src_10004.country + , listings_latest_src_10005.country ) subq_40 ON ( diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql index 36354019e7..b325b9e128 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql @@ -128,62 +128,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_2 ) subq_3 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql index f22bdaf7cb..0bfa1bff7f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql @@ -8,7 +8,7 @@ FROM ( -- Aggregate Measures SELECT subq_7.listing AS listing - , listings_latest_src_10004.country AS listing__country_latest + , listings_latest_src_10005.country AS listing__country_latest , SUM(subq_7.bookings) AS bookings , COUNT(DISTINCT subq_7.bookers) AS bookers FROM ( @@ -22,10 +22,10 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_7 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_7.listing = listings_latest_src_10004.listing_id + subq_7.listing = listings_latest_src_10005.listing_id GROUP BY subq_7.listing - , listings_latest_src_10004.country + , listings_latest_src_10005.country ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_simple_expr__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_simple_expr__plan0.sql index 849d6bdd73..98fe7c09b1 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_simple_expr__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_simple_expr__plan0.sql @@ -125,62 +125,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_2 ) subq_3 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_simple_expr__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_simple_expr__plan0_optimized.sql index caa4c0c6fe..5a844f2632 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_simple_expr__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_simple_expr__plan0_optimized.sql @@ -8,14 +8,14 @@ FROM ( -- Aggregate Measures SELECT bookings_source_src_10001.listing_id AS listing - , listings_latest_src_10004.country AS listing__country_latest + , listings_latest_src_10005.country AS listing__country_latest , SUM(bookings_source_src_10001.booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - bookings_source_src_10001.listing_id = listings_latest_src_10004.listing_id + bookings_source_src_10001.listing_id = listings_latest_src_10005.listing_id GROUP BY bookings_source_src_10001.listing_id - , listings_latest_src_10004.country + , listings_latest_src_10005.country ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimension_with_joined_where_constraint__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimension_with_joined_where_constraint__plan0.sql index fadeff3324..7bdbee3c37 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimension_with_joined_where_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimension_with_joined_where_constraint__plan0.sql @@ -126,62 +126,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: @@ -192,32 +192,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_10008.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS ds_latest__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_10008.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS ds_latest__extract_doy - , users_latest_src_10008.home_state_latest - , DATE_TRUNC('day', users_latest_src_10008.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS user__ds_latest__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_10008.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS user__ds_latest__extract_doy - , users_latest_src_10008.home_state_latest AS user__home_state_latest - , users_latest_src_10008.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_10008 + DATE_TRUNC('day', users_latest_src_10009.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS ds_latest__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_10009.ds) AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS ds_latest__extract_doy + , users_latest_src_10009.home_state_latest + , DATE_TRUNC('day', users_latest_src_10009.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS user__ds_latest__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_10009.ds) AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS user__ds_latest__extract_doy + , users_latest_src_10009.home_state_latest AS user__home_state_latest + , users_latest_src_10009.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_10009 ) subq_1 ) subq_2 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimension_with_joined_where_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimension_with_joined_where_constraint__plan0_optimized.sql index 28fb7a0251..bbb933bac0 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimension_with_joined_where_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimension_with_joined_where_constraint__plan0_optimized.sql @@ -6,13 +6,13 @@ SELECT FROM ( -- Join Standard Outputs SELECT - listings_latest_src_10004.country AS listing__country_latest - , users_latest_src_10008.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings_latest listings_latest_src_10004 + listings_latest_src_10005.country AS listing__country_latest + , users_latest_src_10009.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings_latest listings_latest_src_10005 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_10008 + ***************************.dim_users_latest users_latest_src_10009 ON - listings_latest_src_10004.user_id = users_latest_src_10008.user_id + listings_latest_src_10005.user_id = users_latest_src_10009.user_id ) subq_8 WHERE listing__country_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimensions_requiring_join__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimensions_requiring_join__plan0.sql index 58cf6dadca..8b4db45da4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimensions_requiring_join__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimensions_requiring_join__plan0.sql @@ -67,62 +67,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: @@ -133,32 +133,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_10008.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS ds_latest__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_10008.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS ds_latest__extract_doy - , users_latest_src_10008.home_state_latest - , DATE_TRUNC('day', users_latest_src_10008.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS user__ds_latest__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_10008.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS user__ds_latest__extract_doy - , users_latest_src_10008.home_state_latest AS user__home_state_latest - , users_latest_src_10008.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_10008 + DATE_TRUNC('day', users_latest_src_10009.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS ds_latest__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_10009.ds) AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS ds_latest__extract_doy + , users_latest_src_10009.home_state_latest + , DATE_TRUNC('day', users_latest_src_10009.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS user__ds_latest__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_10009.ds) AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS user__ds_latest__extract_doy + , users_latest_src_10009.home_state_latest AS user__home_state_latest + , users_latest_src_10009.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_10009 ) subq_1 ) subq_2 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimensions_requiring_join__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimensions_requiring_join__plan0_optimized.sql index 4bf3539984..7f093b6070 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimensions_requiring_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimensions_requiring_join__plan0_optimized.sql @@ -2,13 +2,13 @@ -- Pass Only Elements: -- ['user__home_state_latest', 'listing__is_lux_latest'] SELECT - listings_latest_src_10004.is_lux AS listing__is_lux_latest - , users_latest_src_10008.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_10004 + listings_latest_src_10005.is_lux AS listing__is_lux_latest + , users_latest_src_10009.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_10005 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_10008 + ***************************.dim_users_latest users_latest_src_10009 ON - listings_latest_src_10004.user_id = users_latest_src_10008.user_id + listings_latest_src_10005.user_id = users_latest_src_10009.user_id GROUP BY - listings_latest_src_10004.is_lux - , users_latest_src_10008.home_state_latest + listings_latest_src_10005.is_lux + , users_latest_src_10009.home_state_latest diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multi_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multi_join_node__plan0.sql index af21fd2a53..a8cce9d60c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multi_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multi_join_node__plan0.sql @@ -114,62 +114,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_2 ) subq_3 ON @@ -184,62 +184,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_4 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multi_join_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multi_join_node__plan0_optimized.sql index 8180d208b3..ddfc1d9706 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multi_join_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multi_join_node__plan0_optimized.sql @@ -20,7 +20,7 @@ LEFT OUTER JOIN ( SELECT listing_id AS listing , country AS country_latest - FROM ***************************.dim_listings_latest listings_latest_src_10004 + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_9 ON subq_7.listing = subq_9.listing @@ -31,7 +31,7 @@ LEFT OUTER JOIN ( SELECT listing_id AS listing , country AS country_latest - FROM ***************************.dim_listings_latest listings_latest_src_10004 + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_11 ON subq_7.listing = subq_11.listing diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_single_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_single_join_node__plan0.sql index d5769334ab..359fa52752 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_single_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_single_join_node__plan0.sql @@ -112,62 +112,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_2 ) subq_3 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_single_join_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_single_join_node__plan0_optimized.sql index 480a2c9f56..9202940446 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_single_join_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_single_join_node__plan0_optimized.sql @@ -12,6 +12,6 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_5 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_5.listing = listings_latest_src_10004.listing_id + subq_5.listing = listings_latest_src_10005.listing_id diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node__plan0.sql index 8acd57a67f..b46218bd01 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node__plan0.sql @@ -125,62 +125,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_2 ) subq_3 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node__plan0_optimized.sql index 7a53d1c84e..9e5210f489 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node__plan0_optimized.sql @@ -3,7 +3,7 @@ -- Compute Metrics via Expressions SELECT subq_7.listing AS listing - , listings_latest_src_10004.country AS listing__country_latest + , listings_latest_src_10005.country AS listing__country_latest , SUM(subq_7.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -15,9 +15,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_7 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_7.listing = listings_latest_src_10004.listing_id + subq_7.listing = listings_latest_src_10005.listing_id GROUP BY subq_7.listing - , listings_latest_src_10004.country + , listings_latest_src_10005.country diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql index dda45db51d..5cdac9f816 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql @@ -319,62 +319,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_3 ) subq_4 ) subq_5 @@ -487,55 +487,55 @@ FROM ( -- Read Elements From Semantic Model 'views_source' SELECT 1 AS views - , DATE_TRUNC('day', views_source_src_10009.ds) AS ds__day - , DATE_TRUNC('week', views_source_src_10009.ds) AS ds__week - , DATE_TRUNC('month', views_source_src_10009.ds) AS ds__month - , DATE_TRUNC('quarter', views_source_src_10009.ds) AS ds__quarter - , DATE_TRUNC('year', views_source_src_10009.ds) AS ds__year - , EXTRACT(year FROM views_source_src_10009.ds) AS ds__extract_year - , EXTRACT(quarter FROM views_source_src_10009.ds) AS ds__extract_quarter - , EXTRACT(month FROM views_source_src_10009.ds) AS ds__extract_month - , EXTRACT(day FROM views_source_src_10009.ds) AS ds__extract_day - , EXTRACT(isodow FROM views_source_src_10009.ds) AS ds__extract_dow - , EXTRACT(doy FROM views_source_src_10009.ds) AS ds__extract_doy - , DATE_TRUNC('day', views_source_src_10009.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', views_source_src_10009.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', views_source_src_10009.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', views_source_src_10009.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', views_source_src_10009.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', views_source_src_10009.ds) AS view__ds__day - , DATE_TRUNC('week', views_source_src_10009.ds) AS view__ds__week - , DATE_TRUNC('month', views_source_src_10009.ds) AS view__ds__month - , DATE_TRUNC('quarter', views_source_src_10009.ds) AS view__ds__quarter - , DATE_TRUNC('year', views_source_src_10009.ds) AS view__ds__year - , EXTRACT(year FROM views_source_src_10009.ds) AS view__ds__extract_year - , EXTRACT(quarter FROM views_source_src_10009.ds) AS view__ds__extract_quarter - , EXTRACT(month FROM views_source_src_10009.ds) AS view__ds__extract_month - , EXTRACT(day FROM views_source_src_10009.ds) AS view__ds__extract_day - , EXTRACT(isodow FROM views_source_src_10009.ds) AS view__ds__extract_dow - , EXTRACT(doy FROM views_source_src_10009.ds) AS view__ds__extract_doy - , DATE_TRUNC('day', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__day - , DATE_TRUNC('week', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__week - , DATE_TRUNC('month', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__month - , DATE_TRUNC('quarter', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__quarter - , DATE_TRUNC('year', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__year - , EXTRACT(year FROM views_source_src_10009.ds_partitioned) AS view__ds_partitioned__extract_year - , EXTRACT(quarter FROM views_source_src_10009.ds_partitioned) AS view__ds_partitioned__extract_quarter - , EXTRACT(month FROM views_source_src_10009.ds_partitioned) AS view__ds_partitioned__extract_month - , EXTRACT(day FROM views_source_src_10009.ds_partitioned) AS view__ds_partitioned__extract_day - , EXTRACT(isodow FROM views_source_src_10009.ds_partitioned) AS view__ds_partitioned__extract_dow - , EXTRACT(doy FROM views_source_src_10009.ds_partitioned) AS view__ds_partitioned__extract_doy - , views_source_src_10009.listing_id AS listing - , views_source_src_10009.user_id AS user - , views_source_src_10009.listing_id AS view__listing - , views_source_src_10009.user_id AS view__user - FROM ***************************.fct_views views_source_src_10009 + , DATE_TRUNC('day', views_source_src_10010.ds) AS ds__day + , DATE_TRUNC('week', views_source_src_10010.ds) AS ds__week + , DATE_TRUNC('month', views_source_src_10010.ds) AS ds__month + , DATE_TRUNC('quarter', views_source_src_10010.ds) AS ds__quarter + , DATE_TRUNC('year', views_source_src_10010.ds) AS ds__year + , EXTRACT(year FROM views_source_src_10010.ds) AS ds__extract_year + , EXTRACT(quarter FROM views_source_src_10010.ds) AS ds__extract_quarter + , EXTRACT(month FROM views_source_src_10010.ds) AS ds__extract_month + , EXTRACT(day FROM views_source_src_10010.ds) AS ds__extract_day + , EXTRACT(isodow FROM views_source_src_10010.ds) AS ds__extract_dow + , EXTRACT(doy FROM views_source_src_10010.ds) AS ds__extract_doy + , DATE_TRUNC('day', views_source_src_10010.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', views_source_src_10010.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', views_source_src_10010.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', views_source_src_10010.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', views_source_src_10010.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM views_source_src_10010.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM views_source_src_10010.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM views_source_src_10010.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM views_source_src_10010.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM views_source_src_10010.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM views_source_src_10010.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', views_source_src_10010.ds) AS view__ds__day + , DATE_TRUNC('week', views_source_src_10010.ds) AS view__ds__week + , DATE_TRUNC('month', views_source_src_10010.ds) AS view__ds__month + , DATE_TRUNC('quarter', views_source_src_10010.ds) AS view__ds__quarter + , DATE_TRUNC('year', views_source_src_10010.ds) AS view__ds__year + , EXTRACT(year FROM views_source_src_10010.ds) AS view__ds__extract_year + , EXTRACT(quarter FROM views_source_src_10010.ds) AS view__ds__extract_quarter + , EXTRACT(month FROM views_source_src_10010.ds) AS view__ds__extract_month + , EXTRACT(day FROM views_source_src_10010.ds) AS view__ds__extract_day + , EXTRACT(isodow FROM views_source_src_10010.ds) AS view__ds__extract_dow + , EXTRACT(doy FROM views_source_src_10010.ds) AS view__ds__extract_doy + , DATE_TRUNC('day', views_source_src_10010.ds_partitioned) AS view__ds_partitioned__day + , DATE_TRUNC('week', views_source_src_10010.ds_partitioned) AS view__ds_partitioned__week + , DATE_TRUNC('month', views_source_src_10010.ds_partitioned) AS view__ds_partitioned__month + , DATE_TRUNC('quarter', views_source_src_10010.ds_partitioned) AS view__ds_partitioned__quarter + , DATE_TRUNC('year', views_source_src_10010.ds_partitioned) AS view__ds_partitioned__year + , EXTRACT(year FROM views_source_src_10010.ds_partitioned) AS view__ds_partitioned__extract_year + , EXTRACT(quarter FROM views_source_src_10010.ds_partitioned) AS view__ds_partitioned__extract_quarter + , EXTRACT(month FROM views_source_src_10010.ds_partitioned) AS view__ds_partitioned__extract_month + , EXTRACT(day FROM views_source_src_10010.ds_partitioned) AS view__ds_partitioned__extract_day + , EXTRACT(isodow FROM views_source_src_10010.ds_partitioned) AS view__ds_partitioned__extract_dow + , EXTRACT(doy FROM views_source_src_10010.ds_partitioned) AS view__ds_partitioned__extract_doy + , views_source_src_10010.listing_id AS listing + , views_source_src_10010.user_id AS user + , views_source_src_10010.listing_id AS view__listing + , views_source_src_10010.user_id AS view__user + FROM ***************************.fct_views views_source_src_10010 ) subq_10 ) subq_11 ) subq_12 @@ -619,62 +619,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_13 ) subq_14 ) subq_15 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql index 635bfacdef..ee6adb1fd6 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql @@ -18,7 +18,7 @@ FROM ( -- Compute Metrics via Expressions SELECT subq_23.ds__day AS ds__day - , listings_latest_src_10004.country AS listing__country_latest + , listings_latest_src_10005.country AS listing__country_latest , SUM(subq_23.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -32,12 +32,12 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_23 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_23.listing = listings_latest_src_10004.listing_id + subq_23.listing = listings_latest_src_10005.listing_id GROUP BY subq_23.ds__day - , listings_latest_src_10004.country + , listings_latest_src_10005.country ) subq_30 FULL OUTER JOIN ( -- Join Standard Outputs @@ -47,7 +47,7 @@ FROM ( -- Compute Metrics via Expressions SELECT subq_33.ds__day AS ds__day - , listings_latest_src_10004.country AS listing__country_latest + , listings_latest_src_10005.country AS listing__country_latest , SUM(subq_33.views) AS views FROM ( -- Read Elements From Semantic Model 'views_source' @@ -58,15 +58,15 @@ FROM ( DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS views - FROM ***************************.fct_views views_source_src_10009 + FROM ***************************.fct_views views_source_src_10010 ) subq_33 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_33.listing = listings_latest_src_10004.listing_id + subq_33.listing = listings_latest_src_10005.listing_id GROUP BY subq_33.ds__day - , listings_latest_src_10004.country + , listings_latest_src_10005.country ) subq_40 ON ( diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql index 583678d2d6..8c1ec0651c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql @@ -128,62 +128,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_2 ) subq_3 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql index f22bdaf7cb..0bfa1bff7f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql @@ -8,7 +8,7 @@ FROM ( -- Aggregate Measures SELECT subq_7.listing AS listing - , listings_latest_src_10004.country AS listing__country_latest + , listings_latest_src_10005.country AS listing__country_latest , SUM(subq_7.bookings) AS bookings , COUNT(DISTINCT subq_7.bookers) AS bookers FROM ( @@ -22,10 +22,10 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_7 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_7.listing = listings_latest_src_10004.listing_id + subq_7.listing = listings_latest_src_10005.listing_id GROUP BY subq_7.listing - , listings_latest_src_10004.country + , listings_latest_src_10005.country ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_simple_expr__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_simple_expr__plan0.sql index f04f16e5bf..7bbc7fb3b9 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_simple_expr__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_simple_expr__plan0.sql @@ -125,62 +125,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_2 ) subq_3 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_simple_expr__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_simple_expr__plan0_optimized.sql index caa4c0c6fe..5a844f2632 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_simple_expr__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_simple_expr__plan0_optimized.sql @@ -8,14 +8,14 @@ FROM ( -- Aggregate Measures SELECT bookings_source_src_10001.listing_id AS listing - , listings_latest_src_10004.country AS listing__country_latest + , listings_latest_src_10005.country AS listing__country_latest , SUM(bookings_source_src_10001.booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - bookings_source_src_10001.listing_id = listings_latest_src_10004.listing_id + bookings_source_src_10001.listing_id = listings_latest_src_10005.listing_id GROUP BY bookings_source_src_10001.listing_id - , listings_latest_src_10004.country + , listings_latest_src_10005.country ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimension_with_joined_where_constraint__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimension_with_joined_where_constraint__plan0.sql index 111ca3665f..7a9740ce87 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimension_with_joined_where_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimension_with_joined_where_constraint__plan0.sql @@ -126,62 +126,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: @@ -192,32 +192,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_10008.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_10008.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS ds_latest__extract_doy - , users_latest_src_10008.home_state_latest - , DATE_TRUNC('day', users_latest_src_10008.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS user__ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_10008.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS user__ds_latest__extract_doy - , users_latest_src_10008.home_state_latest AS user__home_state_latest - , users_latest_src_10008.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_10008 + DATE_TRUNC('day', users_latest_src_10009.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS ds_latest__extract_day + , EXTRACT(isodow FROM users_latest_src_10009.ds) AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS ds_latest__extract_doy + , users_latest_src_10009.home_state_latest + , DATE_TRUNC('day', users_latest_src_10009.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS user__ds_latest__extract_day + , EXTRACT(isodow FROM users_latest_src_10009.ds) AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS user__ds_latest__extract_doy + , users_latest_src_10009.home_state_latest AS user__home_state_latest + , users_latest_src_10009.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_10009 ) subq_1 ) subq_2 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimension_with_joined_where_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimension_with_joined_where_constraint__plan0_optimized.sql index 28fb7a0251..bbb933bac0 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimension_with_joined_where_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimension_with_joined_where_constraint__plan0_optimized.sql @@ -6,13 +6,13 @@ SELECT FROM ( -- Join Standard Outputs SELECT - listings_latest_src_10004.country AS listing__country_latest - , users_latest_src_10008.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings_latest listings_latest_src_10004 + listings_latest_src_10005.country AS listing__country_latest + , users_latest_src_10009.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings_latest listings_latest_src_10005 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_10008 + ***************************.dim_users_latest users_latest_src_10009 ON - listings_latest_src_10004.user_id = users_latest_src_10008.user_id + listings_latest_src_10005.user_id = users_latest_src_10009.user_id ) subq_8 WHERE listing__country_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimensions_requiring_join__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimensions_requiring_join__plan0.sql index 4ffc0ed119..dd31fb79f8 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimensions_requiring_join__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimensions_requiring_join__plan0.sql @@ -67,62 +67,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: @@ -133,32 +133,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_10008.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_10008.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS ds_latest__extract_doy - , users_latest_src_10008.home_state_latest - , DATE_TRUNC('day', users_latest_src_10008.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS user__ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_10008.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS user__ds_latest__extract_doy - , users_latest_src_10008.home_state_latest AS user__home_state_latest - , users_latest_src_10008.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_10008 + DATE_TRUNC('day', users_latest_src_10009.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS ds_latest__extract_day + , EXTRACT(isodow FROM users_latest_src_10009.ds) AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS ds_latest__extract_doy + , users_latest_src_10009.home_state_latest + , DATE_TRUNC('day', users_latest_src_10009.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS user__ds_latest__extract_day + , EXTRACT(isodow FROM users_latest_src_10009.ds) AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS user__ds_latest__extract_doy + , users_latest_src_10009.home_state_latest AS user__home_state_latest + , users_latest_src_10009.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_10009 ) subq_1 ) subq_2 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimensions_requiring_join__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimensions_requiring_join__plan0_optimized.sql index 4bf3539984..7f093b6070 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimensions_requiring_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimensions_requiring_join__plan0_optimized.sql @@ -2,13 +2,13 @@ -- Pass Only Elements: -- ['user__home_state_latest', 'listing__is_lux_latest'] SELECT - listings_latest_src_10004.is_lux AS listing__is_lux_latest - , users_latest_src_10008.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_10004 + listings_latest_src_10005.is_lux AS listing__is_lux_latest + , users_latest_src_10009.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_10005 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_10008 + ***************************.dim_users_latest users_latest_src_10009 ON - listings_latest_src_10004.user_id = users_latest_src_10008.user_id + listings_latest_src_10005.user_id = users_latest_src_10009.user_id GROUP BY - listings_latest_src_10004.is_lux - , users_latest_src_10008.home_state_latest + listings_latest_src_10005.is_lux + , users_latest_src_10009.home_state_latest diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multi_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multi_join_node__plan0.sql index 5c1795fec6..63e1d67013 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multi_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multi_join_node__plan0.sql @@ -114,62 +114,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_2 ) subq_3 ON @@ -184,62 +184,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_4 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multi_join_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multi_join_node__plan0_optimized.sql index 8180d208b3..ddfc1d9706 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multi_join_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multi_join_node__plan0_optimized.sql @@ -20,7 +20,7 @@ LEFT OUTER JOIN ( SELECT listing_id AS listing , country AS country_latest - FROM ***************************.dim_listings_latest listings_latest_src_10004 + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_9 ON subq_7.listing = subq_9.listing @@ -31,7 +31,7 @@ LEFT OUTER JOIN ( SELECT listing_id AS listing , country AS country_latest - FROM ***************************.dim_listings_latest listings_latest_src_10004 + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_11 ON subq_7.listing = subq_11.listing diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_single_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_single_join_node__plan0.sql index 749b06ce93..ee2699fd60 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_single_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_single_join_node__plan0.sql @@ -112,62 +112,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_2 ) subq_3 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_single_join_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_single_join_node__plan0_optimized.sql index 480a2c9f56..9202940446 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_single_join_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_single_join_node__plan0_optimized.sql @@ -12,6 +12,6 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_5 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_5.listing = listings_latest_src_10004.listing_id + subq_5.listing = listings_latest_src_10005.listing_id diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node__plan0.sql index 8acd57a67f..b46218bd01 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node__plan0.sql @@ -125,62 +125,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_2 ) subq_3 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node__plan0_optimized.sql index 7a53d1c84e..9e5210f489 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node__plan0_optimized.sql @@ -3,7 +3,7 @@ -- Compute Metrics via Expressions SELECT subq_7.listing AS listing - , listings_latest_src_10004.country AS listing__country_latest + , listings_latest_src_10005.country AS listing__country_latest , SUM(subq_7.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -15,9 +15,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_7 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_7.listing = listings_latest_src_10004.listing_id + subq_7.listing = listings_latest_src_10005.listing_id GROUP BY subq_7.listing - , listings_latest_src_10004.country + , listings_latest_src_10005.country diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql index 0bcc2c8877..da83576f65 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql @@ -319,62 +319,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_3 ) subq_4 ) subq_5 @@ -487,55 +487,55 @@ FROM ( -- Read Elements From Semantic Model 'views_source' SELECT 1 AS views - , DATE_TRUNC('day', views_source_src_10009.ds) AS ds__day - , DATE_TRUNC('week', views_source_src_10009.ds) AS ds__week - , DATE_TRUNC('month', views_source_src_10009.ds) AS ds__month - , DATE_TRUNC('quarter', views_source_src_10009.ds) AS ds__quarter - , DATE_TRUNC('year', views_source_src_10009.ds) AS ds__year - , EXTRACT(year FROM views_source_src_10009.ds) AS ds__extract_year - , EXTRACT(quarter FROM views_source_src_10009.ds) AS ds__extract_quarter - , EXTRACT(month FROM views_source_src_10009.ds) AS ds__extract_month - , EXTRACT(day FROM views_source_src_10009.ds) AS ds__extract_day - , EXTRACT(isodow FROM views_source_src_10009.ds) AS ds__extract_dow - , EXTRACT(doy FROM views_source_src_10009.ds) AS ds__extract_doy - , DATE_TRUNC('day', views_source_src_10009.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', views_source_src_10009.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', views_source_src_10009.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', views_source_src_10009.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', views_source_src_10009.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', views_source_src_10009.ds) AS view__ds__day - , DATE_TRUNC('week', views_source_src_10009.ds) AS view__ds__week - , DATE_TRUNC('month', views_source_src_10009.ds) AS view__ds__month - , DATE_TRUNC('quarter', views_source_src_10009.ds) AS view__ds__quarter - , DATE_TRUNC('year', views_source_src_10009.ds) AS view__ds__year - , EXTRACT(year FROM views_source_src_10009.ds) AS view__ds__extract_year - , EXTRACT(quarter FROM views_source_src_10009.ds) AS view__ds__extract_quarter - , EXTRACT(month FROM views_source_src_10009.ds) AS view__ds__extract_month - , EXTRACT(day FROM views_source_src_10009.ds) AS view__ds__extract_day - , EXTRACT(isodow FROM views_source_src_10009.ds) AS view__ds__extract_dow - , EXTRACT(doy FROM views_source_src_10009.ds) AS view__ds__extract_doy - , DATE_TRUNC('day', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__day - , DATE_TRUNC('week', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__week - , DATE_TRUNC('month', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__month - , DATE_TRUNC('quarter', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__quarter - , DATE_TRUNC('year', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__year - , EXTRACT(year FROM views_source_src_10009.ds_partitioned) AS view__ds_partitioned__extract_year - , EXTRACT(quarter FROM views_source_src_10009.ds_partitioned) AS view__ds_partitioned__extract_quarter - , EXTRACT(month FROM views_source_src_10009.ds_partitioned) AS view__ds_partitioned__extract_month - , EXTRACT(day FROM views_source_src_10009.ds_partitioned) AS view__ds_partitioned__extract_day - , EXTRACT(isodow FROM views_source_src_10009.ds_partitioned) AS view__ds_partitioned__extract_dow - , EXTRACT(doy FROM views_source_src_10009.ds_partitioned) AS view__ds_partitioned__extract_doy - , views_source_src_10009.listing_id AS listing - , views_source_src_10009.user_id AS user - , views_source_src_10009.listing_id AS view__listing - , views_source_src_10009.user_id AS view__user - FROM ***************************.fct_views views_source_src_10009 + , DATE_TRUNC('day', views_source_src_10010.ds) AS ds__day + , DATE_TRUNC('week', views_source_src_10010.ds) AS ds__week + , DATE_TRUNC('month', views_source_src_10010.ds) AS ds__month + , DATE_TRUNC('quarter', views_source_src_10010.ds) AS ds__quarter + , DATE_TRUNC('year', views_source_src_10010.ds) AS ds__year + , EXTRACT(year FROM views_source_src_10010.ds) AS ds__extract_year + , EXTRACT(quarter FROM views_source_src_10010.ds) AS ds__extract_quarter + , EXTRACT(month FROM views_source_src_10010.ds) AS ds__extract_month + , EXTRACT(day FROM views_source_src_10010.ds) AS ds__extract_day + , EXTRACT(isodow FROM views_source_src_10010.ds) AS ds__extract_dow + , EXTRACT(doy FROM views_source_src_10010.ds) AS ds__extract_doy + , DATE_TRUNC('day', views_source_src_10010.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', views_source_src_10010.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', views_source_src_10010.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', views_source_src_10010.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', views_source_src_10010.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM views_source_src_10010.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM views_source_src_10010.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM views_source_src_10010.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM views_source_src_10010.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM views_source_src_10010.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM views_source_src_10010.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', views_source_src_10010.ds) AS view__ds__day + , DATE_TRUNC('week', views_source_src_10010.ds) AS view__ds__week + , DATE_TRUNC('month', views_source_src_10010.ds) AS view__ds__month + , DATE_TRUNC('quarter', views_source_src_10010.ds) AS view__ds__quarter + , DATE_TRUNC('year', views_source_src_10010.ds) AS view__ds__year + , EXTRACT(year FROM views_source_src_10010.ds) AS view__ds__extract_year + , EXTRACT(quarter FROM views_source_src_10010.ds) AS view__ds__extract_quarter + , EXTRACT(month FROM views_source_src_10010.ds) AS view__ds__extract_month + , EXTRACT(day FROM views_source_src_10010.ds) AS view__ds__extract_day + , EXTRACT(isodow FROM views_source_src_10010.ds) AS view__ds__extract_dow + , EXTRACT(doy FROM views_source_src_10010.ds) AS view__ds__extract_doy + , DATE_TRUNC('day', views_source_src_10010.ds_partitioned) AS view__ds_partitioned__day + , DATE_TRUNC('week', views_source_src_10010.ds_partitioned) AS view__ds_partitioned__week + , DATE_TRUNC('month', views_source_src_10010.ds_partitioned) AS view__ds_partitioned__month + , DATE_TRUNC('quarter', views_source_src_10010.ds_partitioned) AS view__ds_partitioned__quarter + , DATE_TRUNC('year', views_source_src_10010.ds_partitioned) AS view__ds_partitioned__year + , EXTRACT(year FROM views_source_src_10010.ds_partitioned) AS view__ds_partitioned__extract_year + , EXTRACT(quarter FROM views_source_src_10010.ds_partitioned) AS view__ds_partitioned__extract_quarter + , EXTRACT(month FROM views_source_src_10010.ds_partitioned) AS view__ds_partitioned__extract_month + , EXTRACT(day FROM views_source_src_10010.ds_partitioned) AS view__ds_partitioned__extract_day + , EXTRACT(isodow FROM views_source_src_10010.ds_partitioned) AS view__ds_partitioned__extract_dow + , EXTRACT(doy FROM views_source_src_10010.ds_partitioned) AS view__ds_partitioned__extract_doy + , views_source_src_10010.listing_id AS listing + , views_source_src_10010.user_id AS user + , views_source_src_10010.listing_id AS view__listing + , views_source_src_10010.user_id AS view__user + FROM ***************************.fct_views views_source_src_10010 ) subq_10 ) subq_11 ) subq_12 @@ -619,62 +619,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_13 ) subq_14 ) subq_15 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql index 63f6522655..172693949e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql @@ -18,7 +18,7 @@ FROM ( -- Compute Metrics via Expressions SELECT subq_23.ds__day AS ds__day - , listings_latest_src_10004.country AS listing__country_latest + , listings_latest_src_10005.country AS listing__country_latest , SUM(subq_23.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -32,12 +32,12 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_23 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_23.listing = listings_latest_src_10004.listing_id + subq_23.listing = listings_latest_src_10005.listing_id GROUP BY subq_23.ds__day - , listings_latest_src_10004.country + , listings_latest_src_10005.country ) subq_30 FULL OUTER JOIN ( -- Join Standard Outputs @@ -47,7 +47,7 @@ FROM ( -- Compute Metrics via Expressions SELECT subq_33.ds__day AS ds__day - , listings_latest_src_10004.country AS listing__country_latest + , listings_latest_src_10005.country AS listing__country_latest , SUM(subq_33.views) AS views FROM ( -- Read Elements From Semantic Model 'views_source' @@ -58,15 +58,15 @@ FROM ( DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS views - FROM ***************************.fct_views views_source_src_10009 + FROM ***************************.fct_views views_source_src_10010 ) subq_33 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_33.listing = listings_latest_src_10004.listing_id + subq_33.listing = listings_latest_src_10005.listing_id GROUP BY subq_33.ds__day - , listings_latest_src_10004.country + , listings_latest_src_10005.country ) subq_40 ON ( diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql index be4f95db6e..8f5047e0a2 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql @@ -128,62 +128,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_2 ) subq_3 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql index f4983187c4..340d8adf0a 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql @@ -8,7 +8,7 @@ FROM ( -- Aggregate Measures SELECT subq_7.listing AS listing - , listings_latest_src_10004.country AS listing__country_latest + , listings_latest_src_10005.country AS listing__country_latest , SUM(subq_7.bookings) AS bookings , COUNT(DISTINCT subq_7.bookers) AS bookers FROM ( @@ -22,10 +22,10 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_7 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_7.listing = listings_latest_src_10004.listing_id + subq_7.listing = listings_latest_src_10005.listing_id GROUP BY subq_7.listing - , listings_latest_src_10004.country + , listings_latest_src_10005.country ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_simple_expr__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_simple_expr__plan0.sql index f04f16e5bf..7bbc7fb3b9 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_simple_expr__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_simple_expr__plan0.sql @@ -125,62 +125,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_2 ) subq_3 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_simple_expr__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_simple_expr__plan0_optimized.sql index caa4c0c6fe..5a844f2632 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_simple_expr__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_simple_expr__plan0_optimized.sql @@ -8,14 +8,14 @@ FROM ( -- Aggregate Measures SELECT bookings_source_src_10001.listing_id AS listing - , listings_latest_src_10004.country AS listing__country_latest + , listings_latest_src_10005.country AS listing__country_latest , SUM(bookings_source_src_10001.booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - bookings_source_src_10001.listing_id = listings_latest_src_10004.listing_id + bookings_source_src_10001.listing_id = listings_latest_src_10005.listing_id GROUP BY bookings_source_src_10001.listing_id - , listings_latest_src_10004.country + , listings_latest_src_10005.country ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimension_with_joined_where_constraint__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimension_with_joined_where_constraint__plan0.sql index 111ca3665f..7a9740ce87 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimension_with_joined_where_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimension_with_joined_where_constraint__plan0.sql @@ -126,62 +126,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: @@ -192,32 +192,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_10008.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_10008.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS ds_latest__extract_doy - , users_latest_src_10008.home_state_latest - , DATE_TRUNC('day', users_latest_src_10008.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS user__ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_10008.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS user__ds_latest__extract_doy - , users_latest_src_10008.home_state_latest AS user__home_state_latest - , users_latest_src_10008.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_10008 + DATE_TRUNC('day', users_latest_src_10009.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS ds_latest__extract_day + , EXTRACT(isodow FROM users_latest_src_10009.ds) AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS ds_latest__extract_doy + , users_latest_src_10009.home_state_latest + , DATE_TRUNC('day', users_latest_src_10009.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS user__ds_latest__extract_day + , EXTRACT(isodow FROM users_latest_src_10009.ds) AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS user__ds_latest__extract_doy + , users_latest_src_10009.home_state_latest AS user__home_state_latest + , users_latest_src_10009.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_10009 ) subq_1 ) subq_2 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimension_with_joined_where_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimension_with_joined_where_constraint__plan0_optimized.sql index 28fb7a0251..bbb933bac0 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimension_with_joined_where_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimension_with_joined_where_constraint__plan0_optimized.sql @@ -6,13 +6,13 @@ SELECT FROM ( -- Join Standard Outputs SELECT - listings_latest_src_10004.country AS listing__country_latest - , users_latest_src_10008.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings_latest listings_latest_src_10004 + listings_latest_src_10005.country AS listing__country_latest + , users_latest_src_10009.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings_latest listings_latest_src_10005 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_10008 + ***************************.dim_users_latest users_latest_src_10009 ON - listings_latest_src_10004.user_id = users_latest_src_10008.user_id + listings_latest_src_10005.user_id = users_latest_src_10009.user_id ) subq_8 WHERE listing__country_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimensions_requiring_join__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimensions_requiring_join__plan0.sql index 4ffc0ed119..dd31fb79f8 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimensions_requiring_join__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimensions_requiring_join__plan0.sql @@ -67,62 +67,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: @@ -133,32 +133,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_10008.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_10008.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS ds_latest__extract_doy - , users_latest_src_10008.home_state_latest - , DATE_TRUNC('day', users_latest_src_10008.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS user__ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_10008.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS user__ds_latest__extract_doy - , users_latest_src_10008.home_state_latest AS user__home_state_latest - , users_latest_src_10008.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_10008 + DATE_TRUNC('day', users_latest_src_10009.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS ds_latest__extract_day + , EXTRACT(isodow FROM users_latest_src_10009.ds) AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS ds_latest__extract_doy + , users_latest_src_10009.home_state_latest + , DATE_TRUNC('day', users_latest_src_10009.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS user__ds_latest__extract_day + , EXTRACT(isodow FROM users_latest_src_10009.ds) AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS user__ds_latest__extract_doy + , users_latest_src_10009.home_state_latest AS user__home_state_latest + , users_latest_src_10009.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_10009 ) subq_1 ) subq_2 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimensions_requiring_join__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimensions_requiring_join__plan0_optimized.sql index 4bf3539984..7f093b6070 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimensions_requiring_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimensions_requiring_join__plan0_optimized.sql @@ -2,13 +2,13 @@ -- Pass Only Elements: -- ['user__home_state_latest', 'listing__is_lux_latest'] SELECT - listings_latest_src_10004.is_lux AS listing__is_lux_latest - , users_latest_src_10008.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_10004 + listings_latest_src_10005.is_lux AS listing__is_lux_latest + , users_latest_src_10009.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_10005 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_10008 + ***************************.dim_users_latest users_latest_src_10009 ON - listings_latest_src_10004.user_id = users_latest_src_10008.user_id + listings_latest_src_10005.user_id = users_latest_src_10009.user_id GROUP BY - listings_latest_src_10004.is_lux - , users_latest_src_10008.home_state_latest + listings_latest_src_10005.is_lux + , users_latest_src_10009.home_state_latest diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multi_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multi_join_node__plan0.sql index 5c1795fec6..63e1d67013 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multi_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multi_join_node__plan0.sql @@ -114,62 +114,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_2 ) subq_3 ON @@ -184,62 +184,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_4 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multi_join_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multi_join_node__plan0_optimized.sql index 8180d208b3..ddfc1d9706 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multi_join_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multi_join_node__plan0_optimized.sql @@ -20,7 +20,7 @@ LEFT OUTER JOIN ( SELECT listing_id AS listing , country AS country_latest - FROM ***************************.dim_listings_latest listings_latest_src_10004 + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_9 ON subq_7.listing = subq_9.listing @@ -31,7 +31,7 @@ LEFT OUTER JOIN ( SELECT listing_id AS listing , country AS country_latest - FROM ***************************.dim_listings_latest listings_latest_src_10004 + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_11 ON subq_7.listing = subq_11.listing diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_single_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_single_join_node__plan0.sql index 749b06ce93..ee2699fd60 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_single_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_single_join_node__plan0.sql @@ -112,62 +112,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_2 ) subq_3 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_single_join_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_single_join_node__plan0_optimized.sql index 480a2c9f56..9202940446 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_single_join_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_single_join_node__plan0_optimized.sql @@ -12,6 +12,6 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_5 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_5.listing = listings_latest_src_10004.listing_id + subq_5.listing = listings_latest_src_10005.listing_id diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node__plan0.sql index 3be87d5d93..b59c087fd2 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node__plan0.sql @@ -125,62 +125,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_2 ) subq_3 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node__plan0_optimized.sql index 7a53d1c84e..9e5210f489 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node__plan0_optimized.sql @@ -3,7 +3,7 @@ -- Compute Metrics via Expressions SELECT subq_7.listing AS listing - , listings_latest_src_10004.country AS listing__country_latest + , listings_latest_src_10005.country AS listing__country_latest , SUM(subq_7.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -15,9 +15,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_7 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_7.listing = listings_latest_src_10004.listing_id + subq_7.listing = listings_latest_src_10005.listing_id GROUP BY subq_7.listing - , listings_latest_src_10004.country + , listings_latest_src_10005.country diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql index c189d7644a..555e8813da 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql @@ -319,62 +319,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_3 ) subq_4 ) subq_5 @@ -487,55 +487,55 @@ FROM ( -- Read Elements From Semantic Model 'views_source' SELECT 1 AS views - , DATE_TRUNC('day', views_source_src_10009.ds) AS ds__day - , DATE_TRUNC('week', views_source_src_10009.ds) AS ds__week - , DATE_TRUNC('month', views_source_src_10009.ds) AS ds__month - , DATE_TRUNC('quarter', views_source_src_10009.ds) AS ds__quarter - , DATE_TRUNC('year', views_source_src_10009.ds) AS ds__year - , EXTRACT(year FROM views_source_src_10009.ds) AS ds__extract_year - , EXTRACT(quarter FROM views_source_src_10009.ds) AS ds__extract_quarter - , EXTRACT(month FROM views_source_src_10009.ds) AS ds__extract_month - , EXTRACT(day FROM views_source_src_10009.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM views_source_src_10009.ds) = 0 THEN EXTRACT(dow FROM views_source_src_10009.ds) + 7 ELSE EXTRACT(dow FROM views_source_src_10009.ds) END AS ds__extract_dow - , EXTRACT(doy FROM views_source_src_10009.ds) AS ds__extract_doy - , DATE_TRUNC('day', views_source_src_10009.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', views_source_src_10009.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', views_source_src_10009.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', views_source_src_10009.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', views_source_src_10009.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM views_source_src_10009.ds_partitioned) = 0 THEN EXTRACT(dow FROM views_source_src_10009.ds_partitioned) + 7 ELSE EXTRACT(dow FROM views_source_src_10009.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', views_source_src_10009.ds) AS view__ds__day - , DATE_TRUNC('week', views_source_src_10009.ds) AS view__ds__week - , DATE_TRUNC('month', views_source_src_10009.ds) AS view__ds__month - , DATE_TRUNC('quarter', views_source_src_10009.ds) AS view__ds__quarter - , DATE_TRUNC('year', views_source_src_10009.ds) AS view__ds__year - , EXTRACT(year FROM views_source_src_10009.ds) AS view__ds__extract_year - , EXTRACT(quarter FROM views_source_src_10009.ds) AS view__ds__extract_quarter - , EXTRACT(month FROM views_source_src_10009.ds) AS view__ds__extract_month - , EXTRACT(day FROM views_source_src_10009.ds) AS view__ds__extract_day - , CASE WHEN EXTRACT(dow FROM views_source_src_10009.ds) = 0 THEN EXTRACT(dow FROM views_source_src_10009.ds) + 7 ELSE EXTRACT(dow FROM views_source_src_10009.ds) END AS view__ds__extract_dow - , EXTRACT(doy FROM views_source_src_10009.ds) AS view__ds__extract_doy - , DATE_TRUNC('day', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__day - , DATE_TRUNC('week', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__week - , DATE_TRUNC('month', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__month - , DATE_TRUNC('quarter', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__quarter - , DATE_TRUNC('year', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__year - , EXTRACT(year FROM views_source_src_10009.ds_partitioned) AS view__ds_partitioned__extract_year - , EXTRACT(quarter FROM views_source_src_10009.ds_partitioned) AS view__ds_partitioned__extract_quarter - , EXTRACT(month FROM views_source_src_10009.ds_partitioned) AS view__ds_partitioned__extract_month - , EXTRACT(day FROM views_source_src_10009.ds_partitioned) AS view__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM views_source_src_10009.ds_partitioned) = 0 THEN EXTRACT(dow FROM views_source_src_10009.ds_partitioned) + 7 ELSE EXTRACT(dow FROM views_source_src_10009.ds_partitioned) END AS view__ds_partitioned__extract_dow - , EXTRACT(doy FROM views_source_src_10009.ds_partitioned) AS view__ds_partitioned__extract_doy - , views_source_src_10009.listing_id AS listing - , views_source_src_10009.user_id AS user - , views_source_src_10009.listing_id AS view__listing - , views_source_src_10009.user_id AS view__user - FROM ***************************.fct_views views_source_src_10009 + , DATE_TRUNC('day', views_source_src_10010.ds) AS ds__day + , DATE_TRUNC('week', views_source_src_10010.ds) AS ds__week + , DATE_TRUNC('month', views_source_src_10010.ds) AS ds__month + , DATE_TRUNC('quarter', views_source_src_10010.ds) AS ds__quarter + , DATE_TRUNC('year', views_source_src_10010.ds) AS ds__year + , EXTRACT(year FROM views_source_src_10010.ds) AS ds__extract_year + , EXTRACT(quarter FROM views_source_src_10010.ds) AS ds__extract_quarter + , EXTRACT(month FROM views_source_src_10010.ds) AS ds__extract_month + , EXTRACT(day FROM views_source_src_10010.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM views_source_src_10010.ds) = 0 THEN EXTRACT(dow FROM views_source_src_10010.ds) + 7 ELSE EXTRACT(dow FROM views_source_src_10010.ds) END AS ds__extract_dow + , EXTRACT(doy FROM views_source_src_10010.ds) AS ds__extract_doy + , DATE_TRUNC('day', views_source_src_10010.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', views_source_src_10010.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', views_source_src_10010.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', views_source_src_10010.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', views_source_src_10010.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM views_source_src_10010.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM views_source_src_10010.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM views_source_src_10010.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM views_source_src_10010.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM views_source_src_10010.ds_partitioned) = 0 THEN EXTRACT(dow FROM views_source_src_10010.ds_partitioned) + 7 ELSE EXTRACT(dow FROM views_source_src_10010.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM views_source_src_10010.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', views_source_src_10010.ds) AS view__ds__day + , DATE_TRUNC('week', views_source_src_10010.ds) AS view__ds__week + , DATE_TRUNC('month', views_source_src_10010.ds) AS view__ds__month + , DATE_TRUNC('quarter', views_source_src_10010.ds) AS view__ds__quarter + , DATE_TRUNC('year', views_source_src_10010.ds) AS view__ds__year + , EXTRACT(year FROM views_source_src_10010.ds) AS view__ds__extract_year + , EXTRACT(quarter FROM views_source_src_10010.ds) AS view__ds__extract_quarter + , EXTRACT(month FROM views_source_src_10010.ds) AS view__ds__extract_month + , EXTRACT(day FROM views_source_src_10010.ds) AS view__ds__extract_day + , CASE WHEN EXTRACT(dow FROM views_source_src_10010.ds) = 0 THEN EXTRACT(dow FROM views_source_src_10010.ds) + 7 ELSE EXTRACT(dow FROM views_source_src_10010.ds) END AS view__ds__extract_dow + , EXTRACT(doy FROM views_source_src_10010.ds) AS view__ds__extract_doy + , DATE_TRUNC('day', views_source_src_10010.ds_partitioned) AS view__ds_partitioned__day + , DATE_TRUNC('week', views_source_src_10010.ds_partitioned) AS view__ds_partitioned__week + , DATE_TRUNC('month', views_source_src_10010.ds_partitioned) AS view__ds_partitioned__month + , DATE_TRUNC('quarter', views_source_src_10010.ds_partitioned) AS view__ds_partitioned__quarter + , DATE_TRUNC('year', views_source_src_10010.ds_partitioned) AS view__ds_partitioned__year + , EXTRACT(year FROM views_source_src_10010.ds_partitioned) AS view__ds_partitioned__extract_year + , EXTRACT(quarter FROM views_source_src_10010.ds_partitioned) AS view__ds_partitioned__extract_quarter + , EXTRACT(month FROM views_source_src_10010.ds_partitioned) AS view__ds_partitioned__extract_month + , EXTRACT(day FROM views_source_src_10010.ds_partitioned) AS view__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM views_source_src_10010.ds_partitioned) = 0 THEN EXTRACT(dow FROM views_source_src_10010.ds_partitioned) + 7 ELSE EXTRACT(dow FROM views_source_src_10010.ds_partitioned) END AS view__ds_partitioned__extract_dow + , EXTRACT(doy FROM views_source_src_10010.ds_partitioned) AS view__ds_partitioned__extract_doy + , views_source_src_10010.listing_id AS listing + , views_source_src_10010.user_id AS user + , views_source_src_10010.listing_id AS view__listing + , views_source_src_10010.user_id AS view__user + FROM ***************************.fct_views views_source_src_10010 ) subq_10 ) subq_11 ) subq_12 @@ -619,62 +619,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_13 ) subq_14 ) subq_15 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql index 63f6522655..172693949e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql @@ -18,7 +18,7 @@ FROM ( -- Compute Metrics via Expressions SELECT subq_23.ds__day AS ds__day - , listings_latest_src_10004.country AS listing__country_latest + , listings_latest_src_10005.country AS listing__country_latest , SUM(subq_23.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -32,12 +32,12 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_23 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_23.listing = listings_latest_src_10004.listing_id + subq_23.listing = listings_latest_src_10005.listing_id GROUP BY subq_23.ds__day - , listings_latest_src_10004.country + , listings_latest_src_10005.country ) subq_30 FULL OUTER JOIN ( -- Join Standard Outputs @@ -47,7 +47,7 @@ FROM ( -- Compute Metrics via Expressions SELECT subq_33.ds__day AS ds__day - , listings_latest_src_10004.country AS listing__country_latest + , listings_latest_src_10005.country AS listing__country_latest , SUM(subq_33.views) AS views FROM ( -- Read Elements From Semantic Model 'views_source' @@ -58,15 +58,15 @@ FROM ( DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS views - FROM ***************************.fct_views views_source_src_10009 + FROM ***************************.fct_views views_source_src_10010 ) subq_33 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_33.listing = listings_latest_src_10004.listing_id + subq_33.listing = listings_latest_src_10005.listing_id GROUP BY subq_33.ds__day - , listings_latest_src_10004.country + , listings_latest_src_10005.country ) subq_40 ON ( diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql index 8ac82eb3b7..cc4c21d64b 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql @@ -128,62 +128,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_2 ) subq_3 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql index f4983187c4..340d8adf0a 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql @@ -8,7 +8,7 @@ FROM ( -- Aggregate Measures SELECT subq_7.listing AS listing - , listings_latest_src_10004.country AS listing__country_latest + , listings_latest_src_10005.country AS listing__country_latest , SUM(subq_7.bookings) AS bookings , COUNT(DISTINCT subq_7.bookers) AS bookers FROM ( @@ -22,10 +22,10 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_7 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_7.listing = listings_latest_src_10004.listing_id + subq_7.listing = listings_latest_src_10005.listing_id GROUP BY subq_7.listing - , listings_latest_src_10004.country + , listings_latest_src_10005.country ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_simple_expr__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_simple_expr__plan0.sql index 23f64d2b1e..be23323f92 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_simple_expr__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_simple_expr__plan0.sql @@ -125,62 +125,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_2 ) subq_3 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_simple_expr__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_simple_expr__plan0_optimized.sql index caa4c0c6fe..5a844f2632 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_simple_expr__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_simple_expr__plan0_optimized.sql @@ -8,14 +8,14 @@ FROM ( -- Aggregate Measures SELECT bookings_source_src_10001.listing_id AS listing - , listings_latest_src_10004.country AS listing__country_latest + , listings_latest_src_10005.country AS listing__country_latest , SUM(bookings_source_src_10001.booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - bookings_source_src_10001.listing_id = listings_latest_src_10004.listing_id + bookings_source_src_10001.listing_id = listings_latest_src_10005.listing_id GROUP BY bookings_source_src_10001.listing_id - , listings_latest_src_10004.country + , listings_latest_src_10005.country ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimension_with_joined_where_constraint__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimension_with_joined_where_constraint__plan0.sql index a61f699922..035f5951b6 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimension_with_joined_where_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimension_with_joined_where_constraint__plan0.sql @@ -126,62 +126,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: @@ -192,32 +192,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_10008.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS ds_latest__extract_day - , CASE WHEN EXTRACT(dow FROM users_latest_src_10008.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_10008.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_10008.ds) END AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS ds_latest__extract_doy - , users_latest_src_10008.home_state_latest - , DATE_TRUNC('day', users_latest_src_10008.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS user__ds_latest__extract_day - , CASE WHEN EXTRACT(dow FROM users_latest_src_10008.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_10008.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_10008.ds) END AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS user__ds_latest__extract_doy - , users_latest_src_10008.home_state_latest AS user__home_state_latest - , users_latest_src_10008.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_10008 + DATE_TRUNC('day', users_latest_src_10009.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS ds_latest__extract_day + , CASE WHEN EXTRACT(dow FROM users_latest_src_10009.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_10009.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_10009.ds) END AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS ds_latest__extract_doy + , users_latest_src_10009.home_state_latest + , DATE_TRUNC('day', users_latest_src_10009.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS user__ds_latest__extract_day + , CASE WHEN EXTRACT(dow FROM users_latest_src_10009.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_10009.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_10009.ds) END AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS user__ds_latest__extract_doy + , users_latest_src_10009.home_state_latest AS user__home_state_latest + , users_latest_src_10009.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_10009 ) subq_1 ) subq_2 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimension_with_joined_where_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimension_with_joined_where_constraint__plan0_optimized.sql index 28fb7a0251..bbb933bac0 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimension_with_joined_where_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimension_with_joined_where_constraint__plan0_optimized.sql @@ -6,13 +6,13 @@ SELECT FROM ( -- Join Standard Outputs SELECT - listings_latest_src_10004.country AS listing__country_latest - , users_latest_src_10008.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings_latest listings_latest_src_10004 + listings_latest_src_10005.country AS listing__country_latest + , users_latest_src_10009.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings_latest listings_latest_src_10005 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_10008 + ***************************.dim_users_latest users_latest_src_10009 ON - listings_latest_src_10004.user_id = users_latest_src_10008.user_id + listings_latest_src_10005.user_id = users_latest_src_10009.user_id ) subq_8 WHERE listing__country_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimensions_requiring_join__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimensions_requiring_join__plan0.sql index c484b698c8..e4e43fac32 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimensions_requiring_join__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimensions_requiring_join__plan0.sql @@ -67,62 +67,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: @@ -133,32 +133,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_10008.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS ds_latest__extract_day - , CASE WHEN EXTRACT(dow FROM users_latest_src_10008.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_10008.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_10008.ds) END AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS ds_latest__extract_doy - , users_latest_src_10008.home_state_latest - , DATE_TRUNC('day', users_latest_src_10008.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS user__ds_latest__extract_day - , CASE WHEN EXTRACT(dow FROM users_latest_src_10008.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_10008.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_10008.ds) END AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS user__ds_latest__extract_doy - , users_latest_src_10008.home_state_latest AS user__home_state_latest - , users_latest_src_10008.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_10008 + DATE_TRUNC('day', users_latest_src_10009.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS ds_latest__extract_day + , CASE WHEN EXTRACT(dow FROM users_latest_src_10009.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_10009.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_10009.ds) END AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS ds_latest__extract_doy + , users_latest_src_10009.home_state_latest + , DATE_TRUNC('day', users_latest_src_10009.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS user__ds_latest__extract_day + , CASE WHEN EXTRACT(dow FROM users_latest_src_10009.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_10009.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_10009.ds) END AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS user__ds_latest__extract_doy + , users_latest_src_10009.home_state_latest AS user__home_state_latest + , users_latest_src_10009.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_10009 ) subq_1 ) subq_2 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimensions_requiring_join__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimensions_requiring_join__plan0_optimized.sql index 4bf3539984..7f093b6070 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimensions_requiring_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimensions_requiring_join__plan0_optimized.sql @@ -2,13 +2,13 @@ -- Pass Only Elements: -- ['user__home_state_latest', 'listing__is_lux_latest'] SELECT - listings_latest_src_10004.is_lux AS listing__is_lux_latest - , users_latest_src_10008.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_10004 + listings_latest_src_10005.is_lux AS listing__is_lux_latest + , users_latest_src_10009.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_10005 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_10008 + ***************************.dim_users_latest users_latest_src_10009 ON - listings_latest_src_10004.user_id = users_latest_src_10008.user_id + listings_latest_src_10005.user_id = users_latest_src_10009.user_id GROUP BY - listings_latest_src_10004.is_lux - , users_latest_src_10008.home_state_latest + listings_latest_src_10005.is_lux + , users_latest_src_10009.home_state_latest diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multi_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multi_join_node__plan0.sql index 2ffa44245e..9eeb2b537a 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multi_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multi_join_node__plan0.sql @@ -114,62 +114,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_2 ) subq_3 ON @@ -184,62 +184,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_4 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multi_join_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multi_join_node__plan0_optimized.sql index 8180d208b3..ddfc1d9706 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multi_join_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multi_join_node__plan0_optimized.sql @@ -20,7 +20,7 @@ LEFT OUTER JOIN ( SELECT listing_id AS listing , country AS country_latest - FROM ***************************.dim_listings_latest listings_latest_src_10004 + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_9 ON subq_7.listing = subq_9.listing @@ -31,7 +31,7 @@ LEFT OUTER JOIN ( SELECT listing_id AS listing , country AS country_latest - FROM ***************************.dim_listings_latest listings_latest_src_10004 + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_11 ON subq_7.listing = subq_11.listing diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_single_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_single_join_node__plan0.sql index cc9f3b259f..1a056de001 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_single_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_single_join_node__plan0.sql @@ -112,62 +112,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_2 ) subq_3 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_single_join_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_single_join_node__plan0_optimized.sql index 480a2c9f56..9202940446 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_single_join_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_single_join_node__plan0_optimized.sql @@ -12,6 +12,6 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_5 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_5.listing = listings_latest_src_10004.listing_id + subq_5.listing = listings_latest_src_10005.listing_id diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node__plan0.sql index dad6172504..f11c15d340 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node__plan0.sql @@ -125,62 +125,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_2 ) subq_3 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node__plan0_optimized.sql index 7a53d1c84e..9e5210f489 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node__plan0_optimized.sql @@ -3,7 +3,7 @@ -- Compute Metrics via Expressions SELECT subq_7.listing AS listing - , listings_latest_src_10004.country AS listing__country_latest + , listings_latest_src_10005.country AS listing__country_latest , SUM(subq_7.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -15,9 +15,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_7 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_7.listing = listings_latest_src_10004.listing_id + subq_7.listing = listings_latest_src_10005.listing_id GROUP BY subq_7.listing - , listings_latest_src_10004.country + , listings_latest_src_10005.country diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql index 38473b92d1..92393ec2f6 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql @@ -319,62 +319,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_3 ) subq_4 ) subq_5 @@ -487,55 +487,55 @@ FROM ( -- Read Elements From Semantic Model 'views_source' SELECT 1 AS views - , DATE_TRUNC('day', views_source_src_10009.ds) AS ds__day - , DATE_TRUNC('week', views_source_src_10009.ds) AS ds__week - , DATE_TRUNC('month', views_source_src_10009.ds) AS ds__month - , DATE_TRUNC('quarter', views_source_src_10009.ds) AS ds__quarter - , DATE_TRUNC('year', views_source_src_10009.ds) AS ds__year - , EXTRACT(year FROM views_source_src_10009.ds) AS ds__extract_year - , EXTRACT(quarter FROM views_source_src_10009.ds) AS ds__extract_quarter - , EXTRACT(month FROM views_source_src_10009.ds) AS ds__extract_month - , EXTRACT(day FROM views_source_src_10009.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM views_source_src_10009.ds) AS ds__extract_dow - , EXTRACT(doy FROM views_source_src_10009.ds) AS ds__extract_doy - , DATE_TRUNC('day', views_source_src_10009.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', views_source_src_10009.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', views_source_src_10009.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', views_source_src_10009.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', views_source_src_10009.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', views_source_src_10009.ds) AS view__ds__day - , DATE_TRUNC('week', views_source_src_10009.ds) AS view__ds__week - , DATE_TRUNC('month', views_source_src_10009.ds) AS view__ds__month - , DATE_TRUNC('quarter', views_source_src_10009.ds) AS view__ds__quarter - , DATE_TRUNC('year', views_source_src_10009.ds) AS view__ds__year - , EXTRACT(year FROM views_source_src_10009.ds) AS view__ds__extract_year - , EXTRACT(quarter FROM views_source_src_10009.ds) AS view__ds__extract_quarter - , EXTRACT(month FROM views_source_src_10009.ds) AS view__ds__extract_month - , EXTRACT(day FROM views_source_src_10009.ds) AS view__ds__extract_day - , EXTRACT(dayofweekiso FROM views_source_src_10009.ds) AS view__ds__extract_dow - , EXTRACT(doy FROM views_source_src_10009.ds) AS view__ds__extract_doy - , DATE_TRUNC('day', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__day - , DATE_TRUNC('week', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__week - , DATE_TRUNC('month', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__month - , DATE_TRUNC('quarter', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__quarter - , DATE_TRUNC('year', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__year - , EXTRACT(year FROM views_source_src_10009.ds_partitioned) AS view__ds_partitioned__extract_year - , EXTRACT(quarter FROM views_source_src_10009.ds_partitioned) AS view__ds_partitioned__extract_quarter - , EXTRACT(month FROM views_source_src_10009.ds_partitioned) AS view__ds_partitioned__extract_month - , EXTRACT(day FROM views_source_src_10009.ds_partitioned) AS view__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM views_source_src_10009.ds_partitioned) AS view__ds_partitioned__extract_dow - , EXTRACT(doy FROM views_source_src_10009.ds_partitioned) AS view__ds_partitioned__extract_doy - , views_source_src_10009.listing_id AS listing - , views_source_src_10009.user_id AS user - , views_source_src_10009.listing_id AS view__listing - , views_source_src_10009.user_id AS view__user - FROM ***************************.fct_views views_source_src_10009 + , DATE_TRUNC('day', views_source_src_10010.ds) AS ds__day + , DATE_TRUNC('week', views_source_src_10010.ds) AS ds__week + , DATE_TRUNC('month', views_source_src_10010.ds) AS ds__month + , DATE_TRUNC('quarter', views_source_src_10010.ds) AS ds__quarter + , DATE_TRUNC('year', views_source_src_10010.ds) AS ds__year + , EXTRACT(year FROM views_source_src_10010.ds) AS ds__extract_year + , EXTRACT(quarter FROM views_source_src_10010.ds) AS ds__extract_quarter + , EXTRACT(month FROM views_source_src_10010.ds) AS ds__extract_month + , EXTRACT(day FROM views_source_src_10010.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM views_source_src_10010.ds) AS ds__extract_dow + , EXTRACT(doy FROM views_source_src_10010.ds) AS ds__extract_doy + , DATE_TRUNC('day', views_source_src_10010.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', views_source_src_10010.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', views_source_src_10010.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', views_source_src_10010.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', views_source_src_10010.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM views_source_src_10010.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM views_source_src_10010.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM views_source_src_10010.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM views_source_src_10010.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM views_source_src_10010.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM views_source_src_10010.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', views_source_src_10010.ds) AS view__ds__day + , DATE_TRUNC('week', views_source_src_10010.ds) AS view__ds__week + , DATE_TRUNC('month', views_source_src_10010.ds) AS view__ds__month + , DATE_TRUNC('quarter', views_source_src_10010.ds) AS view__ds__quarter + , DATE_TRUNC('year', views_source_src_10010.ds) AS view__ds__year + , EXTRACT(year FROM views_source_src_10010.ds) AS view__ds__extract_year + , EXTRACT(quarter FROM views_source_src_10010.ds) AS view__ds__extract_quarter + , EXTRACT(month FROM views_source_src_10010.ds) AS view__ds__extract_month + , EXTRACT(day FROM views_source_src_10010.ds) AS view__ds__extract_day + , EXTRACT(dayofweekiso FROM views_source_src_10010.ds) AS view__ds__extract_dow + , EXTRACT(doy FROM views_source_src_10010.ds) AS view__ds__extract_doy + , DATE_TRUNC('day', views_source_src_10010.ds_partitioned) AS view__ds_partitioned__day + , DATE_TRUNC('week', views_source_src_10010.ds_partitioned) AS view__ds_partitioned__week + , DATE_TRUNC('month', views_source_src_10010.ds_partitioned) AS view__ds_partitioned__month + , DATE_TRUNC('quarter', views_source_src_10010.ds_partitioned) AS view__ds_partitioned__quarter + , DATE_TRUNC('year', views_source_src_10010.ds_partitioned) AS view__ds_partitioned__year + , EXTRACT(year FROM views_source_src_10010.ds_partitioned) AS view__ds_partitioned__extract_year + , EXTRACT(quarter FROM views_source_src_10010.ds_partitioned) AS view__ds_partitioned__extract_quarter + , EXTRACT(month FROM views_source_src_10010.ds_partitioned) AS view__ds_partitioned__extract_month + , EXTRACT(day FROM views_source_src_10010.ds_partitioned) AS view__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM views_source_src_10010.ds_partitioned) AS view__ds_partitioned__extract_dow + , EXTRACT(doy FROM views_source_src_10010.ds_partitioned) AS view__ds_partitioned__extract_doy + , views_source_src_10010.listing_id AS listing + , views_source_src_10010.user_id AS user + , views_source_src_10010.listing_id AS view__listing + , views_source_src_10010.user_id AS view__user + FROM ***************************.fct_views views_source_src_10010 ) subq_10 ) subq_11 ) subq_12 @@ -619,62 +619,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_13 ) subq_14 ) subq_15 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql index 635bfacdef..ee6adb1fd6 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql @@ -18,7 +18,7 @@ FROM ( -- Compute Metrics via Expressions SELECT subq_23.ds__day AS ds__day - , listings_latest_src_10004.country AS listing__country_latest + , listings_latest_src_10005.country AS listing__country_latest , SUM(subq_23.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -32,12 +32,12 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_23 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_23.listing = listings_latest_src_10004.listing_id + subq_23.listing = listings_latest_src_10005.listing_id GROUP BY subq_23.ds__day - , listings_latest_src_10004.country + , listings_latest_src_10005.country ) subq_30 FULL OUTER JOIN ( -- Join Standard Outputs @@ -47,7 +47,7 @@ FROM ( -- Compute Metrics via Expressions SELECT subq_33.ds__day AS ds__day - , listings_latest_src_10004.country AS listing__country_latest + , listings_latest_src_10005.country AS listing__country_latest , SUM(subq_33.views) AS views FROM ( -- Read Elements From Semantic Model 'views_source' @@ -58,15 +58,15 @@ FROM ( DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS views - FROM ***************************.fct_views views_source_src_10009 + FROM ***************************.fct_views views_source_src_10010 ) subq_33 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_33.listing = listings_latest_src_10004.listing_id + subq_33.listing = listings_latest_src_10005.listing_id GROUP BY subq_33.ds__day - , listings_latest_src_10004.country + , listings_latest_src_10005.country ) subq_40 ON ( diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql index 3d535c3a3c..129bb396d8 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql @@ -128,62 +128,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_2 ) subq_3 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql index f22bdaf7cb..0bfa1bff7f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql @@ -8,7 +8,7 @@ FROM ( -- Aggregate Measures SELECT subq_7.listing AS listing - , listings_latest_src_10004.country AS listing__country_latest + , listings_latest_src_10005.country AS listing__country_latest , SUM(subq_7.bookings) AS bookings , COUNT(DISTINCT subq_7.bookers) AS bookers FROM ( @@ -22,10 +22,10 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_7 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_7.listing = listings_latest_src_10004.listing_id + subq_7.listing = listings_latest_src_10005.listing_id GROUP BY subq_7.listing - , listings_latest_src_10004.country + , listings_latest_src_10005.country ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_simple_expr__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_simple_expr__plan0.sql index faeef9d5ef..921dd2f799 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_simple_expr__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_simple_expr__plan0.sql @@ -125,62 +125,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_2 ) subq_3 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_simple_expr__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_simple_expr__plan0_optimized.sql index caa4c0c6fe..5a844f2632 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_simple_expr__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_simple_expr__plan0_optimized.sql @@ -8,14 +8,14 @@ FROM ( -- Aggregate Measures SELECT bookings_source_src_10001.listing_id AS listing - , listings_latest_src_10004.country AS listing__country_latest + , listings_latest_src_10005.country AS listing__country_latest , SUM(bookings_source_src_10001.booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - bookings_source_src_10001.listing_id = listings_latest_src_10004.listing_id + bookings_source_src_10001.listing_id = listings_latest_src_10005.listing_id GROUP BY bookings_source_src_10001.listing_id - , listings_latest_src_10004.country + , listings_latest_src_10005.country ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimension_with_joined_where_constraint__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimension_with_joined_where_constraint__plan0.sql index 3b356c536e..1f3816a7c6 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimension_with_joined_where_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimension_with_joined_where_constraint__plan0.sql @@ -126,62 +126,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: @@ -192,32 +192,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_10008.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS ds_latest__extract_day - , EXTRACT(dayofweekiso FROM users_latest_src_10008.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS ds_latest__extract_doy - , users_latest_src_10008.home_state_latest - , DATE_TRUNC('day', users_latest_src_10008.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS user__ds_latest__extract_day - , EXTRACT(dayofweekiso FROM users_latest_src_10008.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS user__ds_latest__extract_doy - , users_latest_src_10008.home_state_latest AS user__home_state_latest - , users_latest_src_10008.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_10008 + DATE_TRUNC('day', users_latest_src_10009.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS ds_latest__extract_day + , EXTRACT(dayofweekiso FROM users_latest_src_10009.ds) AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS ds_latest__extract_doy + , users_latest_src_10009.home_state_latest + , DATE_TRUNC('day', users_latest_src_10009.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS user__ds_latest__extract_day + , EXTRACT(dayofweekiso FROM users_latest_src_10009.ds) AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS user__ds_latest__extract_doy + , users_latest_src_10009.home_state_latest AS user__home_state_latest + , users_latest_src_10009.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_10009 ) subq_1 ) subq_2 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimension_with_joined_where_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimension_with_joined_where_constraint__plan0_optimized.sql index 28fb7a0251..bbb933bac0 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimension_with_joined_where_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimension_with_joined_where_constraint__plan0_optimized.sql @@ -6,13 +6,13 @@ SELECT FROM ( -- Join Standard Outputs SELECT - listings_latest_src_10004.country AS listing__country_latest - , users_latest_src_10008.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings_latest listings_latest_src_10004 + listings_latest_src_10005.country AS listing__country_latest + , users_latest_src_10009.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings_latest listings_latest_src_10005 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_10008 + ***************************.dim_users_latest users_latest_src_10009 ON - listings_latest_src_10004.user_id = users_latest_src_10008.user_id + listings_latest_src_10005.user_id = users_latest_src_10009.user_id ) subq_8 WHERE listing__country_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimensions_requiring_join__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimensions_requiring_join__plan0.sql index 2e9ea32b76..9de08f9d44 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimensions_requiring_join__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimensions_requiring_join__plan0.sql @@ -67,62 +67,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: @@ -133,32 +133,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_10008.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS ds_latest__extract_day - , EXTRACT(dayofweekiso FROM users_latest_src_10008.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS ds_latest__extract_doy - , users_latest_src_10008.home_state_latest - , DATE_TRUNC('day', users_latest_src_10008.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS user__ds_latest__extract_day - , EXTRACT(dayofweekiso FROM users_latest_src_10008.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS user__ds_latest__extract_doy - , users_latest_src_10008.home_state_latest AS user__home_state_latest - , users_latest_src_10008.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_10008 + DATE_TRUNC('day', users_latest_src_10009.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS ds_latest__extract_day + , EXTRACT(dayofweekiso FROM users_latest_src_10009.ds) AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS ds_latest__extract_doy + , users_latest_src_10009.home_state_latest + , DATE_TRUNC('day', users_latest_src_10009.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS user__ds_latest__extract_day + , EXTRACT(dayofweekiso FROM users_latest_src_10009.ds) AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS user__ds_latest__extract_doy + , users_latest_src_10009.home_state_latest AS user__home_state_latest + , users_latest_src_10009.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_10009 ) subq_1 ) subq_2 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimensions_requiring_join__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimensions_requiring_join__plan0_optimized.sql index 4bf3539984..7f093b6070 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimensions_requiring_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimensions_requiring_join__plan0_optimized.sql @@ -2,13 +2,13 @@ -- Pass Only Elements: -- ['user__home_state_latest', 'listing__is_lux_latest'] SELECT - listings_latest_src_10004.is_lux AS listing__is_lux_latest - , users_latest_src_10008.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_10004 + listings_latest_src_10005.is_lux AS listing__is_lux_latest + , users_latest_src_10009.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_10005 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_10008 + ***************************.dim_users_latest users_latest_src_10009 ON - listings_latest_src_10004.user_id = users_latest_src_10008.user_id + listings_latest_src_10005.user_id = users_latest_src_10009.user_id GROUP BY - listings_latest_src_10004.is_lux - , users_latest_src_10008.home_state_latest + listings_latest_src_10005.is_lux + , users_latest_src_10009.home_state_latest diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multi_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multi_join_node__plan0.sql index 96067fbe9c..863151e670 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multi_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multi_join_node__plan0.sql @@ -114,62 +114,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_2 ) subq_3 ON @@ -184,62 +184,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_4 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multi_join_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multi_join_node__plan0_optimized.sql index 8180d208b3..ddfc1d9706 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multi_join_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multi_join_node__plan0_optimized.sql @@ -20,7 +20,7 @@ LEFT OUTER JOIN ( SELECT listing_id AS listing , country AS country_latest - FROM ***************************.dim_listings_latest listings_latest_src_10004 + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_9 ON subq_7.listing = subq_9.listing @@ -31,7 +31,7 @@ LEFT OUTER JOIN ( SELECT listing_id AS listing , country AS country_latest - FROM ***************************.dim_listings_latest listings_latest_src_10004 + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_11 ON subq_7.listing = subq_11.listing diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_single_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_single_join_node__plan0.sql index af48996702..4c3043e790 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_single_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_single_join_node__plan0.sql @@ -112,62 +112,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_2 ) subq_3 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_single_join_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_single_join_node__plan0_optimized.sql index 480a2c9f56..9202940446 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_single_join_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_single_join_node__plan0_optimized.sql @@ -12,6 +12,6 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_5 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_5.listing = listings_latest_src_10004.listing_id + subq_5.listing = listings_latest_src_10005.listing_id diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node__plan0.xml index 77ef9e9b24..29122d902b 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node__plan0.xml @@ -461,242 +461,242 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.xml index cc5132fbd1..3f3aecfe24 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.xml @@ -1,25 +1,25 @@ - + - + - + - + - + @@ -36,10 +36,10 @@ - + - + @@ -55,45 +55,45 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -101,45 +101,45 @@ - + - + - + - + - + - + - + - + - + - + - + - + @@ -149,416 +149,416 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -933,525 +933,525 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1463,45 +1463,45 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -1509,45 +1509,45 @@ - + - + - + - + - + - + - + - + - + - + - + - + @@ -1557,473 +1557,473 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -2033,525 +2033,525 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.xml index b8ea0e4a87..17c1855177 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.xml @@ -473,242 +473,242 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_simple_expr__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_simple_expr__plan0.xml index d54260dadb..22bf057801 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_simple_expr__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_simple_expr__plan0.xml @@ -461,242 +461,242 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_dimension_with_joined_where_constraint__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_dimension_with_joined_where_constraint__plan0.xml index e20132aba5..c3eed73a7e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_dimension_with_joined_where_constraint__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_dimension_with_joined_where_constraint__plan0.xml @@ -481,7 +481,7 @@ - + @@ -492,237 +492,237 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -739,118 +739,118 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_dimensions_requiring_join__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_dimensions_requiring_join__plan0.xml index 1eb6447fb4..ad8b624b68 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_dimensions_requiring_join__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_dimensions_requiring_join__plan0.xml @@ -254,7 +254,7 @@ - + @@ -265,237 +265,237 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -512,118 +512,118 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_multi_join_node__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_multi_join_node__plan0.xml index 3268ab93ba..1c616c88c7 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_multi_join_node__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_multi_join_node__plan0.xml @@ -427,242 +427,242 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -680,242 +680,242 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_single_join_node__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_single_join_node__plan0.xml index ab795d1fad..659424d6b3 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_single_join_node__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_single_join_node__plan0.xml @@ -413,242 +413,242 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql index 661b10274b..1322f60df3 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql @@ -72,22 +72,22 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_monthly_source' SELECT - bookings_monthly_source_src_10024.bookings_monthly - , DATE_TRUNC(bookings_monthly_source_src_10024.ds, month) AS monthly_ds__month - , DATE_TRUNC(bookings_monthly_source_src_10024.ds, quarter) AS monthly_ds__quarter - , DATE_TRUNC(bookings_monthly_source_src_10024.ds, year) AS monthly_ds__year - , EXTRACT(year FROM bookings_monthly_source_src_10024.ds) AS monthly_ds__extract_year - , EXTRACT(quarter FROM bookings_monthly_source_src_10024.ds) AS monthly_ds__extract_quarter - , EXTRACT(month FROM bookings_monthly_source_src_10024.ds) AS monthly_ds__extract_month - , DATE_TRUNC(bookings_monthly_source_src_10024.ds, month) AS booking__monthly_ds__month - , DATE_TRUNC(bookings_monthly_source_src_10024.ds, quarter) AS booking__monthly_ds__quarter - , DATE_TRUNC(bookings_monthly_source_src_10024.ds, year) AS booking__monthly_ds__year - , EXTRACT(year FROM bookings_monthly_source_src_10024.ds) AS booking__monthly_ds__extract_year - , EXTRACT(quarter FROM bookings_monthly_source_src_10024.ds) AS booking__monthly_ds__extract_quarter - , EXTRACT(month FROM bookings_monthly_source_src_10024.ds) AS booking__monthly_ds__extract_month - , bookings_monthly_source_src_10024.listing_id AS listing - , bookings_monthly_source_src_10024.listing_id AS booking__listing - FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_10024 + bookings_monthly_source_src_10026.bookings_monthly + , DATE_TRUNC(bookings_monthly_source_src_10026.ds, month) AS monthly_ds__month + , DATE_TRUNC(bookings_monthly_source_src_10026.ds, quarter) AS monthly_ds__quarter + , DATE_TRUNC(bookings_monthly_source_src_10026.ds, year) AS monthly_ds__year + , EXTRACT(year FROM bookings_monthly_source_src_10026.ds) AS monthly_ds__extract_year + , EXTRACT(quarter FROM bookings_monthly_source_src_10026.ds) AS monthly_ds__extract_quarter + , EXTRACT(month FROM bookings_monthly_source_src_10026.ds) AS monthly_ds__extract_month + , DATE_TRUNC(bookings_monthly_source_src_10026.ds, month) AS booking__monthly_ds__month + , DATE_TRUNC(bookings_monthly_source_src_10026.ds, quarter) AS booking__monthly_ds__quarter + , DATE_TRUNC(bookings_monthly_source_src_10026.ds, year) AS booking__monthly_ds__year + , EXTRACT(year FROM bookings_monthly_source_src_10026.ds) AS booking__monthly_ds__extract_year + , EXTRACT(quarter FROM bookings_monthly_source_src_10026.ds) AS booking__monthly_ds__extract_quarter + , EXTRACT(month FROM bookings_monthly_source_src_10026.ds) AS booking__monthly_ds__extract_month + , bookings_monthly_source_src_10026.listing_id AS listing + , bookings_monthly_source_src_10026.listing_id AS booking__listing + FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_10026 ) subq_0 ) subq_1 ON diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql index 9b18b91533..feffe86ae1 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( -- Compute Metrics via Expressions SELECT subq_10.metric_time__month AS metric_time__month - , SUM(bookings_monthly_source_src_10024.bookings_monthly) AS bookings_last_month + , SUM(bookings_monthly_source_src_10026.bookings_monthly) AS bookings_last_month FROM ( -- Date Spine SELECT @@ -20,9 +20,9 @@ FROM ( metric_time__month ) subq_10 INNER JOIN - ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_10024 + ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_10026 ON - DATE_SUB(CAST(subq_10.metric_time__month AS DATETIME), INTERVAL 1 month) = DATE_TRUNC(bookings_monthly_source_src_10024.ds, month) + DATE_SUB(CAST(subq_10.metric_time__month AS DATETIME), INTERVAL 1 month) = DATE_TRUNC(bookings_monthly_source_src_10026.ds, month) GROUP BY metric_time__month ) subq_15 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql index 41ec0d45de..c19000cc02 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql @@ -72,22 +72,22 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_monthly_source' SELECT - bookings_monthly_source_src_10024.bookings_monthly - , DATE_TRUNC('month', bookings_monthly_source_src_10024.ds) AS monthly_ds__month - , DATE_TRUNC('quarter', bookings_monthly_source_src_10024.ds) AS monthly_ds__quarter - , DATE_TRUNC('year', bookings_monthly_source_src_10024.ds) AS monthly_ds__year - , EXTRACT(year FROM bookings_monthly_source_src_10024.ds) AS monthly_ds__extract_year - , EXTRACT(quarter FROM bookings_monthly_source_src_10024.ds) AS monthly_ds__extract_quarter - , EXTRACT(month FROM bookings_monthly_source_src_10024.ds) AS monthly_ds__extract_month - , DATE_TRUNC('month', bookings_monthly_source_src_10024.ds) AS booking__monthly_ds__month - , DATE_TRUNC('quarter', bookings_monthly_source_src_10024.ds) AS booking__monthly_ds__quarter - , DATE_TRUNC('year', bookings_monthly_source_src_10024.ds) AS booking__monthly_ds__year - , EXTRACT(year FROM bookings_monthly_source_src_10024.ds) AS booking__monthly_ds__extract_year - , EXTRACT(quarter FROM bookings_monthly_source_src_10024.ds) AS booking__monthly_ds__extract_quarter - , EXTRACT(month FROM bookings_monthly_source_src_10024.ds) AS booking__monthly_ds__extract_month - , bookings_monthly_source_src_10024.listing_id AS listing - , bookings_monthly_source_src_10024.listing_id AS booking__listing - FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_10024 + bookings_monthly_source_src_10026.bookings_monthly + , DATE_TRUNC('month', bookings_monthly_source_src_10026.ds) AS monthly_ds__month + , DATE_TRUNC('quarter', bookings_monthly_source_src_10026.ds) AS monthly_ds__quarter + , DATE_TRUNC('year', bookings_monthly_source_src_10026.ds) AS monthly_ds__year + , EXTRACT(year FROM bookings_monthly_source_src_10026.ds) AS monthly_ds__extract_year + , EXTRACT(quarter FROM bookings_monthly_source_src_10026.ds) AS monthly_ds__extract_quarter + , EXTRACT(month FROM bookings_monthly_source_src_10026.ds) AS monthly_ds__extract_month + , DATE_TRUNC('month', bookings_monthly_source_src_10026.ds) AS booking__monthly_ds__month + , DATE_TRUNC('quarter', bookings_monthly_source_src_10026.ds) AS booking__monthly_ds__quarter + , DATE_TRUNC('year', bookings_monthly_source_src_10026.ds) AS booking__monthly_ds__year + , EXTRACT(year FROM bookings_monthly_source_src_10026.ds) AS booking__monthly_ds__extract_year + , EXTRACT(quarter FROM bookings_monthly_source_src_10026.ds) AS booking__monthly_ds__extract_quarter + , EXTRACT(month FROM bookings_monthly_source_src_10026.ds) AS booking__monthly_ds__extract_month + , bookings_monthly_source_src_10026.listing_id AS listing + , bookings_monthly_source_src_10026.listing_id AS booking__listing + FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_10026 ) subq_0 ) subq_1 ON diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql index d0d550e6d3..b7a5485c92 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( -- Compute Metrics via Expressions SELECT subq_10.metric_time__month AS metric_time__month - , SUM(bookings_monthly_source_src_10024.bookings_monthly) AS bookings_last_month + , SUM(bookings_monthly_source_src_10026.bookings_monthly) AS bookings_last_month FROM ( -- Date Spine SELECT @@ -20,9 +20,9 @@ FROM ( DATE_TRUNC('month', ds) ) subq_10 INNER JOIN - ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_10024 + ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_10026 ON - DATEADD(month, -1, subq_10.metric_time__month) = DATE_TRUNC('month', bookings_monthly_source_src_10024.ds) + DATEADD(month, -1, subq_10.metric_time__month) = DATE_TRUNC('month', bookings_monthly_source_src_10026.ds) GROUP BY subq_10.metric_time__month ) subq_15 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql index 3e830e9a12..a3797a278c 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql @@ -72,22 +72,22 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_monthly_source' SELECT - bookings_monthly_source_src_10024.bookings_monthly - , DATE_TRUNC('month', bookings_monthly_source_src_10024.ds) AS monthly_ds__month - , DATE_TRUNC('quarter', bookings_monthly_source_src_10024.ds) AS monthly_ds__quarter - , DATE_TRUNC('year', bookings_monthly_source_src_10024.ds) AS monthly_ds__year - , EXTRACT(year FROM bookings_monthly_source_src_10024.ds) AS monthly_ds__extract_year - , EXTRACT(quarter FROM bookings_monthly_source_src_10024.ds) AS monthly_ds__extract_quarter - , EXTRACT(month FROM bookings_monthly_source_src_10024.ds) AS monthly_ds__extract_month - , DATE_TRUNC('month', bookings_monthly_source_src_10024.ds) AS booking__monthly_ds__month - , DATE_TRUNC('quarter', bookings_monthly_source_src_10024.ds) AS booking__monthly_ds__quarter - , DATE_TRUNC('year', bookings_monthly_source_src_10024.ds) AS booking__monthly_ds__year - , EXTRACT(year FROM bookings_monthly_source_src_10024.ds) AS booking__monthly_ds__extract_year - , EXTRACT(quarter FROM bookings_monthly_source_src_10024.ds) AS booking__monthly_ds__extract_quarter - , EXTRACT(month FROM bookings_monthly_source_src_10024.ds) AS booking__monthly_ds__extract_month - , bookings_monthly_source_src_10024.listing_id AS listing - , bookings_monthly_source_src_10024.listing_id AS booking__listing - FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_10024 + bookings_monthly_source_src_10026.bookings_monthly + , DATE_TRUNC('month', bookings_monthly_source_src_10026.ds) AS monthly_ds__month + , DATE_TRUNC('quarter', bookings_monthly_source_src_10026.ds) AS monthly_ds__quarter + , DATE_TRUNC('year', bookings_monthly_source_src_10026.ds) AS monthly_ds__year + , EXTRACT(year FROM bookings_monthly_source_src_10026.ds) AS monthly_ds__extract_year + , EXTRACT(quarter FROM bookings_monthly_source_src_10026.ds) AS monthly_ds__extract_quarter + , EXTRACT(month FROM bookings_monthly_source_src_10026.ds) AS monthly_ds__extract_month + , DATE_TRUNC('month', bookings_monthly_source_src_10026.ds) AS booking__monthly_ds__month + , DATE_TRUNC('quarter', bookings_monthly_source_src_10026.ds) AS booking__monthly_ds__quarter + , DATE_TRUNC('year', bookings_monthly_source_src_10026.ds) AS booking__monthly_ds__year + , EXTRACT(year FROM bookings_monthly_source_src_10026.ds) AS booking__monthly_ds__extract_year + , EXTRACT(quarter FROM bookings_monthly_source_src_10026.ds) AS booking__monthly_ds__extract_quarter + , EXTRACT(month FROM bookings_monthly_source_src_10026.ds) AS booking__monthly_ds__extract_month + , bookings_monthly_source_src_10026.listing_id AS listing + , bookings_monthly_source_src_10026.listing_id AS booking__listing + FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_10026 ) subq_0 ) subq_1 ON diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql index 4883e8870b..c462a58676 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( -- Compute Metrics via Expressions SELECT subq_10.metric_time__month AS metric_time__month - , SUM(bookings_monthly_source_src_10024.bookings_monthly) AS bookings_last_month + , SUM(bookings_monthly_source_src_10026.bookings_monthly) AS bookings_last_month FROM ( -- Date Spine SELECT @@ -20,9 +20,9 @@ FROM ( DATE_TRUNC('month', ds) ) subq_10 INNER JOIN - ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_10024 + ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_10026 ON - subq_10.metric_time__month - INTERVAL 1 month = DATE_TRUNC('month', bookings_monthly_source_src_10024.ds) + subq_10.metric_time__month - INTERVAL 1 month = DATE_TRUNC('month', bookings_monthly_source_src_10026.ds) GROUP BY subq_10.metric_time__month ) subq_15 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql index 5a98441f07..c064e30cd1 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql @@ -72,22 +72,22 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_monthly_source' SELECT - bookings_monthly_source_src_10024.bookings_monthly - , DATE_TRUNC('month', bookings_monthly_source_src_10024.ds) AS monthly_ds__month - , DATE_TRUNC('quarter', bookings_monthly_source_src_10024.ds) AS monthly_ds__quarter - , DATE_TRUNC('year', bookings_monthly_source_src_10024.ds) AS monthly_ds__year - , EXTRACT(year FROM bookings_monthly_source_src_10024.ds) AS monthly_ds__extract_year - , EXTRACT(quarter FROM bookings_monthly_source_src_10024.ds) AS monthly_ds__extract_quarter - , EXTRACT(month FROM bookings_monthly_source_src_10024.ds) AS monthly_ds__extract_month - , DATE_TRUNC('month', bookings_monthly_source_src_10024.ds) AS booking__monthly_ds__month - , DATE_TRUNC('quarter', bookings_monthly_source_src_10024.ds) AS booking__monthly_ds__quarter - , DATE_TRUNC('year', bookings_monthly_source_src_10024.ds) AS booking__monthly_ds__year - , EXTRACT(year FROM bookings_monthly_source_src_10024.ds) AS booking__monthly_ds__extract_year - , EXTRACT(quarter FROM bookings_monthly_source_src_10024.ds) AS booking__monthly_ds__extract_quarter - , EXTRACT(month FROM bookings_monthly_source_src_10024.ds) AS booking__monthly_ds__extract_month - , bookings_monthly_source_src_10024.listing_id AS listing - , bookings_monthly_source_src_10024.listing_id AS booking__listing - FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_10024 + bookings_monthly_source_src_10026.bookings_monthly + , DATE_TRUNC('month', bookings_monthly_source_src_10026.ds) AS monthly_ds__month + , DATE_TRUNC('quarter', bookings_monthly_source_src_10026.ds) AS monthly_ds__quarter + , DATE_TRUNC('year', bookings_monthly_source_src_10026.ds) AS monthly_ds__year + , EXTRACT(year FROM bookings_monthly_source_src_10026.ds) AS monthly_ds__extract_year + , EXTRACT(quarter FROM bookings_monthly_source_src_10026.ds) AS monthly_ds__extract_quarter + , EXTRACT(month FROM bookings_monthly_source_src_10026.ds) AS monthly_ds__extract_month + , DATE_TRUNC('month', bookings_monthly_source_src_10026.ds) AS booking__monthly_ds__month + , DATE_TRUNC('quarter', bookings_monthly_source_src_10026.ds) AS booking__monthly_ds__quarter + , DATE_TRUNC('year', bookings_monthly_source_src_10026.ds) AS booking__monthly_ds__year + , EXTRACT(year FROM bookings_monthly_source_src_10026.ds) AS booking__monthly_ds__extract_year + , EXTRACT(quarter FROM bookings_monthly_source_src_10026.ds) AS booking__monthly_ds__extract_quarter + , EXTRACT(month FROM bookings_monthly_source_src_10026.ds) AS booking__monthly_ds__extract_month + , bookings_monthly_source_src_10026.listing_id AS listing + , bookings_monthly_source_src_10026.listing_id AS booking__listing + FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_10026 ) subq_0 ) subq_1 ON diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql index 519a319f9a..88420281f4 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( -- Compute Metrics via Expressions SELECT subq_10.metric_time__month AS metric_time__month - , SUM(bookings_monthly_source_src_10024.bookings_monthly) AS bookings_last_month + , SUM(bookings_monthly_source_src_10026.bookings_monthly) AS bookings_last_month FROM ( -- Date Spine SELECT @@ -20,9 +20,9 @@ FROM ( DATE_TRUNC('month', ds) ) subq_10 INNER JOIN - ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_10024 + ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_10026 ON - subq_10.metric_time__month - MAKE_INTERVAL(months => 1) = DATE_TRUNC('month', bookings_monthly_source_src_10024.ds) + subq_10.metric_time__month - MAKE_INTERVAL(months => 1) = DATE_TRUNC('month', bookings_monthly_source_src_10026.ds) GROUP BY subq_10.metric_time__month ) subq_15 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql index 41ec0d45de..c19000cc02 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql @@ -72,22 +72,22 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_monthly_source' SELECT - bookings_monthly_source_src_10024.bookings_monthly - , DATE_TRUNC('month', bookings_monthly_source_src_10024.ds) AS monthly_ds__month - , DATE_TRUNC('quarter', bookings_monthly_source_src_10024.ds) AS monthly_ds__quarter - , DATE_TRUNC('year', bookings_monthly_source_src_10024.ds) AS monthly_ds__year - , EXTRACT(year FROM bookings_monthly_source_src_10024.ds) AS monthly_ds__extract_year - , EXTRACT(quarter FROM bookings_monthly_source_src_10024.ds) AS monthly_ds__extract_quarter - , EXTRACT(month FROM bookings_monthly_source_src_10024.ds) AS monthly_ds__extract_month - , DATE_TRUNC('month', bookings_monthly_source_src_10024.ds) AS booking__monthly_ds__month - , DATE_TRUNC('quarter', bookings_monthly_source_src_10024.ds) AS booking__monthly_ds__quarter - , DATE_TRUNC('year', bookings_monthly_source_src_10024.ds) AS booking__monthly_ds__year - , EXTRACT(year FROM bookings_monthly_source_src_10024.ds) AS booking__monthly_ds__extract_year - , EXTRACT(quarter FROM bookings_monthly_source_src_10024.ds) AS booking__monthly_ds__extract_quarter - , EXTRACT(month FROM bookings_monthly_source_src_10024.ds) AS booking__monthly_ds__extract_month - , bookings_monthly_source_src_10024.listing_id AS listing - , bookings_monthly_source_src_10024.listing_id AS booking__listing - FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_10024 + bookings_monthly_source_src_10026.bookings_monthly + , DATE_TRUNC('month', bookings_monthly_source_src_10026.ds) AS monthly_ds__month + , DATE_TRUNC('quarter', bookings_monthly_source_src_10026.ds) AS monthly_ds__quarter + , DATE_TRUNC('year', bookings_monthly_source_src_10026.ds) AS monthly_ds__year + , EXTRACT(year FROM bookings_monthly_source_src_10026.ds) AS monthly_ds__extract_year + , EXTRACT(quarter FROM bookings_monthly_source_src_10026.ds) AS monthly_ds__extract_quarter + , EXTRACT(month FROM bookings_monthly_source_src_10026.ds) AS monthly_ds__extract_month + , DATE_TRUNC('month', bookings_monthly_source_src_10026.ds) AS booking__monthly_ds__month + , DATE_TRUNC('quarter', bookings_monthly_source_src_10026.ds) AS booking__monthly_ds__quarter + , DATE_TRUNC('year', bookings_monthly_source_src_10026.ds) AS booking__monthly_ds__year + , EXTRACT(year FROM bookings_monthly_source_src_10026.ds) AS booking__monthly_ds__extract_year + , EXTRACT(quarter FROM bookings_monthly_source_src_10026.ds) AS booking__monthly_ds__extract_quarter + , EXTRACT(month FROM bookings_monthly_source_src_10026.ds) AS booking__monthly_ds__extract_month + , bookings_monthly_source_src_10026.listing_id AS listing + , bookings_monthly_source_src_10026.listing_id AS booking__listing + FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_10026 ) subq_0 ) subq_1 ON diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql index d0d550e6d3..b7a5485c92 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( -- Compute Metrics via Expressions SELECT subq_10.metric_time__month AS metric_time__month - , SUM(bookings_monthly_source_src_10024.bookings_monthly) AS bookings_last_month + , SUM(bookings_monthly_source_src_10026.bookings_monthly) AS bookings_last_month FROM ( -- Date Spine SELECT @@ -20,9 +20,9 @@ FROM ( DATE_TRUNC('month', ds) ) subq_10 INNER JOIN - ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_10024 + ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_10026 ON - DATEADD(month, -1, subq_10.metric_time__month) = DATE_TRUNC('month', bookings_monthly_source_src_10024.ds) + DATEADD(month, -1, subq_10.metric_time__month) = DATE_TRUNC('month', bookings_monthly_source_src_10026.ds) GROUP BY subq_10.metric_time__month ) subq_15 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql index 41ec0d45de..c19000cc02 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql @@ -72,22 +72,22 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_monthly_source' SELECT - bookings_monthly_source_src_10024.bookings_monthly - , DATE_TRUNC('month', bookings_monthly_source_src_10024.ds) AS monthly_ds__month - , DATE_TRUNC('quarter', bookings_monthly_source_src_10024.ds) AS monthly_ds__quarter - , DATE_TRUNC('year', bookings_monthly_source_src_10024.ds) AS monthly_ds__year - , EXTRACT(year FROM bookings_monthly_source_src_10024.ds) AS monthly_ds__extract_year - , EXTRACT(quarter FROM bookings_monthly_source_src_10024.ds) AS monthly_ds__extract_quarter - , EXTRACT(month FROM bookings_monthly_source_src_10024.ds) AS monthly_ds__extract_month - , DATE_TRUNC('month', bookings_monthly_source_src_10024.ds) AS booking__monthly_ds__month - , DATE_TRUNC('quarter', bookings_monthly_source_src_10024.ds) AS booking__monthly_ds__quarter - , DATE_TRUNC('year', bookings_monthly_source_src_10024.ds) AS booking__monthly_ds__year - , EXTRACT(year FROM bookings_monthly_source_src_10024.ds) AS booking__monthly_ds__extract_year - , EXTRACT(quarter FROM bookings_monthly_source_src_10024.ds) AS booking__monthly_ds__extract_quarter - , EXTRACT(month FROM bookings_monthly_source_src_10024.ds) AS booking__monthly_ds__extract_month - , bookings_monthly_source_src_10024.listing_id AS listing - , bookings_monthly_source_src_10024.listing_id AS booking__listing - FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_10024 + bookings_monthly_source_src_10026.bookings_monthly + , DATE_TRUNC('month', bookings_monthly_source_src_10026.ds) AS monthly_ds__month + , DATE_TRUNC('quarter', bookings_monthly_source_src_10026.ds) AS monthly_ds__quarter + , DATE_TRUNC('year', bookings_monthly_source_src_10026.ds) AS monthly_ds__year + , EXTRACT(year FROM bookings_monthly_source_src_10026.ds) AS monthly_ds__extract_year + , EXTRACT(quarter FROM bookings_monthly_source_src_10026.ds) AS monthly_ds__extract_quarter + , EXTRACT(month FROM bookings_monthly_source_src_10026.ds) AS monthly_ds__extract_month + , DATE_TRUNC('month', bookings_monthly_source_src_10026.ds) AS booking__monthly_ds__month + , DATE_TRUNC('quarter', bookings_monthly_source_src_10026.ds) AS booking__monthly_ds__quarter + , DATE_TRUNC('year', bookings_monthly_source_src_10026.ds) AS booking__monthly_ds__year + , EXTRACT(year FROM bookings_monthly_source_src_10026.ds) AS booking__monthly_ds__extract_year + , EXTRACT(quarter FROM bookings_monthly_source_src_10026.ds) AS booking__monthly_ds__extract_quarter + , EXTRACT(month FROM bookings_monthly_source_src_10026.ds) AS booking__monthly_ds__extract_month + , bookings_monthly_source_src_10026.listing_id AS listing + , bookings_monthly_source_src_10026.listing_id AS booking__listing + FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_10026 ) subq_0 ) subq_1 ON diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql index d0d550e6d3..b7a5485c92 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( -- Compute Metrics via Expressions SELECT subq_10.metric_time__month AS metric_time__month - , SUM(bookings_monthly_source_src_10024.bookings_monthly) AS bookings_last_month + , SUM(bookings_monthly_source_src_10026.bookings_monthly) AS bookings_last_month FROM ( -- Date Spine SELECT @@ -20,9 +20,9 @@ FROM ( DATE_TRUNC('month', ds) ) subq_10 INNER JOIN - ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_10024 + ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_10026 ON - DATEADD(month, -1, subq_10.metric_time__month) = DATE_TRUNC('month', bookings_monthly_source_src_10024.ds) + DATEADD(month, -1, subq_10.metric_time__month) = DATE_TRUNC('month', bookings_monthly_source_src_10026.ds) GROUP BY subq_10.metric_time__month ) subq_15 diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimension_values_with_a_join_and_a_filter__plan0.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimension_values_with_a_join_and_a_filter__plan0.sql index e789be29d6..9d3c09b14e 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimension_values_with_a_join_and_a_filter__plan0.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimension_values_with_a_join_and_a_filter__plan0.sql @@ -127,62 +127,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: @@ -193,32 +193,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC(users_latest_src_10008.ds, day) AS ds_latest__day - , DATE_TRUNC(users_latest_src_10008.ds, isoweek) AS ds_latest__week - , DATE_TRUNC(users_latest_src_10008.ds, month) AS ds_latest__month - , DATE_TRUNC(users_latest_src_10008.ds, quarter) AS ds_latest__quarter - , DATE_TRUNC(users_latest_src_10008.ds, year) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS ds_latest__extract_day - , IF(EXTRACT(dayofweek FROM users_latest_src_10008.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_10008.ds) - 1) AS ds_latest__extract_dow - , EXTRACT(dayofyear FROM users_latest_src_10008.ds) AS ds_latest__extract_doy - , users_latest_src_10008.home_state_latest - , DATE_TRUNC(users_latest_src_10008.ds, day) AS user__ds_latest__day - , DATE_TRUNC(users_latest_src_10008.ds, isoweek) AS user__ds_latest__week - , DATE_TRUNC(users_latest_src_10008.ds, month) AS user__ds_latest__month - , DATE_TRUNC(users_latest_src_10008.ds, quarter) AS user__ds_latest__quarter - , DATE_TRUNC(users_latest_src_10008.ds, year) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS user__ds_latest__extract_day - , IF(EXTRACT(dayofweek FROM users_latest_src_10008.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_10008.ds) - 1) AS user__ds_latest__extract_dow - , EXTRACT(dayofyear FROM users_latest_src_10008.ds) AS user__ds_latest__extract_doy - , users_latest_src_10008.home_state_latest AS user__home_state_latest - , users_latest_src_10008.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_10008 + DATE_TRUNC(users_latest_src_10009.ds, day) AS ds_latest__day + , DATE_TRUNC(users_latest_src_10009.ds, isoweek) AS ds_latest__week + , DATE_TRUNC(users_latest_src_10009.ds, month) AS ds_latest__month + , DATE_TRUNC(users_latest_src_10009.ds, quarter) AS ds_latest__quarter + , DATE_TRUNC(users_latest_src_10009.ds, year) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS ds_latest__extract_day + , IF(EXTRACT(dayofweek FROM users_latest_src_10009.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_10009.ds) - 1) AS ds_latest__extract_dow + , EXTRACT(dayofyear FROM users_latest_src_10009.ds) AS ds_latest__extract_doy + , users_latest_src_10009.home_state_latest + , DATE_TRUNC(users_latest_src_10009.ds, day) AS user__ds_latest__day + , DATE_TRUNC(users_latest_src_10009.ds, isoweek) AS user__ds_latest__week + , DATE_TRUNC(users_latest_src_10009.ds, month) AS user__ds_latest__month + , DATE_TRUNC(users_latest_src_10009.ds, quarter) AS user__ds_latest__quarter + , DATE_TRUNC(users_latest_src_10009.ds, year) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS user__ds_latest__extract_day + , IF(EXTRACT(dayofweek FROM users_latest_src_10009.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_10009.ds) - 1) AS user__ds_latest__extract_dow + , EXTRACT(dayofyear FROM users_latest_src_10009.ds) AS user__ds_latest__extract_doy + , users_latest_src_10009.home_state_latest AS user__home_state_latest + , users_latest_src_10009.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_10009 ) subq_1 ) subq_2 ON diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql index 3d0526ebb2..533b86774d 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql @@ -7,13 +7,13 @@ SELECT FROM ( -- Join Standard Outputs SELECT - listings_latest_src_10004.is_lux AS listing__is_lux_latest - , users_latest_src_10008.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings_latest listings_latest_src_10004 + listings_latest_src_10005.is_lux AS listing__is_lux_latest + , users_latest_src_10009.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings_latest listings_latest_src_10005 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_10008 + ***************************.dim_users_latest users_latest_src_10009 ON - listings_latest_src_10004.user_id = users_latest_src_10008.user_id + listings_latest_src_10005.user_id = users_latest_src_10009.user_id ) subq_8 WHERE user__home_state_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimensions_requiring_join__plan0.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimensions_requiring_join__plan0.sql index 20ea6ad5b2..b06d4edf2e 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimensions_requiring_join__plan0.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimensions_requiring_join__plan0.sql @@ -67,62 +67,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: @@ -133,32 +133,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC(users_latest_src_10008.ds, day) AS ds_latest__day - , DATE_TRUNC(users_latest_src_10008.ds, isoweek) AS ds_latest__week - , DATE_TRUNC(users_latest_src_10008.ds, month) AS ds_latest__month - , DATE_TRUNC(users_latest_src_10008.ds, quarter) AS ds_latest__quarter - , DATE_TRUNC(users_latest_src_10008.ds, year) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS ds_latest__extract_day - , IF(EXTRACT(dayofweek FROM users_latest_src_10008.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_10008.ds) - 1) AS ds_latest__extract_dow - , EXTRACT(dayofyear FROM users_latest_src_10008.ds) AS ds_latest__extract_doy - , users_latest_src_10008.home_state_latest - , DATE_TRUNC(users_latest_src_10008.ds, day) AS user__ds_latest__day - , DATE_TRUNC(users_latest_src_10008.ds, isoweek) AS user__ds_latest__week - , DATE_TRUNC(users_latest_src_10008.ds, month) AS user__ds_latest__month - , DATE_TRUNC(users_latest_src_10008.ds, quarter) AS user__ds_latest__quarter - , DATE_TRUNC(users_latest_src_10008.ds, year) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS user__ds_latest__extract_day - , IF(EXTRACT(dayofweek FROM users_latest_src_10008.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_10008.ds) - 1) AS user__ds_latest__extract_dow - , EXTRACT(dayofyear FROM users_latest_src_10008.ds) AS user__ds_latest__extract_doy - , users_latest_src_10008.home_state_latest AS user__home_state_latest - , users_latest_src_10008.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_10008 + DATE_TRUNC(users_latest_src_10009.ds, day) AS ds_latest__day + , DATE_TRUNC(users_latest_src_10009.ds, isoweek) AS ds_latest__week + , DATE_TRUNC(users_latest_src_10009.ds, month) AS ds_latest__month + , DATE_TRUNC(users_latest_src_10009.ds, quarter) AS ds_latest__quarter + , DATE_TRUNC(users_latest_src_10009.ds, year) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS ds_latest__extract_day + , IF(EXTRACT(dayofweek FROM users_latest_src_10009.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_10009.ds) - 1) AS ds_latest__extract_dow + , EXTRACT(dayofyear FROM users_latest_src_10009.ds) AS ds_latest__extract_doy + , users_latest_src_10009.home_state_latest + , DATE_TRUNC(users_latest_src_10009.ds, day) AS user__ds_latest__day + , DATE_TRUNC(users_latest_src_10009.ds, isoweek) AS user__ds_latest__week + , DATE_TRUNC(users_latest_src_10009.ds, month) AS user__ds_latest__month + , DATE_TRUNC(users_latest_src_10009.ds, quarter) AS user__ds_latest__quarter + , DATE_TRUNC(users_latest_src_10009.ds, year) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS user__ds_latest__extract_day + , IF(EXTRACT(dayofweek FROM users_latest_src_10009.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_10009.ds) - 1) AS user__ds_latest__extract_dow + , EXTRACT(dayofyear FROM users_latest_src_10009.ds) AS user__ds_latest__extract_doy + , users_latest_src_10009.home_state_latest AS user__home_state_latest + , users_latest_src_10009.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_10009 ) subq_1 ) subq_2 ON diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimensions_requiring_join__plan0_optimized.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimensions_requiring_join__plan0_optimized.sql index 0d442e4a0f..52bb1235c2 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimensions_requiring_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimensions_requiring_join__plan0_optimized.sql @@ -2,13 +2,13 @@ -- Pass Only Elements: -- ['user__home_state_latest', 'listing__is_lux_latest'] SELECT - listings_latest_src_10004.is_lux AS listing__is_lux_latest - , users_latest_src_10008.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_10004 + listings_latest_src_10005.is_lux AS listing__is_lux_latest + , users_latest_src_10009.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_10005 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_10008 + ***************************.dim_users_latest users_latest_src_10009 ON - listings_latest_src_10004.user_id = users_latest_src_10008.user_id + listings_latest_src_10005.user_id = users_latest_src_10009.user_id GROUP BY listing__is_lux_latest , user__home_state_latest diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimension_values_with_a_join_and_a_filter__plan0.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimension_values_with_a_join_and_a_filter__plan0.sql index 68cefdd899..6657922bea 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimension_values_with_a_join_and_a_filter__plan0.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimension_values_with_a_join_and_a_filter__plan0.sql @@ -127,62 +127,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: @@ -193,32 +193,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_10008.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS ds_latest__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_10008.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS ds_latest__extract_doy - , users_latest_src_10008.home_state_latest - , DATE_TRUNC('day', users_latest_src_10008.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS user__ds_latest__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_10008.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS user__ds_latest__extract_doy - , users_latest_src_10008.home_state_latest AS user__home_state_latest - , users_latest_src_10008.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_10008 + DATE_TRUNC('day', users_latest_src_10009.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS ds_latest__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_10009.ds) AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS ds_latest__extract_doy + , users_latest_src_10009.home_state_latest + , DATE_TRUNC('day', users_latest_src_10009.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS user__ds_latest__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_10009.ds) AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS user__ds_latest__extract_doy + , users_latest_src_10009.home_state_latest AS user__home_state_latest + , users_latest_src_10009.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_10009 ) subq_1 ) subq_2 ON diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql index 3d0526ebb2..533b86774d 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql @@ -7,13 +7,13 @@ SELECT FROM ( -- Join Standard Outputs SELECT - listings_latest_src_10004.is_lux AS listing__is_lux_latest - , users_latest_src_10008.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings_latest listings_latest_src_10004 + listings_latest_src_10005.is_lux AS listing__is_lux_latest + , users_latest_src_10009.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings_latest listings_latest_src_10005 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_10008 + ***************************.dim_users_latest users_latest_src_10009 ON - listings_latest_src_10004.user_id = users_latest_src_10008.user_id + listings_latest_src_10005.user_id = users_latest_src_10009.user_id ) subq_8 WHERE user__home_state_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimensions_requiring_join__plan0.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimensions_requiring_join__plan0.sql index 58cf6dadca..8b4db45da4 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimensions_requiring_join__plan0.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimensions_requiring_join__plan0.sql @@ -67,62 +67,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: @@ -133,32 +133,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_10008.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS ds_latest__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_10008.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS ds_latest__extract_doy - , users_latest_src_10008.home_state_latest - , DATE_TRUNC('day', users_latest_src_10008.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS user__ds_latest__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_10008.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS user__ds_latest__extract_doy - , users_latest_src_10008.home_state_latest AS user__home_state_latest - , users_latest_src_10008.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_10008 + DATE_TRUNC('day', users_latest_src_10009.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS ds_latest__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_10009.ds) AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS ds_latest__extract_doy + , users_latest_src_10009.home_state_latest + , DATE_TRUNC('day', users_latest_src_10009.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS user__ds_latest__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_10009.ds) AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS user__ds_latest__extract_doy + , users_latest_src_10009.home_state_latest AS user__home_state_latest + , users_latest_src_10009.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_10009 ) subq_1 ) subq_2 ON diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimensions_requiring_join__plan0_optimized.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimensions_requiring_join__plan0_optimized.sql index 4bf3539984..7f093b6070 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimensions_requiring_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimensions_requiring_join__plan0_optimized.sql @@ -2,13 +2,13 @@ -- Pass Only Elements: -- ['user__home_state_latest', 'listing__is_lux_latest'] SELECT - listings_latest_src_10004.is_lux AS listing__is_lux_latest - , users_latest_src_10008.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_10004 + listings_latest_src_10005.is_lux AS listing__is_lux_latest + , users_latest_src_10009.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_10005 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_10008 + ***************************.dim_users_latest users_latest_src_10009 ON - listings_latest_src_10004.user_id = users_latest_src_10008.user_id + listings_latest_src_10005.user_id = users_latest_src_10009.user_id GROUP BY - listings_latest_src_10004.is_lux - , users_latest_src_10008.home_state_latest + listings_latest_src_10005.is_lux + , users_latest_src_10009.home_state_latest diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimension_values_with_a_join_and_a_filter__plan0.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimension_values_with_a_join_and_a_filter__plan0.sql index 09d4611a5c..2574c8a32a 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimension_values_with_a_join_and_a_filter__plan0.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimension_values_with_a_join_and_a_filter__plan0.sql @@ -127,62 +127,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: @@ -193,32 +193,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_10008.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_10008.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS ds_latest__extract_doy - , users_latest_src_10008.home_state_latest - , DATE_TRUNC('day', users_latest_src_10008.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS user__ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_10008.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS user__ds_latest__extract_doy - , users_latest_src_10008.home_state_latest AS user__home_state_latest - , users_latest_src_10008.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_10008 + DATE_TRUNC('day', users_latest_src_10009.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS ds_latest__extract_day + , EXTRACT(isodow FROM users_latest_src_10009.ds) AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS ds_latest__extract_doy + , users_latest_src_10009.home_state_latest + , DATE_TRUNC('day', users_latest_src_10009.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS user__ds_latest__extract_day + , EXTRACT(isodow FROM users_latest_src_10009.ds) AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS user__ds_latest__extract_doy + , users_latest_src_10009.home_state_latest AS user__home_state_latest + , users_latest_src_10009.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_10009 ) subq_1 ) subq_2 ON diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql index 3d0526ebb2..533b86774d 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql @@ -7,13 +7,13 @@ SELECT FROM ( -- Join Standard Outputs SELECT - listings_latest_src_10004.is_lux AS listing__is_lux_latest - , users_latest_src_10008.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings_latest listings_latest_src_10004 + listings_latest_src_10005.is_lux AS listing__is_lux_latest + , users_latest_src_10009.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings_latest listings_latest_src_10005 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_10008 + ***************************.dim_users_latest users_latest_src_10009 ON - listings_latest_src_10004.user_id = users_latest_src_10008.user_id + listings_latest_src_10005.user_id = users_latest_src_10009.user_id ) subq_8 WHERE user__home_state_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimensions_requiring_join__plan0.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimensions_requiring_join__plan0.sql index 4ffc0ed119..dd31fb79f8 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimensions_requiring_join__plan0.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimensions_requiring_join__plan0.sql @@ -67,62 +67,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: @@ -133,32 +133,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_10008.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_10008.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS ds_latest__extract_doy - , users_latest_src_10008.home_state_latest - , DATE_TRUNC('day', users_latest_src_10008.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS user__ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_10008.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS user__ds_latest__extract_doy - , users_latest_src_10008.home_state_latest AS user__home_state_latest - , users_latest_src_10008.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_10008 + DATE_TRUNC('day', users_latest_src_10009.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS ds_latest__extract_day + , EXTRACT(isodow FROM users_latest_src_10009.ds) AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS ds_latest__extract_doy + , users_latest_src_10009.home_state_latest + , DATE_TRUNC('day', users_latest_src_10009.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS user__ds_latest__extract_day + , EXTRACT(isodow FROM users_latest_src_10009.ds) AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS user__ds_latest__extract_doy + , users_latest_src_10009.home_state_latest AS user__home_state_latest + , users_latest_src_10009.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_10009 ) subq_1 ) subq_2 ON diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimensions_requiring_join__plan0_optimized.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimensions_requiring_join__plan0_optimized.sql index 4bf3539984..7f093b6070 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimensions_requiring_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimensions_requiring_join__plan0_optimized.sql @@ -2,13 +2,13 @@ -- Pass Only Elements: -- ['user__home_state_latest', 'listing__is_lux_latest'] SELECT - listings_latest_src_10004.is_lux AS listing__is_lux_latest - , users_latest_src_10008.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_10004 + listings_latest_src_10005.is_lux AS listing__is_lux_latest + , users_latest_src_10009.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_10005 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_10008 + ***************************.dim_users_latest users_latest_src_10009 ON - listings_latest_src_10004.user_id = users_latest_src_10008.user_id + listings_latest_src_10005.user_id = users_latest_src_10009.user_id GROUP BY - listings_latest_src_10004.is_lux - , users_latest_src_10008.home_state_latest + listings_latest_src_10005.is_lux + , users_latest_src_10009.home_state_latest diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimension_values_with_a_join_and_a_filter__plan0.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimension_values_with_a_join_and_a_filter__plan0.sql index 09d4611a5c..2574c8a32a 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimension_values_with_a_join_and_a_filter__plan0.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimension_values_with_a_join_and_a_filter__plan0.sql @@ -127,62 +127,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: @@ -193,32 +193,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_10008.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_10008.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS ds_latest__extract_doy - , users_latest_src_10008.home_state_latest - , DATE_TRUNC('day', users_latest_src_10008.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS user__ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_10008.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS user__ds_latest__extract_doy - , users_latest_src_10008.home_state_latest AS user__home_state_latest - , users_latest_src_10008.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_10008 + DATE_TRUNC('day', users_latest_src_10009.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS ds_latest__extract_day + , EXTRACT(isodow FROM users_latest_src_10009.ds) AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS ds_latest__extract_doy + , users_latest_src_10009.home_state_latest + , DATE_TRUNC('day', users_latest_src_10009.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS user__ds_latest__extract_day + , EXTRACT(isodow FROM users_latest_src_10009.ds) AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS user__ds_latest__extract_doy + , users_latest_src_10009.home_state_latest AS user__home_state_latest + , users_latest_src_10009.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_10009 ) subq_1 ) subq_2 ON diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql index 3d0526ebb2..533b86774d 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql @@ -7,13 +7,13 @@ SELECT FROM ( -- Join Standard Outputs SELECT - listings_latest_src_10004.is_lux AS listing__is_lux_latest - , users_latest_src_10008.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings_latest listings_latest_src_10004 + listings_latest_src_10005.is_lux AS listing__is_lux_latest + , users_latest_src_10009.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings_latest listings_latest_src_10005 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_10008 + ***************************.dim_users_latest users_latest_src_10009 ON - listings_latest_src_10004.user_id = users_latest_src_10008.user_id + listings_latest_src_10005.user_id = users_latest_src_10009.user_id ) subq_8 WHERE user__home_state_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimensions_requiring_join__plan0.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimensions_requiring_join__plan0.sql index 4ffc0ed119..dd31fb79f8 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimensions_requiring_join__plan0.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimensions_requiring_join__plan0.sql @@ -67,62 +67,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: @@ -133,32 +133,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_10008.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_10008.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS ds_latest__extract_doy - , users_latest_src_10008.home_state_latest - , DATE_TRUNC('day', users_latest_src_10008.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS user__ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_10008.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS user__ds_latest__extract_doy - , users_latest_src_10008.home_state_latest AS user__home_state_latest - , users_latest_src_10008.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_10008 + DATE_TRUNC('day', users_latest_src_10009.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS ds_latest__extract_day + , EXTRACT(isodow FROM users_latest_src_10009.ds) AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS ds_latest__extract_doy + , users_latest_src_10009.home_state_latest + , DATE_TRUNC('day', users_latest_src_10009.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS user__ds_latest__extract_day + , EXTRACT(isodow FROM users_latest_src_10009.ds) AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS user__ds_latest__extract_doy + , users_latest_src_10009.home_state_latest AS user__home_state_latest + , users_latest_src_10009.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_10009 ) subq_1 ) subq_2 ON diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimensions_requiring_join__plan0_optimized.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimensions_requiring_join__plan0_optimized.sql index 4bf3539984..7f093b6070 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimensions_requiring_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimensions_requiring_join__plan0_optimized.sql @@ -2,13 +2,13 @@ -- Pass Only Elements: -- ['user__home_state_latest', 'listing__is_lux_latest'] SELECT - listings_latest_src_10004.is_lux AS listing__is_lux_latest - , users_latest_src_10008.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_10004 + listings_latest_src_10005.is_lux AS listing__is_lux_latest + , users_latest_src_10009.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_10005 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_10008 + ***************************.dim_users_latest users_latest_src_10009 ON - listings_latest_src_10004.user_id = users_latest_src_10008.user_id + listings_latest_src_10005.user_id = users_latest_src_10009.user_id GROUP BY - listings_latest_src_10004.is_lux - , users_latest_src_10008.home_state_latest + listings_latest_src_10005.is_lux + , users_latest_src_10009.home_state_latest diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimension_values_with_a_join_and_a_filter__plan0.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimension_values_with_a_join_and_a_filter__plan0.sql index 7c513423a1..69f81f0060 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimension_values_with_a_join_and_a_filter__plan0.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimension_values_with_a_join_and_a_filter__plan0.sql @@ -127,62 +127,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: @@ -193,32 +193,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_10008.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS ds_latest__extract_day - , CASE WHEN EXTRACT(dow FROM users_latest_src_10008.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_10008.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_10008.ds) END AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS ds_latest__extract_doy - , users_latest_src_10008.home_state_latest - , DATE_TRUNC('day', users_latest_src_10008.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS user__ds_latest__extract_day - , CASE WHEN EXTRACT(dow FROM users_latest_src_10008.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_10008.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_10008.ds) END AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS user__ds_latest__extract_doy - , users_latest_src_10008.home_state_latest AS user__home_state_latest - , users_latest_src_10008.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_10008 + DATE_TRUNC('day', users_latest_src_10009.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS ds_latest__extract_day + , CASE WHEN EXTRACT(dow FROM users_latest_src_10009.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_10009.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_10009.ds) END AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS ds_latest__extract_doy + , users_latest_src_10009.home_state_latest + , DATE_TRUNC('day', users_latest_src_10009.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS user__ds_latest__extract_day + , CASE WHEN EXTRACT(dow FROM users_latest_src_10009.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_10009.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_10009.ds) END AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS user__ds_latest__extract_doy + , users_latest_src_10009.home_state_latest AS user__home_state_latest + , users_latest_src_10009.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_10009 ) subq_1 ) subq_2 ON diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql index 3d0526ebb2..533b86774d 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql @@ -7,13 +7,13 @@ SELECT FROM ( -- Join Standard Outputs SELECT - listings_latest_src_10004.is_lux AS listing__is_lux_latest - , users_latest_src_10008.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings_latest listings_latest_src_10004 + listings_latest_src_10005.is_lux AS listing__is_lux_latest + , users_latest_src_10009.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings_latest listings_latest_src_10005 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_10008 + ***************************.dim_users_latest users_latest_src_10009 ON - listings_latest_src_10004.user_id = users_latest_src_10008.user_id + listings_latest_src_10005.user_id = users_latest_src_10009.user_id ) subq_8 WHERE user__home_state_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimensions_requiring_join__plan0.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimensions_requiring_join__plan0.sql index c484b698c8..e4e43fac32 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimensions_requiring_join__plan0.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimensions_requiring_join__plan0.sql @@ -67,62 +67,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: @@ -133,32 +133,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_10008.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS ds_latest__extract_day - , CASE WHEN EXTRACT(dow FROM users_latest_src_10008.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_10008.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_10008.ds) END AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS ds_latest__extract_doy - , users_latest_src_10008.home_state_latest - , DATE_TRUNC('day', users_latest_src_10008.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS user__ds_latest__extract_day - , CASE WHEN EXTRACT(dow FROM users_latest_src_10008.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_10008.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_10008.ds) END AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS user__ds_latest__extract_doy - , users_latest_src_10008.home_state_latest AS user__home_state_latest - , users_latest_src_10008.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_10008 + DATE_TRUNC('day', users_latest_src_10009.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS ds_latest__extract_day + , CASE WHEN EXTRACT(dow FROM users_latest_src_10009.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_10009.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_10009.ds) END AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS ds_latest__extract_doy + , users_latest_src_10009.home_state_latest + , DATE_TRUNC('day', users_latest_src_10009.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS user__ds_latest__extract_day + , CASE WHEN EXTRACT(dow FROM users_latest_src_10009.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_10009.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_10009.ds) END AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS user__ds_latest__extract_doy + , users_latest_src_10009.home_state_latest AS user__home_state_latest + , users_latest_src_10009.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_10009 ) subq_1 ) subq_2 ON diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimensions_requiring_join__plan0_optimized.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimensions_requiring_join__plan0_optimized.sql index 4bf3539984..7f093b6070 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimensions_requiring_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimensions_requiring_join__plan0_optimized.sql @@ -2,13 +2,13 @@ -- Pass Only Elements: -- ['user__home_state_latest', 'listing__is_lux_latest'] SELECT - listings_latest_src_10004.is_lux AS listing__is_lux_latest - , users_latest_src_10008.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_10004 + listings_latest_src_10005.is_lux AS listing__is_lux_latest + , users_latest_src_10009.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_10005 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_10008 + ***************************.dim_users_latest users_latest_src_10009 ON - listings_latest_src_10004.user_id = users_latest_src_10008.user_id + listings_latest_src_10005.user_id = users_latest_src_10009.user_id GROUP BY - listings_latest_src_10004.is_lux - , users_latest_src_10008.home_state_latest + listings_latest_src_10005.is_lux + , users_latest_src_10009.home_state_latest diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimension_values_with_a_join_and_a_filter__plan0.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimension_values_with_a_join_and_a_filter__plan0.sql index fd366a79c8..a80e4be7e8 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimension_values_with_a_join_and_a_filter__plan0.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimension_values_with_a_join_and_a_filter__plan0.sql @@ -127,62 +127,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: @@ -193,32 +193,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_10008.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS ds_latest__extract_day - , EXTRACT(dayofweekiso FROM users_latest_src_10008.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS ds_latest__extract_doy - , users_latest_src_10008.home_state_latest - , DATE_TRUNC('day', users_latest_src_10008.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS user__ds_latest__extract_day - , EXTRACT(dayofweekiso FROM users_latest_src_10008.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS user__ds_latest__extract_doy - , users_latest_src_10008.home_state_latest AS user__home_state_latest - , users_latest_src_10008.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_10008 + DATE_TRUNC('day', users_latest_src_10009.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS ds_latest__extract_day + , EXTRACT(dayofweekiso FROM users_latest_src_10009.ds) AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS ds_latest__extract_doy + , users_latest_src_10009.home_state_latest + , DATE_TRUNC('day', users_latest_src_10009.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS user__ds_latest__extract_day + , EXTRACT(dayofweekiso FROM users_latest_src_10009.ds) AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS user__ds_latest__extract_doy + , users_latest_src_10009.home_state_latest AS user__home_state_latest + , users_latest_src_10009.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_10009 ) subq_1 ) subq_2 ON diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql index 3d0526ebb2..533b86774d 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql @@ -7,13 +7,13 @@ SELECT FROM ( -- Join Standard Outputs SELECT - listings_latest_src_10004.is_lux AS listing__is_lux_latest - , users_latest_src_10008.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings_latest listings_latest_src_10004 + listings_latest_src_10005.is_lux AS listing__is_lux_latest + , users_latest_src_10009.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings_latest listings_latest_src_10005 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_10008 + ***************************.dim_users_latest users_latest_src_10009 ON - listings_latest_src_10004.user_id = users_latest_src_10008.user_id + listings_latest_src_10005.user_id = users_latest_src_10009.user_id ) subq_8 WHERE user__home_state_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimensions_requiring_join__plan0.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimensions_requiring_join__plan0.sql index 2e9ea32b76..9de08f9d44 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimensions_requiring_join__plan0.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimensions_requiring_join__plan0.sql @@ -67,62 +67,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: @@ -133,32 +133,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_10008.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS ds_latest__extract_day - , EXTRACT(dayofweekiso FROM users_latest_src_10008.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS ds_latest__extract_doy - , users_latest_src_10008.home_state_latest - , DATE_TRUNC('day', users_latest_src_10008.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_10008.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_10008.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_10008.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_10008.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_10008.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_10008.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_10008.ds) AS user__ds_latest__extract_day - , EXTRACT(dayofweekiso FROM users_latest_src_10008.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_10008.ds) AS user__ds_latest__extract_doy - , users_latest_src_10008.home_state_latest AS user__home_state_latest - , users_latest_src_10008.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_10008 + DATE_TRUNC('day', users_latest_src_10009.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS ds_latest__extract_day + , EXTRACT(dayofweekiso FROM users_latest_src_10009.ds) AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS ds_latest__extract_doy + , users_latest_src_10009.home_state_latest + , DATE_TRUNC('day', users_latest_src_10009.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_10009.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_10009.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_10009.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_10009.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_10009.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_10009.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_10009.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_10009.ds) AS user__ds_latest__extract_day + , EXTRACT(dayofweekiso FROM users_latest_src_10009.ds) AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_10009.ds) AS user__ds_latest__extract_doy + , users_latest_src_10009.home_state_latest AS user__home_state_latest + , users_latest_src_10009.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_10009 ) subq_1 ) subq_2 ON diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimensions_requiring_join__plan0_optimized.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimensions_requiring_join__plan0_optimized.sql index 4bf3539984..7f093b6070 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimensions_requiring_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimensions_requiring_join__plan0_optimized.sql @@ -2,13 +2,13 @@ -- Pass Only Elements: -- ['user__home_state_latest', 'listing__is_lux_latest'] SELECT - listings_latest_src_10004.is_lux AS listing__is_lux_latest - , users_latest_src_10008.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_10004 + listings_latest_src_10005.is_lux AS listing__is_lux_latest + , users_latest_src_10009.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_10005 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_10008 + ***************************.dim_users_latest users_latest_src_10009 ON - listings_latest_src_10004.user_id = users_latest_src_10008.user_id + listings_latest_src_10005.user_id = users_latest_src_10009.user_id GROUP BY - listings_latest_src_10004.is_lux - , users_latest_src_10008.home_state_latest + listings_latest_src_10005.is_lux + , users_latest_src_10009.home_state_latest diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/test_dimension_values_with_a_join_and_a_filter__plan0.xml b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/test_dimension_values_with_a_join_and_a_filter__plan0.xml index 26d712d0f6..c33124d380 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/test_dimension_values_with_a_join_and_a_filter__plan0.xml +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/test_dimension_values_with_a_join_and_a_filter__plan0.xml @@ -489,7 +489,7 @@ - + @@ -500,237 +500,237 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -747,118 +747,118 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/test_dimensions_requiring_join__plan0.xml b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/test_dimensions_requiring_join__plan0.xml index 1eb6447fb4..ad8b624b68 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/test_dimensions_requiring_join__plan0.xml +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/test_dimensions_requiring_join__plan0.xml @@ -254,7 +254,7 @@ - + @@ -265,237 +265,237 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -512,118 +512,118 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/test_simple_query_with_metric_time_dimension__plan0.xml b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/test_simple_query_with_metric_time_dimension__plan0.xml index f10ffcaeb6..da17778ce3 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/test_simple_query_with_metric_time_dimension__plan0.xml +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/test_simple_query_with_metric_time_dimension__plan0.xml @@ -1,7 +1,7 @@ - + @@ -14,10 +14,10 @@ - + - + @@ -29,33 +29,33 @@ - + - + - + - + - + - + - + - + @@ -63,412 +63,412 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -843,33 +843,33 @@ - + - + - + - + - + - + - + - + @@ -877,364 +877,364 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_distinct_values__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_distinct_values__plan0.sql index aa785903ea..d9cab62c53 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_distinct_values__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_distinct_values__plan0.sql @@ -69,62 +69,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_0 WHERE listing__country_latest = 'us' ) subq_1 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_distinct_values__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_distinct_values__plan0_optimized.sql index ec0d94dac2..53c7bf823f 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_distinct_values__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_distinct_values__plan0_optimized.sql @@ -8,7 +8,7 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT country AS listing__country_latest - FROM ***************************.dim_listings_latest listings_latest_src_10004 + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_3 WHERE listing__country_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_on_join_dim__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_on_join_dim__plan0.sql index 024a941adf..befded4f2a 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_on_join_dim__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_on_join_dim__plan0.sql @@ -316,62 +316,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_3 ) subq_4 ) subq_5 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql index 19b1b78329..d00b32fb24 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql @@ -12,7 +12,7 @@ FROM ( -- ['bookings', 'booking__is_instant', 'listing__country_latest'] SELECT subq_13.booking__is_instant AS booking__is_instant - , listings_latest_src_10004.country AS listing__country_latest + , listings_latest_src_10005.country AS listing__country_latest , subq_13.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -26,9 +26,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_13 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_13.listing = listings_latest_src_10004.listing_id + subq_13.listing = listings_latest_src_10005.listing_id ) subq_18 WHERE listing__country_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_join_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_join_to_scd_dimension__plan0.sql index 82df597d7d..2f31bd939d 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_join_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_join_to_scd_dimension__plan0.sql @@ -142,87 +142,87 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_10015.booking_value - , bookings_source_src_10015.guest_id AS bookers - , bookings_source_src_10015.booking_value AS average_booking_value - , bookings_source_src_10015.booking_value AS booking_payments - , bookings_source_src_10015.is_instant - , DATE_TRUNC(bookings_source_src_10015.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_10015.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_10015.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_10015.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_10015.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_10015.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_10015.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_10015.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_10015.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_10015.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_10015.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_10015.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_10015.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_10015.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_10015.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_10015.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_10015.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_10015.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_10015.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_10015.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_10015.paid_at) AS paid_at__extract_doy - , bookings_source_src_10015.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_10015.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_10015.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_10015.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_10015.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_10015.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_10015.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_10015.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_10015.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_10015.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_10015.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_10015.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_10015.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_10015.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_10015.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_10015.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_10015.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_10015.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_10015.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_10015.listing_id AS listing - , bookings_source_src_10015.guest_id AS guest - , bookings_source_src_10015.host_id AS host - , bookings_source_src_10015.guest_id AS user - , bookings_source_src_10015.listing_id AS booking__listing - , bookings_source_src_10015.guest_id AS booking__guest - , bookings_source_src_10015.host_id AS booking__host - , bookings_source_src_10015.guest_id AS booking__user - FROM ***************************.fct_bookings bookings_source_src_10015 + , bookings_source_src_10017.booking_value + , bookings_source_src_10017.guest_id AS bookers + , bookings_source_src_10017.booking_value AS average_booking_value + , bookings_source_src_10017.booking_value AS booking_payments + , bookings_source_src_10017.is_instant + , DATE_TRUNC(bookings_source_src_10017.ds, day) AS ds__day + , DATE_TRUNC(bookings_source_src_10017.ds, isoweek) AS ds__week + , DATE_TRUNC(bookings_source_src_10017.ds, month) AS ds__month + , DATE_TRUNC(bookings_source_src_10017.ds, quarter) AS ds__quarter + , DATE_TRUNC(bookings_source_src_10017.ds, year) AS ds__year + , EXTRACT(year FROM bookings_source_src_10017.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_10017.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_10017.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_10017.ds) AS ds__extract_doy + , DATE_TRUNC(bookings_source_src_10017.ds_partitioned, day) AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10017.ds_partitioned, isoweek) AS ds_partitioned__week + , DATE_TRUNC(bookings_source_src_10017.ds_partitioned, month) AS ds_partitioned__month + , DATE_TRUNC(bookings_source_src_10017.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATE_TRUNC(bookings_source_src_10017.ds_partitioned, year) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_10017.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_10017.ds_partitioned) - 1) AS ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC(bookings_source_src_10017.paid_at, day) AS paid_at__day + , DATE_TRUNC(bookings_source_src_10017.paid_at, isoweek) AS paid_at__week + , DATE_TRUNC(bookings_source_src_10017.paid_at, month) AS paid_at__month + , DATE_TRUNC(bookings_source_src_10017.paid_at, quarter) AS paid_at__quarter + , DATE_TRUNC(bookings_source_src_10017.paid_at, year) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_10017.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_10017.paid_at) AS paid_at__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_10017.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_10017.paid_at) - 1) AS paid_at__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_10017.paid_at) AS paid_at__extract_doy + , bookings_source_src_10017.is_instant AS booking__is_instant + , DATE_TRUNC(bookings_source_src_10017.ds, day) AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10017.ds, isoweek) AS booking__ds__week + , DATE_TRUNC(bookings_source_src_10017.ds, month) AS booking__ds__month + , DATE_TRUNC(bookings_source_src_10017.ds, quarter) AS booking__ds__quarter + , DATE_TRUNC(bookings_source_src_10017.ds, year) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_10017.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds) AS booking__ds__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_10017.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_10017.ds) - 1) AS booking__ds__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_10017.ds) AS booking__ds__extract_doy + , DATE_TRUNC(bookings_source_src_10017.ds_partitioned, day) AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10017.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATE_TRUNC(bookings_source_src_10017.ds_partitioned, month) AS booking__ds_partitioned__month + , DATE_TRUNC(bookings_source_src_10017.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATE_TRUNC(bookings_source_src_10017.ds_partitioned, year) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_10017.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_10017.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC(bookings_source_src_10017.paid_at, day) AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10017.paid_at, isoweek) AS booking__paid_at__week + , DATE_TRUNC(bookings_source_src_10017.paid_at, month) AS booking__paid_at__month + , DATE_TRUNC(bookings_source_src_10017.paid_at, quarter) AS booking__paid_at__quarter + , DATE_TRUNC(bookings_source_src_10017.paid_at, year) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_10017.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_10017.paid_at) - 1) AS booking__paid_at__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_10017.listing_id AS listing + , bookings_source_src_10017.guest_id AS guest + , bookings_source_src_10017.host_id AS host + , bookings_source_src_10017.guest_id AS user + , bookings_source_src_10017.listing_id AS booking__listing + , bookings_source_src_10017.guest_id AS booking__guest + , bookings_source_src_10017.host_id AS booking__host + , bookings_source_src_10017.guest_id AS booking__user + FROM ***************************.fct_bookings bookings_source_src_10017 ) subq_0 ) subq_1 ) subq_2 @@ -237,60 +237,60 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'listings' SELECT - listings_src_10017.active_from AS window_start__day - , DATE_TRUNC(listings_src_10017.active_from, isoweek) AS window_start__week - , DATE_TRUNC(listings_src_10017.active_from, month) AS window_start__month - , DATE_TRUNC(listings_src_10017.active_from, quarter) AS window_start__quarter - , DATE_TRUNC(listings_src_10017.active_from, year) AS window_start__year - , EXTRACT(year FROM listings_src_10017.active_from) AS window_start__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_from) AS window_start__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_from) AS window_start__extract_month - , EXTRACT(day FROM listings_src_10017.active_from) AS window_start__extract_day - , IF(EXTRACT(dayofweek FROM listings_src_10017.active_from) = 1, 7, EXTRACT(dayofweek FROM listings_src_10017.active_from) - 1) AS window_start__extract_dow - , EXTRACT(dayofyear FROM listings_src_10017.active_from) AS window_start__extract_doy - , listings_src_10017.active_to AS window_end__day - , DATE_TRUNC(listings_src_10017.active_to, isoweek) AS window_end__week - , DATE_TRUNC(listings_src_10017.active_to, month) AS window_end__month - , DATE_TRUNC(listings_src_10017.active_to, quarter) AS window_end__quarter - , DATE_TRUNC(listings_src_10017.active_to, year) AS window_end__year - , EXTRACT(year FROM listings_src_10017.active_to) AS window_end__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_to) AS window_end__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_to) AS window_end__extract_month - , EXTRACT(day FROM listings_src_10017.active_to) AS window_end__extract_day - , IF(EXTRACT(dayofweek FROM listings_src_10017.active_to) = 1, 7, EXTRACT(dayofweek FROM listings_src_10017.active_to) - 1) AS window_end__extract_dow - , EXTRACT(dayofyear FROM listings_src_10017.active_to) AS window_end__extract_doy - , listings_src_10017.country - , listings_src_10017.is_lux - , listings_src_10017.capacity - , listings_src_10017.active_from AS listing__window_start__day - , DATE_TRUNC(listings_src_10017.active_from, isoweek) AS listing__window_start__week - , DATE_TRUNC(listings_src_10017.active_from, month) AS listing__window_start__month - , DATE_TRUNC(listings_src_10017.active_from, quarter) AS listing__window_start__quarter - , DATE_TRUNC(listings_src_10017.active_from, year) AS listing__window_start__year - , EXTRACT(year FROM listings_src_10017.active_from) AS listing__window_start__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_from) AS listing__window_start__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_from) AS listing__window_start__extract_month - , EXTRACT(day FROM listings_src_10017.active_from) AS listing__window_start__extract_day - , IF(EXTRACT(dayofweek FROM listings_src_10017.active_from) = 1, 7, EXTRACT(dayofweek FROM listings_src_10017.active_from) - 1) AS listing__window_start__extract_dow - , EXTRACT(dayofyear FROM listings_src_10017.active_from) AS listing__window_start__extract_doy - , listings_src_10017.active_to AS listing__window_end__day - , DATE_TRUNC(listings_src_10017.active_to, isoweek) AS listing__window_end__week - , DATE_TRUNC(listings_src_10017.active_to, month) AS listing__window_end__month - , DATE_TRUNC(listings_src_10017.active_to, quarter) AS listing__window_end__quarter - , DATE_TRUNC(listings_src_10017.active_to, year) AS listing__window_end__year - , EXTRACT(year FROM listings_src_10017.active_to) AS listing__window_end__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_to) AS listing__window_end__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_to) AS listing__window_end__extract_month - , EXTRACT(day FROM listings_src_10017.active_to) AS listing__window_end__extract_day - , IF(EXTRACT(dayofweek FROM listings_src_10017.active_to) = 1, 7, EXTRACT(dayofweek FROM listings_src_10017.active_to) - 1) AS listing__window_end__extract_dow - , EXTRACT(dayofyear FROM listings_src_10017.active_to) AS listing__window_end__extract_doy - , listings_src_10017.country AS listing__country - , listings_src_10017.is_lux AS listing__is_lux - , listings_src_10017.capacity AS listing__capacity - , listings_src_10017.listing_id AS listing - , listings_src_10017.user_id AS user - , listings_src_10017.user_id AS listing__user - FROM ***************************.dim_listings listings_src_10017 + listings_src_10019.active_from AS window_start__day + , DATE_TRUNC(listings_src_10019.active_from, isoweek) AS window_start__week + , DATE_TRUNC(listings_src_10019.active_from, month) AS window_start__month + , DATE_TRUNC(listings_src_10019.active_from, quarter) AS window_start__quarter + , DATE_TRUNC(listings_src_10019.active_from, year) AS window_start__year + , EXTRACT(year FROM listings_src_10019.active_from) AS window_start__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_from) AS window_start__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_from) AS window_start__extract_month + , EXTRACT(day FROM listings_src_10019.active_from) AS window_start__extract_day + , IF(EXTRACT(dayofweek FROM listings_src_10019.active_from) = 1, 7, EXTRACT(dayofweek FROM listings_src_10019.active_from) - 1) AS window_start__extract_dow + , EXTRACT(dayofyear FROM listings_src_10019.active_from) AS window_start__extract_doy + , listings_src_10019.active_to AS window_end__day + , DATE_TRUNC(listings_src_10019.active_to, isoweek) AS window_end__week + , DATE_TRUNC(listings_src_10019.active_to, month) AS window_end__month + , DATE_TRUNC(listings_src_10019.active_to, quarter) AS window_end__quarter + , DATE_TRUNC(listings_src_10019.active_to, year) AS window_end__year + , EXTRACT(year FROM listings_src_10019.active_to) AS window_end__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_to) AS window_end__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_to) AS window_end__extract_month + , EXTRACT(day FROM listings_src_10019.active_to) AS window_end__extract_day + , IF(EXTRACT(dayofweek FROM listings_src_10019.active_to) = 1, 7, EXTRACT(dayofweek FROM listings_src_10019.active_to) - 1) AS window_end__extract_dow + , EXTRACT(dayofyear FROM listings_src_10019.active_to) AS window_end__extract_doy + , listings_src_10019.country + , listings_src_10019.is_lux + , listings_src_10019.capacity + , listings_src_10019.active_from AS listing__window_start__day + , DATE_TRUNC(listings_src_10019.active_from, isoweek) AS listing__window_start__week + , DATE_TRUNC(listings_src_10019.active_from, month) AS listing__window_start__month + , DATE_TRUNC(listings_src_10019.active_from, quarter) AS listing__window_start__quarter + , DATE_TRUNC(listings_src_10019.active_from, year) AS listing__window_start__year + , EXTRACT(year FROM listings_src_10019.active_from) AS listing__window_start__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_from) AS listing__window_start__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_from) AS listing__window_start__extract_month + , EXTRACT(day FROM listings_src_10019.active_from) AS listing__window_start__extract_day + , IF(EXTRACT(dayofweek FROM listings_src_10019.active_from) = 1, 7, EXTRACT(dayofweek FROM listings_src_10019.active_from) - 1) AS listing__window_start__extract_dow + , EXTRACT(dayofyear FROM listings_src_10019.active_from) AS listing__window_start__extract_doy + , listings_src_10019.active_to AS listing__window_end__day + , DATE_TRUNC(listings_src_10019.active_to, isoweek) AS listing__window_end__week + , DATE_TRUNC(listings_src_10019.active_to, month) AS listing__window_end__month + , DATE_TRUNC(listings_src_10019.active_to, quarter) AS listing__window_end__quarter + , DATE_TRUNC(listings_src_10019.active_to, year) AS listing__window_end__year + , EXTRACT(year FROM listings_src_10019.active_to) AS listing__window_end__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_to) AS listing__window_end__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_to) AS listing__window_end__extract_month + , EXTRACT(day FROM listings_src_10019.active_to) AS listing__window_end__extract_day + , IF(EXTRACT(dayofweek FROM listings_src_10019.active_to) = 1, 7, EXTRACT(dayofweek FROM listings_src_10019.active_to) - 1) AS listing__window_end__extract_dow + , EXTRACT(dayofyear FROM listings_src_10019.active_to) AS listing__window_end__extract_doy + , listings_src_10019.country AS listing__country + , listings_src_10019.is_lux AS listing__is_lux + , listings_src_10019.capacity AS listing__capacity + , listings_src_10019.listing_id AS listing + , listings_src_10019.user_id AS user + , listings_src_10019.user_id AS listing__user + FROM ***************************.dim_listings listings_src_10019 ) subq_3 ) subq_4 ON diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_join_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_join_to_scd_dimension__plan0_optimized.sql index d9dff12ede..9edcd06ccc 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_join_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_join_to_scd_dimension__plan0_optimized.sql @@ -12,7 +12,7 @@ FROM ( -- ['bookings', 'listing__capacity', 'metric_time__day'] SELECT subq_12.metric_time__day AS metric_time__day - , listings_src_10017.capacity AS listing__capacity + , listings_src_10019.capacity AS listing__capacity , subq_12.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -23,21 +23,21 @@ FROM ( DATE_TRUNC(ds, day) AS metric_time__day , listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_10015 + FROM ***************************.fct_bookings bookings_source_src_10017 ) subq_12 LEFT OUTER JOIN - ***************************.dim_listings listings_src_10017 + ***************************.dim_listings listings_src_10019 ON ( - subq_12.listing = listings_src_10017.listing_id + subq_12.listing = listings_src_10019.listing_id ) AND ( ( - subq_12.metric_time__day >= listings_src_10017.active_from + subq_12.metric_time__day >= listings_src_10019.active_from ) AND ( ( - subq_12.metric_time__day < listings_src_10017.active_to + subq_12.metric_time__day < listings_src_10019.active_to ) OR ( - listings_src_10017.active_to IS NULL + listings_src_10019.active_to IS NULL ) ) ) diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_local_dimension_using_local_entity__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_local_dimension_using_local_entity__plan0.sql index fa9fd5337d..c31635a669 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_local_dimension_using_local_entity__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_local_dimension_using_local_entity__plan0.sql @@ -87,62 +87,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_0 ) subq_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_local_dimension_using_local_entity__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_local_dimension_using_local_entity__plan0_optimized.sql index f7932552c3..2c5690447e 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_local_dimension_using_local_entity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_local_dimension_using_local_entity__plan0_optimized.sql @@ -11,7 +11,7 @@ FROM ( SELECT country AS listing__country_latest , 1 AS listings - FROM ***************************.dim_listings_latest listings_latest_src_10004 + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_6 GROUP BY listing__country_latest diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0.sql index bda66f6049..cebf3e430e 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0.sql @@ -328,62 +328,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_3 ) subq_4 ) subq_5 @@ -717,62 +717,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_15 ) subq_16 ) subq_17 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0_optimized.sql index 7c1744a24e..ad42fa7a25 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0_optimized.sql @@ -24,13 +24,13 @@ FROM ( -- ['average_booking_value', 'listing__is_lux_latest', 'metric_time__day'] SELECT DATE_TRUNC(bookings_source_src_10001.ds, day) AS metric_time__day - , listings_latest_src_10004.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest , bookings_source_src_10001.booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_10001 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - bookings_source_src_10001.listing_id = listings_latest_src_10004.listing_id + bookings_source_src_10001.listing_id = listings_latest_src_10005.listing_id ) subq_37 WHERE listing__is_lux_latest GROUP BY @@ -51,7 +51,7 @@ FROM ( -- ['bookings', 'listing__is_lux_latest', 'metric_time__day'] SELECT subq_44.metric_time__day AS metric_time__day - , listings_latest_src_10004.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest , subq_44.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -65,9 +65,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_44 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_44.listing = listings_latest_src_10004.listing_id + subq_44.listing = listings_latest_src_10005.listing_id ) subq_49 WHERE listing__is_lux_latest GROUP BY diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql index a506e8dafb..76fa4191e9 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql @@ -304,62 +304,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_5 ) subq_6 ) subq_7 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql index 64aaaf1d47..a6ee65ea4a 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql @@ -22,5 +22,5 @@ CROSS JOIN ( -- Compute Metrics via Expressions SELECT SUM(1) AS listings - FROM ***************************.dim_listings_latest listings_latest_src_10004 + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_20 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0.sql index 33c85d6210..1d468bac78 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0.sql @@ -132,87 +132,87 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_10015.booking_value - , bookings_source_src_10015.guest_id AS bookers - , bookings_source_src_10015.booking_value AS average_booking_value - , bookings_source_src_10015.booking_value AS booking_payments - , bookings_source_src_10015.is_instant - , DATE_TRUNC(bookings_source_src_10015.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_10015.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_10015.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_10015.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_10015.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_10015.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_10015.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_10015.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_10015.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_10015.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_10015.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_10015.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_10015.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_10015.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_10015.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_10015.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_10015.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_10015.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_10015.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_10015.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_10015.paid_at) AS paid_at__extract_doy - , bookings_source_src_10015.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_10015.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_10015.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_10015.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_10015.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_10015.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_10015.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_10015.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_10015.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_10015.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_10015.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_10015.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_10015.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_10015.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_10015.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_10015.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_10015.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_10015.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_10015.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_10015.listing_id AS listing - , bookings_source_src_10015.guest_id AS guest - , bookings_source_src_10015.host_id AS host - , bookings_source_src_10015.guest_id AS user - , bookings_source_src_10015.listing_id AS booking__listing - , bookings_source_src_10015.guest_id AS booking__guest - , bookings_source_src_10015.host_id AS booking__host - , bookings_source_src_10015.guest_id AS booking__user - FROM ***************************.fct_bookings bookings_source_src_10015 + , bookings_source_src_10017.booking_value + , bookings_source_src_10017.guest_id AS bookers + , bookings_source_src_10017.booking_value AS average_booking_value + , bookings_source_src_10017.booking_value AS booking_payments + , bookings_source_src_10017.is_instant + , DATE_TRUNC(bookings_source_src_10017.ds, day) AS ds__day + , DATE_TRUNC(bookings_source_src_10017.ds, isoweek) AS ds__week + , DATE_TRUNC(bookings_source_src_10017.ds, month) AS ds__month + , DATE_TRUNC(bookings_source_src_10017.ds, quarter) AS ds__quarter + , DATE_TRUNC(bookings_source_src_10017.ds, year) AS ds__year + , EXTRACT(year FROM bookings_source_src_10017.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_10017.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_10017.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_10017.ds) AS ds__extract_doy + , DATE_TRUNC(bookings_source_src_10017.ds_partitioned, day) AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10017.ds_partitioned, isoweek) AS ds_partitioned__week + , DATE_TRUNC(bookings_source_src_10017.ds_partitioned, month) AS ds_partitioned__month + , DATE_TRUNC(bookings_source_src_10017.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATE_TRUNC(bookings_source_src_10017.ds_partitioned, year) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_10017.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_10017.ds_partitioned) - 1) AS ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC(bookings_source_src_10017.paid_at, day) AS paid_at__day + , DATE_TRUNC(bookings_source_src_10017.paid_at, isoweek) AS paid_at__week + , DATE_TRUNC(bookings_source_src_10017.paid_at, month) AS paid_at__month + , DATE_TRUNC(bookings_source_src_10017.paid_at, quarter) AS paid_at__quarter + , DATE_TRUNC(bookings_source_src_10017.paid_at, year) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_10017.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_10017.paid_at) AS paid_at__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_10017.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_10017.paid_at) - 1) AS paid_at__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_10017.paid_at) AS paid_at__extract_doy + , bookings_source_src_10017.is_instant AS booking__is_instant + , DATE_TRUNC(bookings_source_src_10017.ds, day) AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10017.ds, isoweek) AS booking__ds__week + , DATE_TRUNC(bookings_source_src_10017.ds, month) AS booking__ds__month + , DATE_TRUNC(bookings_source_src_10017.ds, quarter) AS booking__ds__quarter + , DATE_TRUNC(bookings_source_src_10017.ds, year) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_10017.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds) AS booking__ds__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_10017.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_10017.ds) - 1) AS booking__ds__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_10017.ds) AS booking__ds__extract_doy + , DATE_TRUNC(bookings_source_src_10017.ds_partitioned, day) AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10017.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATE_TRUNC(bookings_source_src_10017.ds_partitioned, month) AS booking__ds_partitioned__month + , DATE_TRUNC(bookings_source_src_10017.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATE_TRUNC(bookings_source_src_10017.ds_partitioned, year) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_10017.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_10017.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC(bookings_source_src_10017.paid_at, day) AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10017.paid_at, isoweek) AS booking__paid_at__week + , DATE_TRUNC(bookings_source_src_10017.paid_at, month) AS booking__paid_at__month + , DATE_TRUNC(bookings_source_src_10017.paid_at, quarter) AS booking__paid_at__quarter + , DATE_TRUNC(bookings_source_src_10017.paid_at, year) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_10017.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_10017.paid_at) - 1) AS booking__paid_at__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_10017.listing_id AS listing + , bookings_source_src_10017.guest_id AS guest + , bookings_source_src_10017.host_id AS host + , bookings_source_src_10017.guest_id AS user + , bookings_source_src_10017.listing_id AS booking__listing + , bookings_source_src_10017.guest_id AS booking__guest + , bookings_source_src_10017.host_id AS booking__host + , bookings_source_src_10017.guest_id AS booking__user + FROM ***************************.fct_bookings bookings_source_src_10017 ) subq_0 ) subq_1 ) subq_2 @@ -295,60 +295,60 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'listings' SELECT - listings_src_10017.active_from AS window_start__day - , DATE_TRUNC(listings_src_10017.active_from, isoweek) AS window_start__week - , DATE_TRUNC(listings_src_10017.active_from, month) AS window_start__month - , DATE_TRUNC(listings_src_10017.active_from, quarter) AS window_start__quarter - , DATE_TRUNC(listings_src_10017.active_from, year) AS window_start__year - , EXTRACT(year FROM listings_src_10017.active_from) AS window_start__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_from) AS window_start__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_from) AS window_start__extract_month - , EXTRACT(day FROM listings_src_10017.active_from) AS window_start__extract_day - , IF(EXTRACT(dayofweek FROM listings_src_10017.active_from) = 1, 7, EXTRACT(dayofweek FROM listings_src_10017.active_from) - 1) AS window_start__extract_dow - , EXTRACT(dayofyear FROM listings_src_10017.active_from) AS window_start__extract_doy - , listings_src_10017.active_to AS window_end__day - , DATE_TRUNC(listings_src_10017.active_to, isoweek) AS window_end__week - , DATE_TRUNC(listings_src_10017.active_to, month) AS window_end__month - , DATE_TRUNC(listings_src_10017.active_to, quarter) AS window_end__quarter - , DATE_TRUNC(listings_src_10017.active_to, year) AS window_end__year - , EXTRACT(year FROM listings_src_10017.active_to) AS window_end__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_to) AS window_end__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_to) AS window_end__extract_month - , EXTRACT(day FROM listings_src_10017.active_to) AS window_end__extract_day - , IF(EXTRACT(dayofweek FROM listings_src_10017.active_to) = 1, 7, EXTRACT(dayofweek FROM listings_src_10017.active_to) - 1) AS window_end__extract_dow - , EXTRACT(dayofyear FROM listings_src_10017.active_to) AS window_end__extract_doy - , listings_src_10017.country - , listings_src_10017.is_lux - , listings_src_10017.capacity - , listings_src_10017.active_from AS listing__window_start__day - , DATE_TRUNC(listings_src_10017.active_from, isoweek) AS listing__window_start__week - , DATE_TRUNC(listings_src_10017.active_from, month) AS listing__window_start__month - , DATE_TRUNC(listings_src_10017.active_from, quarter) AS listing__window_start__quarter - , DATE_TRUNC(listings_src_10017.active_from, year) AS listing__window_start__year - , EXTRACT(year FROM listings_src_10017.active_from) AS listing__window_start__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_from) AS listing__window_start__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_from) AS listing__window_start__extract_month - , EXTRACT(day FROM listings_src_10017.active_from) AS listing__window_start__extract_day - , IF(EXTRACT(dayofweek FROM listings_src_10017.active_from) = 1, 7, EXTRACT(dayofweek FROM listings_src_10017.active_from) - 1) AS listing__window_start__extract_dow - , EXTRACT(dayofyear FROM listings_src_10017.active_from) AS listing__window_start__extract_doy - , listings_src_10017.active_to AS listing__window_end__day - , DATE_TRUNC(listings_src_10017.active_to, isoweek) AS listing__window_end__week - , DATE_TRUNC(listings_src_10017.active_to, month) AS listing__window_end__month - , DATE_TRUNC(listings_src_10017.active_to, quarter) AS listing__window_end__quarter - , DATE_TRUNC(listings_src_10017.active_to, year) AS listing__window_end__year - , EXTRACT(year FROM listings_src_10017.active_to) AS listing__window_end__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_to) AS listing__window_end__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_to) AS listing__window_end__extract_month - , EXTRACT(day FROM listings_src_10017.active_to) AS listing__window_end__extract_day - , IF(EXTRACT(dayofweek FROM listings_src_10017.active_to) = 1, 7, EXTRACT(dayofweek FROM listings_src_10017.active_to) - 1) AS listing__window_end__extract_dow - , EXTRACT(dayofyear FROM listings_src_10017.active_to) AS listing__window_end__extract_doy - , listings_src_10017.country AS listing__country - , listings_src_10017.is_lux AS listing__is_lux - , listings_src_10017.capacity AS listing__capacity - , listings_src_10017.listing_id AS listing - , listings_src_10017.user_id AS user - , listings_src_10017.user_id AS listing__user - FROM ***************************.dim_listings listings_src_10017 + listings_src_10019.active_from AS window_start__day + , DATE_TRUNC(listings_src_10019.active_from, isoweek) AS window_start__week + , DATE_TRUNC(listings_src_10019.active_from, month) AS window_start__month + , DATE_TRUNC(listings_src_10019.active_from, quarter) AS window_start__quarter + , DATE_TRUNC(listings_src_10019.active_from, year) AS window_start__year + , EXTRACT(year FROM listings_src_10019.active_from) AS window_start__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_from) AS window_start__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_from) AS window_start__extract_month + , EXTRACT(day FROM listings_src_10019.active_from) AS window_start__extract_day + , IF(EXTRACT(dayofweek FROM listings_src_10019.active_from) = 1, 7, EXTRACT(dayofweek FROM listings_src_10019.active_from) - 1) AS window_start__extract_dow + , EXTRACT(dayofyear FROM listings_src_10019.active_from) AS window_start__extract_doy + , listings_src_10019.active_to AS window_end__day + , DATE_TRUNC(listings_src_10019.active_to, isoweek) AS window_end__week + , DATE_TRUNC(listings_src_10019.active_to, month) AS window_end__month + , DATE_TRUNC(listings_src_10019.active_to, quarter) AS window_end__quarter + , DATE_TRUNC(listings_src_10019.active_to, year) AS window_end__year + , EXTRACT(year FROM listings_src_10019.active_to) AS window_end__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_to) AS window_end__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_to) AS window_end__extract_month + , EXTRACT(day FROM listings_src_10019.active_to) AS window_end__extract_day + , IF(EXTRACT(dayofweek FROM listings_src_10019.active_to) = 1, 7, EXTRACT(dayofweek FROM listings_src_10019.active_to) - 1) AS window_end__extract_dow + , EXTRACT(dayofyear FROM listings_src_10019.active_to) AS window_end__extract_doy + , listings_src_10019.country + , listings_src_10019.is_lux + , listings_src_10019.capacity + , listings_src_10019.active_from AS listing__window_start__day + , DATE_TRUNC(listings_src_10019.active_from, isoweek) AS listing__window_start__week + , DATE_TRUNC(listings_src_10019.active_from, month) AS listing__window_start__month + , DATE_TRUNC(listings_src_10019.active_from, quarter) AS listing__window_start__quarter + , DATE_TRUNC(listings_src_10019.active_from, year) AS listing__window_start__year + , EXTRACT(year FROM listings_src_10019.active_from) AS listing__window_start__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_from) AS listing__window_start__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_from) AS listing__window_start__extract_month + , EXTRACT(day FROM listings_src_10019.active_from) AS listing__window_start__extract_day + , IF(EXTRACT(dayofweek FROM listings_src_10019.active_from) = 1, 7, EXTRACT(dayofweek FROM listings_src_10019.active_from) - 1) AS listing__window_start__extract_dow + , EXTRACT(dayofyear FROM listings_src_10019.active_from) AS listing__window_start__extract_doy + , listings_src_10019.active_to AS listing__window_end__day + , DATE_TRUNC(listings_src_10019.active_to, isoweek) AS listing__window_end__week + , DATE_TRUNC(listings_src_10019.active_to, month) AS listing__window_end__month + , DATE_TRUNC(listings_src_10019.active_to, quarter) AS listing__window_end__quarter + , DATE_TRUNC(listings_src_10019.active_to, year) AS listing__window_end__year + , EXTRACT(year FROM listings_src_10019.active_to) AS listing__window_end__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_to) AS listing__window_end__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_to) AS listing__window_end__extract_month + , EXTRACT(day FROM listings_src_10019.active_to) AS listing__window_end__extract_day + , IF(EXTRACT(dayofweek FROM listings_src_10019.active_to) = 1, 7, EXTRACT(dayofweek FROM listings_src_10019.active_to) - 1) AS listing__window_end__extract_dow + , EXTRACT(dayofyear FROM listings_src_10019.active_to) AS listing__window_end__extract_doy + , listings_src_10019.country AS listing__country + , listings_src_10019.is_lux AS listing__is_lux + , listings_src_10019.capacity AS listing__capacity + , listings_src_10019.listing_id AS listing + , listings_src_10019.user_id AS user + , listings_src_10019.user_id AS listing__user + FROM ***************************.dim_listings listings_src_10019 ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: @@ -406,32 +406,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC(users_latest_src_10021.ds, day) AS ds__day - , DATE_TRUNC(users_latest_src_10021.ds, isoweek) AS ds__week - , DATE_TRUNC(users_latest_src_10021.ds, month) AS ds__month - , DATE_TRUNC(users_latest_src_10021.ds, quarter) AS ds__quarter - , DATE_TRUNC(users_latest_src_10021.ds, year) AS ds__year - , EXTRACT(year FROM users_latest_src_10021.ds) AS ds__extract_year - , EXTRACT(quarter FROM users_latest_src_10021.ds) AS ds__extract_quarter - , EXTRACT(month FROM users_latest_src_10021.ds) AS ds__extract_month - , EXTRACT(day FROM users_latest_src_10021.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM users_latest_src_10021.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_10021.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM users_latest_src_10021.ds) AS ds__extract_doy - , users_latest_src_10021.home_state_latest - , DATE_TRUNC(users_latest_src_10021.ds, day) AS user__ds__day - , DATE_TRUNC(users_latest_src_10021.ds, isoweek) AS user__ds__week - , DATE_TRUNC(users_latest_src_10021.ds, month) AS user__ds__month - , DATE_TRUNC(users_latest_src_10021.ds, quarter) AS user__ds__quarter - , DATE_TRUNC(users_latest_src_10021.ds, year) AS user__ds__year - , EXTRACT(year FROM users_latest_src_10021.ds) AS user__ds__extract_year - , EXTRACT(quarter FROM users_latest_src_10021.ds) AS user__ds__extract_quarter - , EXTRACT(month FROM users_latest_src_10021.ds) AS user__ds__extract_month - , EXTRACT(day FROM users_latest_src_10021.ds) AS user__ds__extract_day - , IF(EXTRACT(dayofweek FROM users_latest_src_10021.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_10021.ds) - 1) AS user__ds__extract_dow - , EXTRACT(dayofyear FROM users_latest_src_10021.ds) AS user__ds__extract_doy - , users_latest_src_10021.home_state_latest AS user__home_state_latest - , users_latest_src_10021.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_10021 + DATE_TRUNC(users_latest_src_10023.ds, day) AS ds__day + , DATE_TRUNC(users_latest_src_10023.ds, isoweek) AS ds__week + , DATE_TRUNC(users_latest_src_10023.ds, month) AS ds__month + , DATE_TRUNC(users_latest_src_10023.ds, quarter) AS ds__quarter + , DATE_TRUNC(users_latest_src_10023.ds, year) AS ds__year + , EXTRACT(year FROM users_latest_src_10023.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_latest_src_10023.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_latest_src_10023.ds) AS ds__extract_month + , EXTRACT(day FROM users_latest_src_10023.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM users_latest_src_10023.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_10023.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM users_latest_src_10023.ds) AS ds__extract_doy + , users_latest_src_10023.home_state_latest + , DATE_TRUNC(users_latest_src_10023.ds, day) AS user__ds__day + , DATE_TRUNC(users_latest_src_10023.ds, isoweek) AS user__ds__week + , DATE_TRUNC(users_latest_src_10023.ds, month) AS user__ds__month + , DATE_TRUNC(users_latest_src_10023.ds, quarter) AS user__ds__quarter + , DATE_TRUNC(users_latest_src_10023.ds, year) AS user__ds__year + , EXTRACT(year FROM users_latest_src_10023.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_latest_src_10023.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_latest_src_10023.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_latest_src_10023.ds) AS user__ds__extract_day + , IF(EXTRACT(dayofweek FROM users_latest_src_10023.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_10023.ds) - 1) AS user__ds__extract_dow + , EXTRACT(dayofyear FROM users_latest_src_10023.ds) AS user__ds__extract_doy + , users_latest_src_10023.home_state_latest AS user__home_state_latest + , users_latest_src_10023.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_10023 ) subq_4 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0_optimized.sql index 4c0ecc75dd..64a8588115 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0_optimized.sql @@ -16,22 +16,22 @@ FROM ( DATE_TRUNC(ds, day) AS metric_time__day , listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_10015 + FROM ***************************.fct_bookings bookings_source_src_10017 ) subq_13 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: -- ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] SELECT - listings_src_10017.active_from AS window_start__day - , listings_src_10017.active_to AS window_end__day - , listings_src_10017.listing_id AS listing - , users_latest_src_10021.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings listings_src_10017 + listings_src_10019.active_from AS window_start__day + , listings_src_10019.active_to AS window_end__day + , listings_src_10019.listing_id AS listing + , users_latest_src_10023.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings listings_src_10019 LEFT OUTER JOIN - ***************************.dim_users_latest users_latest_src_10021 + ***************************.dim_users_latest users_latest_src_10023 ON - listings_src_10017.user_id = users_latest_src_10021.user_id + listings_src_10019.user_id = users_latest_src_10023.user_id ) subq_18 ON ( diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0.sql index 2039618def..94fe4f81b2 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0.sql @@ -132,87 +132,87 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_10015.booking_value - , bookings_source_src_10015.guest_id AS bookers - , bookings_source_src_10015.booking_value AS average_booking_value - , bookings_source_src_10015.booking_value AS booking_payments - , bookings_source_src_10015.is_instant - , DATE_TRUNC(bookings_source_src_10015.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_10015.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_10015.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_10015.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_10015.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_10015.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_10015.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_10015.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_10015.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_10015.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_10015.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_10015.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_10015.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_10015.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_10015.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_10015.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_10015.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_10015.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_10015.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_10015.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_10015.paid_at) AS paid_at__extract_doy - , bookings_source_src_10015.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_10015.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_10015.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_10015.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_10015.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_10015.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_10015.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_10015.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_10015.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_10015.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_10015.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_10015.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_10015.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_10015.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_10015.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_10015.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_10015.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_10015.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_10015.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_10015.listing_id AS listing - , bookings_source_src_10015.guest_id AS guest - , bookings_source_src_10015.host_id AS host - , bookings_source_src_10015.guest_id AS user - , bookings_source_src_10015.listing_id AS booking__listing - , bookings_source_src_10015.guest_id AS booking__guest - , bookings_source_src_10015.host_id AS booking__host - , bookings_source_src_10015.guest_id AS booking__user - FROM ***************************.fct_bookings bookings_source_src_10015 + , bookings_source_src_10017.booking_value + , bookings_source_src_10017.guest_id AS bookers + , bookings_source_src_10017.booking_value AS average_booking_value + , bookings_source_src_10017.booking_value AS booking_payments + , bookings_source_src_10017.is_instant + , DATE_TRUNC(bookings_source_src_10017.ds, day) AS ds__day + , DATE_TRUNC(bookings_source_src_10017.ds, isoweek) AS ds__week + , DATE_TRUNC(bookings_source_src_10017.ds, month) AS ds__month + , DATE_TRUNC(bookings_source_src_10017.ds, quarter) AS ds__quarter + , DATE_TRUNC(bookings_source_src_10017.ds, year) AS ds__year + , EXTRACT(year FROM bookings_source_src_10017.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_10017.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_10017.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_10017.ds) AS ds__extract_doy + , DATE_TRUNC(bookings_source_src_10017.ds_partitioned, day) AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10017.ds_partitioned, isoweek) AS ds_partitioned__week + , DATE_TRUNC(bookings_source_src_10017.ds_partitioned, month) AS ds_partitioned__month + , DATE_TRUNC(bookings_source_src_10017.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATE_TRUNC(bookings_source_src_10017.ds_partitioned, year) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_10017.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_10017.ds_partitioned) - 1) AS ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC(bookings_source_src_10017.paid_at, day) AS paid_at__day + , DATE_TRUNC(bookings_source_src_10017.paid_at, isoweek) AS paid_at__week + , DATE_TRUNC(bookings_source_src_10017.paid_at, month) AS paid_at__month + , DATE_TRUNC(bookings_source_src_10017.paid_at, quarter) AS paid_at__quarter + , DATE_TRUNC(bookings_source_src_10017.paid_at, year) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_10017.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_10017.paid_at) AS paid_at__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_10017.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_10017.paid_at) - 1) AS paid_at__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_10017.paid_at) AS paid_at__extract_doy + , bookings_source_src_10017.is_instant AS booking__is_instant + , DATE_TRUNC(bookings_source_src_10017.ds, day) AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10017.ds, isoweek) AS booking__ds__week + , DATE_TRUNC(bookings_source_src_10017.ds, month) AS booking__ds__month + , DATE_TRUNC(bookings_source_src_10017.ds, quarter) AS booking__ds__quarter + , DATE_TRUNC(bookings_source_src_10017.ds, year) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_10017.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds) AS booking__ds__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_10017.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_10017.ds) - 1) AS booking__ds__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_10017.ds) AS booking__ds__extract_doy + , DATE_TRUNC(bookings_source_src_10017.ds_partitioned, day) AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10017.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATE_TRUNC(bookings_source_src_10017.ds_partitioned, month) AS booking__ds_partitioned__month + , DATE_TRUNC(bookings_source_src_10017.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATE_TRUNC(bookings_source_src_10017.ds_partitioned, year) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_10017.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_10017.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC(bookings_source_src_10017.paid_at, day) AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10017.paid_at, isoweek) AS booking__paid_at__week + , DATE_TRUNC(bookings_source_src_10017.paid_at, month) AS booking__paid_at__month + , DATE_TRUNC(bookings_source_src_10017.paid_at, quarter) AS booking__paid_at__quarter + , DATE_TRUNC(bookings_source_src_10017.paid_at, year) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_10017.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_10017.paid_at) - 1) AS booking__paid_at__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_10017.listing_id AS listing + , bookings_source_src_10017.guest_id AS guest + , bookings_source_src_10017.host_id AS host + , bookings_source_src_10017.guest_id AS user + , bookings_source_src_10017.listing_id AS booking__listing + , bookings_source_src_10017.guest_id AS booking__guest + , bookings_source_src_10017.host_id AS booking__host + , bookings_source_src_10017.guest_id AS booking__user + FROM ***************************.fct_bookings bookings_source_src_10017 ) subq_0 ) subq_1 ) subq_2 @@ -259,10 +259,10 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'lux_listing_mapping' SELECT - lux_listing_mapping_src_10018.listing_id AS listing - , lux_listing_mapping_src_10018.lux_listing_id AS lux_listing - , lux_listing_mapping_src_10018.lux_listing_id AS listing__lux_listing - FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_10018 + lux_listing_mapping_src_10020.listing_id AS listing + , lux_listing_mapping_src_10020.lux_listing_id AS lux_listing + , lux_listing_mapping_src_10020.lux_listing_id AS listing__lux_listing + FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_10020 ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: @@ -364,54 +364,54 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'lux_listings' SELECT - lux_listings_src_10019.valid_from AS window_start__day - , DATE_TRUNC(lux_listings_src_10019.valid_from, isoweek) AS window_start__week - , DATE_TRUNC(lux_listings_src_10019.valid_from, month) AS window_start__month - , DATE_TRUNC(lux_listings_src_10019.valid_from, quarter) AS window_start__quarter - , DATE_TRUNC(lux_listings_src_10019.valid_from, year) AS window_start__year - , EXTRACT(year FROM lux_listings_src_10019.valid_from) AS window_start__extract_year - , EXTRACT(quarter FROM lux_listings_src_10019.valid_from) AS window_start__extract_quarter - , EXTRACT(month FROM lux_listings_src_10019.valid_from) AS window_start__extract_month - , EXTRACT(day FROM lux_listings_src_10019.valid_from) AS window_start__extract_day - , IF(EXTRACT(dayofweek FROM lux_listings_src_10019.valid_from) = 1, 7, EXTRACT(dayofweek FROM lux_listings_src_10019.valid_from) - 1) AS window_start__extract_dow - , EXTRACT(dayofyear FROM lux_listings_src_10019.valid_from) AS window_start__extract_doy - , lux_listings_src_10019.valid_to AS window_end__day - , DATE_TRUNC(lux_listings_src_10019.valid_to, isoweek) AS window_end__week - , DATE_TRUNC(lux_listings_src_10019.valid_to, month) AS window_end__month - , DATE_TRUNC(lux_listings_src_10019.valid_to, quarter) AS window_end__quarter - , DATE_TRUNC(lux_listings_src_10019.valid_to, year) AS window_end__year - , EXTRACT(year FROM lux_listings_src_10019.valid_to) AS window_end__extract_year - , EXTRACT(quarter FROM lux_listings_src_10019.valid_to) AS window_end__extract_quarter - , EXTRACT(month FROM lux_listings_src_10019.valid_to) AS window_end__extract_month - , EXTRACT(day FROM lux_listings_src_10019.valid_to) AS window_end__extract_day - , IF(EXTRACT(dayofweek FROM lux_listings_src_10019.valid_to) = 1, 7, EXTRACT(dayofweek FROM lux_listings_src_10019.valid_to) - 1) AS window_end__extract_dow - , EXTRACT(dayofyear FROM lux_listings_src_10019.valid_to) AS window_end__extract_doy - , lux_listings_src_10019.is_confirmed_lux - , lux_listings_src_10019.valid_from AS lux_listing__window_start__day - , DATE_TRUNC(lux_listings_src_10019.valid_from, isoweek) AS lux_listing__window_start__week - , DATE_TRUNC(lux_listings_src_10019.valid_from, month) AS lux_listing__window_start__month - , DATE_TRUNC(lux_listings_src_10019.valid_from, quarter) AS lux_listing__window_start__quarter - , DATE_TRUNC(lux_listings_src_10019.valid_from, year) AS lux_listing__window_start__year - , EXTRACT(year FROM lux_listings_src_10019.valid_from) AS lux_listing__window_start__extract_year - , EXTRACT(quarter FROM lux_listings_src_10019.valid_from) AS lux_listing__window_start__extract_quarter - , EXTRACT(month FROM lux_listings_src_10019.valid_from) AS lux_listing__window_start__extract_month - , EXTRACT(day FROM lux_listings_src_10019.valid_from) AS lux_listing__window_start__extract_day - , IF(EXTRACT(dayofweek FROM lux_listings_src_10019.valid_from) = 1, 7, EXTRACT(dayofweek FROM lux_listings_src_10019.valid_from) - 1) AS lux_listing__window_start__extract_dow - , EXTRACT(dayofyear FROM lux_listings_src_10019.valid_from) AS lux_listing__window_start__extract_doy - , lux_listings_src_10019.valid_to AS lux_listing__window_end__day - , DATE_TRUNC(lux_listings_src_10019.valid_to, isoweek) AS lux_listing__window_end__week - , DATE_TRUNC(lux_listings_src_10019.valid_to, month) AS lux_listing__window_end__month - , DATE_TRUNC(lux_listings_src_10019.valid_to, quarter) AS lux_listing__window_end__quarter - , DATE_TRUNC(lux_listings_src_10019.valid_to, year) AS lux_listing__window_end__year - , EXTRACT(year FROM lux_listings_src_10019.valid_to) AS lux_listing__window_end__extract_year - , EXTRACT(quarter FROM lux_listings_src_10019.valid_to) AS lux_listing__window_end__extract_quarter - , EXTRACT(month FROM lux_listings_src_10019.valid_to) AS lux_listing__window_end__extract_month - , EXTRACT(day FROM lux_listings_src_10019.valid_to) AS lux_listing__window_end__extract_day - , IF(EXTRACT(dayofweek FROM lux_listings_src_10019.valid_to) = 1, 7, EXTRACT(dayofweek FROM lux_listings_src_10019.valid_to) - 1) AS lux_listing__window_end__extract_dow - , EXTRACT(dayofyear FROM lux_listings_src_10019.valid_to) AS lux_listing__window_end__extract_doy - , lux_listings_src_10019.is_confirmed_lux AS lux_listing__is_confirmed_lux - , lux_listings_src_10019.lux_listing_id AS lux_listing - FROM ***************************.dim_lux_listings lux_listings_src_10019 + lux_listings_src_10021.valid_from AS window_start__day + , DATE_TRUNC(lux_listings_src_10021.valid_from, isoweek) AS window_start__week + , DATE_TRUNC(lux_listings_src_10021.valid_from, month) AS window_start__month + , DATE_TRUNC(lux_listings_src_10021.valid_from, quarter) AS window_start__quarter + , DATE_TRUNC(lux_listings_src_10021.valid_from, year) AS window_start__year + , EXTRACT(year FROM lux_listings_src_10021.valid_from) AS window_start__extract_year + , EXTRACT(quarter FROM lux_listings_src_10021.valid_from) AS window_start__extract_quarter + , EXTRACT(month FROM lux_listings_src_10021.valid_from) AS window_start__extract_month + , EXTRACT(day FROM lux_listings_src_10021.valid_from) AS window_start__extract_day + , IF(EXTRACT(dayofweek FROM lux_listings_src_10021.valid_from) = 1, 7, EXTRACT(dayofweek FROM lux_listings_src_10021.valid_from) - 1) AS window_start__extract_dow + , EXTRACT(dayofyear FROM lux_listings_src_10021.valid_from) AS window_start__extract_doy + , lux_listings_src_10021.valid_to AS window_end__day + , DATE_TRUNC(lux_listings_src_10021.valid_to, isoweek) AS window_end__week + , DATE_TRUNC(lux_listings_src_10021.valid_to, month) AS window_end__month + , DATE_TRUNC(lux_listings_src_10021.valid_to, quarter) AS window_end__quarter + , DATE_TRUNC(lux_listings_src_10021.valid_to, year) AS window_end__year + , EXTRACT(year FROM lux_listings_src_10021.valid_to) AS window_end__extract_year + , EXTRACT(quarter FROM lux_listings_src_10021.valid_to) AS window_end__extract_quarter + , EXTRACT(month FROM lux_listings_src_10021.valid_to) AS window_end__extract_month + , EXTRACT(day FROM lux_listings_src_10021.valid_to) AS window_end__extract_day + , IF(EXTRACT(dayofweek FROM lux_listings_src_10021.valid_to) = 1, 7, EXTRACT(dayofweek FROM lux_listings_src_10021.valid_to) - 1) AS window_end__extract_dow + , EXTRACT(dayofyear FROM lux_listings_src_10021.valid_to) AS window_end__extract_doy + , lux_listings_src_10021.is_confirmed_lux + , lux_listings_src_10021.valid_from AS lux_listing__window_start__day + , DATE_TRUNC(lux_listings_src_10021.valid_from, isoweek) AS lux_listing__window_start__week + , DATE_TRUNC(lux_listings_src_10021.valid_from, month) AS lux_listing__window_start__month + , DATE_TRUNC(lux_listings_src_10021.valid_from, quarter) AS lux_listing__window_start__quarter + , DATE_TRUNC(lux_listings_src_10021.valid_from, year) AS lux_listing__window_start__year + , EXTRACT(year FROM lux_listings_src_10021.valid_from) AS lux_listing__window_start__extract_year + , EXTRACT(quarter FROM lux_listings_src_10021.valid_from) AS lux_listing__window_start__extract_quarter + , EXTRACT(month FROM lux_listings_src_10021.valid_from) AS lux_listing__window_start__extract_month + , EXTRACT(day FROM lux_listings_src_10021.valid_from) AS lux_listing__window_start__extract_day + , IF(EXTRACT(dayofweek FROM lux_listings_src_10021.valid_from) = 1, 7, EXTRACT(dayofweek FROM lux_listings_src_10021.valid_from) - 1) AS lux_listing__window_start__extract_dow + , EXTRACT(dayofyear FROM lux_listings_src_10021.valid_from) AS lux_listing__window_start__extract_doy + , lux_listings_src_10021.valid_to AS lux_listing__window_end__day + , DATE_TRUNC(lux_listings_src_10021.valid_to, isoweek) AS lux_listing__window_end__week + , DATE_TRUNC(lux_listings_src_10021.valid_to, month) AS lux_listing__window_end__month + , DATE_TRUNC(lux_listings_src_10021.valid_to, quarter) AS lux_listing__window_end__quarter + , DATE_TRUNC(lux_listings_src_10021.valid_to, year) AS lux_listing__window_end__year + , EXTRACT(year FROM lux_listings_src_10021.valid_to) AS lux_listing__window_end__extract_year + , EXTRACT(quarter FROM lux_listings_src_10021.valid_to) AS lux_listing__window_end__extract_quarter + , EXTRACT(month FROM lux_listings_src_10021.valid_to) AS lux_listing__window_end__extract_month + , EXTRACT(day FROM lux_listings_src_10021.valid_to) AS lux_listing__window_end__extract_day + , IF(EXTRACT(dayofweek FROM lux_listings_src_10021.valid_to) = 1, 7, EXTRACT(dayofweek FROM lux_listings_src_10021.valid_to) - 1) AS lux_listing__window_end__extract_dow + , EXTRACT(dayofyear FROM lux_listings_src_10021.valid_to) AS lux_listing__window_end__extract_doy + , lux_listings_src_10021.is_confirmed_lux AS lux_listing__is_confirmed_lux + , lux_listings_src_10021.lux_listing_id AS lux_listing + FROM ***************************.dim_lux_listings lux_listings_src_10021 ) subq_4 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0_optimized.sql index e2b8f6391f..6df5b73793 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0_optimized.sql @@ -16,7 +16,7 @@ FROM ( DATE_TRUNC(ds, day) AS metric_time__day , listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_10015 + FROM ***************************.fct_bookings bookings_source_src_10017 ) subq_13 LEFT OUTER JOIN ( -- Join Standard Outputs @@ -26,15 +26,15 @@ LEFT OUTER JOIN ( -- 'lux_listing__window_end__day', -- 'listing'] SELECT - lux_listings_src_10019.valid_from AS lux_listing__window_start__day - , lux_listings_src_10019.valid_to AS lux_listing__window_end__day - , lux_listing_mapping_src_10018.listing_id AS listing - , lux_listings_src_10019.is_confirmed_lux AS lux_listing__is_confirmed_lux - FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_10018 + lux_listings_src_10021.valid_from AS lux_listing__window_start__day + , lux_listings_src_10021.valid_to AS lux_listing__window_end__day + , lux_listing_mapping_src_10020.listing_id AS listing + , lux_listings_src_10021.is_confirmed_lux AS lux_listing__is_confirmed_lux + FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_10020 LEFT OUTER JOIN - ***************************.dim_lux_listings lux_listings_src_10019 + ***************************.dim_lux_listings lux_listings_src_10021 ON - lux_listing_mapping_src_10018.lux_listing_id = lux_listings_src_10019.lux_listing_id + lux_listing_mapping_src_10020.lux_listing_id = lux_listings_src_10021.lux_listing_id ) subq_18 ON ( diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0.sql index 0a1e58e264..aa59edb98f 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0.sql @@ -93,55 +93,55 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'account_month_txns' SELECT - account_month_txns_src_10010.txn_count - , DATE_TRUNC(account_month_txns_src_10010.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(account_month_txns_src_10010.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(account_month_txns_src_10010.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(account_month_txns_src_10010.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(account_month_txns_src_10010.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM account_month_txns_src_10010.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM account_month_txns_src_10010.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(account_month_txns_src_10010.ds, day) AS ds__day - , DATE_TRUNC(account_month_txns_src_10010.ds, isoweek) AS ds__week - , DATE_TRUNC(account_month_txns_src_10010.ds, month) AS ds__month - , DATE_TRUNC(account_month_txns_src_10010.ds, quarter) AS ds__quarter - , DATE_TRUNC(account_month_txns_src_10010.ds, year) AS ds__year - , EXTRACT(year FROM account_month_txns_src_10010.ds) AS ds__extract_year - , EXTRACT(quarter FROM account_month_txns_src_10010.ds) AS ds__extract_quarter - , EXTRACT(month FROM account_month_txns_src_10010.ds) AS ds__extract_month - , EXTRACT(day FROM account_month_txns_src_10010.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM account_month_txns_src_10010.ds) = 1, 7, EXTRACT(dayofweek FROM account_month_txns_src_10010.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM account_month_txns_src_10010.ds) AS ds__extract_doy - , account_month_txns_src_10010.account_month - , DATE_TRUNC(account_month_txns_src_10010.ds_partitioned, day) AS account_id__ds_partitioned__day - , DATE_TRUNC(account_month_txns_src_10010.ds_partitioned, isoweek) AS account_id__ds_partitioned__week - , DATE_TRUNC(account_month_txns_src_10010.ds_partitioned, month) AS account_id__ds_partitioned__month - , DATE_TRUNC(account_month_txns_src_10010.ds_partitioned, quarter) AS account_id__ds_partitioned__quarter - , DATE_TRUNC(account_month_txns_src_10010.ds_partitioned, year) AS account_id__ds_partitioned__year - , EXTRACT(year FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_month - , EXTRACT(day FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM account_month_txns_src_10010.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM account_month_txns_src_10010.ds_partitioned) - 1) AS account_id__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , DATE_TRUNC(account_month_txns_src_10010.ds, day) AS account_id__ds__day - , DATE_TRUNC(account_month_txns_src_10010.ds, isoweek) AS account_id__ds__week - , DATE_TRUNC(account_month_txns_src_10010.ds, month) AS account_id__ds__month - , DATE_TRUNC(account_month_txns_src_10010.ds, quarter) AS account_id__ds__quarter - , DATE_TRUNC(account_month_txns_src_10010.ds, year) AS account_id__ds__year - , EXTRACT(year FROM account_month_txns_src_10010.ds) AS account_id__ds__extract_year - , EXTRACT(quarter FROM account_month_txns_src_10010.ds) AS account_id__ds__extract_quarter - , EXTRACT(month FROM account_month_txns_src_10010.ds) AS account_id__ds__extract_month - , EXTRACT(day FROM account_month_txns_src_10010.ds) AS account_id__ds__extract_day - , IF(EXTRACT(dayofweek FROM account_month_txns_src_10010.ds) = 1, 7, EXTRACT(dayofweek FROM account_month_txns_src_10010.ds) - 1) AS account_id__ds__extract_dow - , EXTRACT(dayofyear FROM account_month_txns_src_10010.ds) AS account_id__ds__extract_doy - , account_month_txns_src_10010.account_month AS account_id__account_month - , account_month_txns_src_10010.account_id - FROM ***************************.account_month_txns account_month_txns_src_10010 + account_month_txns_src_10012.txn_count + , DATE_TRUNC(account_month_txns_src_10012.ds_partitioned, day) AS ds_partitioned__day + , DATE_TRUNC(account_month_txns_src_10012.ds_partitioned, isoweek) AS ds_partitioned__week + , DATE_TRUNC(account_month_txns_src_10012.ds_partitioned, month) AS ds_partitioned__month + , DATE_TRUNC(account_month_txns_src_10012.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATE_TRUNC(account_month_txns_src_10012.ds_partitioned, year) AS ds_partitioned__year + , EXTRACT(year FROM account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM account_month_txns_src_10012.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM account_month_txns_src_10012.ds_partitioned) - 1) AS ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC(account_month_txns_src_10012.ds, day) AS ds__day + , DATE_TRUNC(account_month_txns_src_10012.ds, isoweek) AS ds__week + , DATE_TRUNC(account_month_txns_src_10012.ds, month) AS ds__month + , DATE_TRUNC(account_month_txns_src_10012.ds, quarter) AS ds__quarter + , DATE_TRUNC(account_month_txns_src_10012.ds, year) AS ds__year + , EXTRACT(year FROM account_month_txns_src_10012.ds) AS ds__extract_year + , EXTRACT(quarter FROM account_month_txns_src_10012.ds) AS ds__extract_quarter + , EXTRACT(month FROM account_month_txns_src_10012.ds) AS ds__extract_month + , EXTRACT(day FROM account_month_txns_src_10012.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM account_month_txns_src_10012.ds) = 1, 7, EXTRACT(dayofweek FROM account_month_txns_src_10012.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM account_month_txns_src_10012.ds) AS ds__extract_doy + , account_month_txns_src_10012.account_month + , DATE_TRUNC(account_month_txns_src_10012.ds_partitioned, day) AS account_id__ds_partitioned__day + , DATE_TRUNC(account_month_txns_src_10012.ds_partitioned, isoweek) AS account_id__ds_partitioned__week + , DATE_TRUNC(account_month_txns_src_10012.ds_partitioned, month) AS account_id__ds_partitioned__month + , DATE_TRUNC(account_month_txns_src_10012.ds_partitioned, quarter) AS account_id__ds_partitioned__quarter + , DATE_TRUNC(account_month_txns_src_10012.ds_partitioned, year) AS account_id__ds_partitioned__year + , EXTRACT(year FROM account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__extract_month + , EXTRACT(day FROM account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM account_month_txns_src_10012.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM account_month_txns_src_10012.ds_partitioned) - 1) AS account_id__ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__extract_doy + , DATE_TRUNC(account_month_txns_src_10012.ds, day) AS account_id__ds__day + , DATE_TRUNC(account_month_txns_src_10012.ds, isoweek) AS account_id__ds__week + , DATE_TRUNC(account_month_txns_src_10012.ds, month) AS account_id__ds__month + , DATE_TRUNC(account_month_txns_src_10012.ds, quarter) AS account_id__ds__quarter + , DATE_TRUNC(account_month_txns_src_10012.ds, year) AS account_id__ds__year + , EXTRACT(year FROM account_month_txns_src_10012.ds) AS account_id__ds__extract_year + , EXTRACT(quarter FROM account_month_txns_src_10012.ds) AS account_id__ds__extract_quarter + , EXTRACT(month FROM account_month_txns_src_10012.ds) AS account_id__ds__extract_month + , EXTRACT(day FROM account_month_txns_src_10012.ds) AS account_id__ds__extract_day + , IF(EXTRACT(dayofweek FROM account_month_txns_src_10012.ds) = 1, 7, EXTRACT(dayofweek FROM account_month_txns_src_10012.ds) - 1) AS account_id__ds__extract_dow + , EXTRACT(dayofyear FROM account_month_txns_src_10012.ds) AS account_id__ds__extract_doy + , account_month_txns_src_10012.account_month AS account_id__account_month + , account_month_txns_src_10012.account_id + FROM ***************************.account_month_txns account_month_txns_src_10012 ) subq_0 ) subq_1 ) subq_2 @@ -212,48 +212,48 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT - bridge_table_src_10011.extra_dim - , DATE_TRUNC(bridge_table_src_10011.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bridge_table_src_10011.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bridge_table_src_10011.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bridge_table_src_10011.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bridge_table_src_10011.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bridge_table_src_10011.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bridge_table_src_10011.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_doy - , bridge_table_src_10011.extra_dim AS account_id__extra_dim - , DATE_TRUNC(bridge_table_src_10011.ds_partitioned, day) AS account_id__ds_partitioned__day - , DATE_TRUNC(bridge_table_src_10011.ds_partitioned, isoweek) AS account_id__ds_partitioned__week - , DATE_TRUNC(bridge_table_src_10011.ds_partitioned, month) AS account_id__ds_partitioned__month - , DATE_TRUNC(bridge_table_src_10011.ds_partitioned, quarter) AS account_id__ds_partitioned__quarter - , DATE_TRUNC(bridge_table_src_10011.ds_partitioned, year) AS account_id__ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bridge_table_src_10011.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bridge_table_src_10011.ds_partitioned) - 1) AS account_id__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , bridge_table_src_10011.extra_dim AS bridge_account__extra_dim - , DATE_TRUNC(bridge_table_src_10011.ds_partitioned, day) AS bridge_account__ds_partitioned__day - , DATE_TRUNC(bridge_table_src_10011.ds_partitioned, isoweek) AS bridge_account__ds_partitioned__week - , DATE_TRUNC(bridge_table_src_10011.ds_partitioned, month) AS bridge_account__ds_partitioned__month - , DATE_TRUNC(bridge_table_src_10011.ds_partitioned, quarter) AS bridge_account__ds_partitioned__quarter - , DATE_TRUNC(bridge_table_src_10011.ds_partitioned, year) AS bridge_account__ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bridge_table_src_10011.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bridge_table_src_10011.ds_partitioned) - 1) AS bridge_account__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__extract_doy - , bridge_table_src_10011.account_id - , bridge_table_src_10011.customer_id - , bridge_table_src_10011.customer_id AS account_id__customer_id - , bridge_table_src_10011.account_id AS bridge_account__account_id - , bridge_table_src_10011.customer_id AS bridge_account__customer_id - FROM ***************************.bridge_table bridge_table_src_10011 + bridge_table_src_10013.extra_dim + , DATE_TRUNC(bridge_table_src_10013.ds_partitioned, day) AS ds_partitioned__day + , DATE_TRUNC(bridge_table_src_10013.ds_partitioned, isoweek) AS ds_partitioned__week + , DATE_TRUNC(bridge_table_src_10013.ds_partitioned, month) AS ds_partitioned__month + , DATE_TRUNC(bridge_table_src_10013.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATE_TRUNC(bridge_table_src_10013.ds_partitioned, year) AS ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_10013.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_10013.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_10013.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_10013.ds_partitioned) AS ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM bridge_table_src_10013.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bridge_table_src_10013.ds_partitioned) - 1) AS ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM bridge_table_src_10013.ds_partitioned) AS ds_partitioned__extract_doy + , bridge_table_src_10013.extra_dim AS account_id__extra_dim + , DATE_TRUNC(bridge_table_src_10013.ds_partitioned, day) AS account_id__ds_partitioned__day + , DATE_TRUNC(bridge_table_src_10013.ds_partitioned, isoweek) AS account_id__ds_partitioned__week + , DATE_TRUNC(bridge_table_src_10013.ds_partitioned, month) AS account_id__ds_partitioned__month + , DATE_TRUNC(bridge_table_src_10013.ds_partitioned, quarter) AS account_id__ds_partitioned__quarter + , DATE_TRUNC(bridge_table_src_10013.ds_partitioned, year) AS account_id__ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM bridge_table_src_10013.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bridge_table_src_10013.ds_partitioned) - 1) AS account_id__ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__extract_doy + , bridge_table_src_10013.extra_dim AS bridge_account__extra_dim + , DATE_TRUNC(bridge_table_src_10013.ds_partitioned, day) AS bridge_account__ds_partitioned__day + , DATE_TRUNC(bridge_table_src_10013.ds_partitioned, isoweek) AS bridge_account__ds_partitioned__week + , DATE_TRUNC(bridge_table_src_10013.ds_partitioned, month) AS bridge_account__ds_partitioned__month + , DATE_TRUNC(bridge_table_src_10013.ds_partitioned, quarter) AS bridge_account__ds_partitioned__quarter + , DATE_TRUNC(bridge_table_src_10013.ds_partitioned, year) AS bridge_account__ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM bridge_table_src_10013.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bridge_table_src_10013.ds_partitioned) - 1) AS bridge_account__ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__extract_doy + , bridge_table_src_10013.account_id + , bridge_table_src_10013.customer_id + , bridge_table_src_10013.customer_id AS account_id__customer_id + , bridge_table_src_10013.account_id AS bridge_account__account_id + , bridge_table_src_10013.customer_id AS bridge_account__customer_id + FROM ***************************.bridge_table bridge_table_src_10013 ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: @@ -315,34 +315,34 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'customer_table' SELECT - customer_table_src_10013.customer_name - , customer_table_src_10013.customer_atomic_weight - , DATE_TRUNC(customer_table_src_10013.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(customer_table_src_10013.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(customer_table_src_10013.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(customer_table_src_10013.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(customer_table_src_10013.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM customer_table_src_10013.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM customer_table_src_10013.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_doy - , customer_table_src_10013.customer_name AS customer_id__customer_name - , customer_table_src_10013.customer_atomic_weight AS customer_id__customer_atomic_weight - , DATE_TRUNC(customer_table_src_10013.ds_partitioned, day) AS customer_id__ds_partitioned__day - , DATE_TRUNC(customer_table_src_10013.ds_partitioned, isoweek) AS customer_id__ds_partitioned__week - , DATE_TRUNC(customer_table_src_10013.ds_partitioned, month) AS customer_id__ds_partitioned__month - , DATE_TRUNC(customer_table_src_10013.ds_partitioned, quarter) AS customer_id__ds_partitioned__quarter - , DATE_TRUNC(customer_table_src_10013.ds_partitioned, year) AS customer_id__ds_partitioned__year - , EXTRACT(year FROM customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__extract_month - , EXTRACT(day FROM customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM customer_table_src_10013.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM customer_table_src_10013.ds_partitioned) - 1) AS customer_id__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__extract_doy - , customer_table_src_10013.customer_id - FROM ***************************.customer_table customer_table_src_10013 + customer_table_src_10015.customer_name + , customer_table_src_10015.customer_atomic_weight + , DATE_TRUNC(customer_table_src_10015.ds_partitioned, day) AS ds_partitioned__day + , DATE_TRUNC(customer_table_src_10015.ds_partitioned, isoweek) AS ds_partitioned__week + , DATE_TRUNC(customer_table_src_10015.ds_partitioned, month) AS ds_partitioned__month + , DATE_TRUNC(customer_table_src_10015.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATE_TRUNC(customer_table_src_10015.ds_partitioned, year) AS ds_partitioned__year + , EXTRACT(year FROM customer_table_src_10015.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM customer_table_src_10015.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM customer_table_src_10015.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM customer_table_src_10015.ds_partitioned) AS ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM customer_table_src_10015.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM customer_table_src_10015.ds_partitioned) - 1) AS ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM customer_table_src_10015.ds_partitioned) AS ds_partitioned__extract_doy + , customer_table_src_10015.customer_name AS customer_id__customer_name + , customer_table_src_10015.customer_atomic_weight AS customer_id__customer_atomic_weight + , DATE_TRUNC(customer_table_src_10015.ds_partitioned, day) AS customer_id__ds_partitioned__day + , DATE_TRUNC(customer_table_src_10015.ds_partitioned, isoweek) AS customer_id__ds_partitioned__week + , DATE_TRUNC(customer_table_src_10015.ds_partitioned, month) AS customer_id__ds_partitioned__month + , DATE_TRUNC(customer_table_src_10015.ds_partitioned, quarter) AS customer_id__ds_partitioned__quarter + , DATE_TRUNC(customer_table_src_10015.ds_partitioned, year) AS customer_id__ds_partitioned__year + , EXTRACT(year FROM customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__extract_month + , EXTRACT(day FROM customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM customer_table_src_10015.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM customer_table_src_10015.ds_partitioned) - 1) AS customer_id__ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__extract_doy + , customer_table_src_10015.customer_id + FROM ***************************.customer_table customer_table_src_10015 ) subq_4 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0_optimized.sql index a8c31cfb8a..3cd4f108f9 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0_optimized.sql @@ -5,31 +5,31 @@ -- Compute Metrics via Expressions SELECT subq_18.customer_id__customer_name AS account_id__customer_id__customer_name - , SUM(account_month_txns_src_10010.txn_count) AS txn_count -FROM ***************************.account_month_txns account_month_txns_src_10010 + , SUM(account_month_txns_src_10012.txn_count) AS txn_count +FROM ***************************.account_month_txns account_month_txns_src_10012 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: -- ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - DATE_TRUNC(bridge_table_src_10011.ds_partitioned, day) AS ds_partitioned__day - , bridge_table_src_10011.account_id AS account_id - , customer_table_src_10013.customer_name AS customer_id__customer_name - FROM ***************************.bridge_table bridge_table_src_10011 + DATE_TRUNC(bridge_table_src_10013.ds_partitioned, day) AS ds_partitioned__day + , bridge_table_src_10013.account_id AS account_id + , customer_table_src_10015.customer_name AS customer_id__customer_name + FROM ***************************.bridge_table bridge_table_src_10013 LEFT OUTER JOIN - ***************************.customer_table customer_table_src_10013 + ***************************.customer_table customer_table_src_10015 ON ( - bridge_table_src_10011.customer_id = customer_table_src_10013.customer_id + bridge_table_src_10013.customer_id = customer_table_src_10015.customer_id ) AND ( - DATE_TRUNC(bridge_table_src_10011.ds_partitioned, day) = DATE_TRUNC(customer_table_src_10013.ds_partitioned, day) + DATE_TRUNC(bridge_table_src_10013.ds_partitioned, day) = DATE_TRUNC(customer_table_src_10015.ds_partitioned, day) ) ) subq_18 ON ( - account_month_txns_src_10010.account_id = subq_18.account_id + account_month_txns_src_10012.account_id = subq_18.account_id ) AND ( - DATE_TRUNC(account_month_txns_src_10010.ds_partitioned, day) = subq_18.ds_partitioned__day + DATE_TRUNC(account_month_txns_src_10012.ds_partitioned, day) = subq_18.ds_partitioned__day ) GROUP BY account_id__customer_id__customer_name diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multiple_metrics_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multiple_metrics_no_dimensions__plan0.sql index 6d823d91b4..ccb79498a2 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multiple_metrics_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multiple_metrics_no_dimensions__plan0.sql @@ -473,62 +473,62 @@ CROSS JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_10004.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__ds__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__ds__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__ds__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__ds__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC(listings_latest_src_10005.created_at, day) AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_10005.created_at, isoweek) AS listing__created_at__week + , DATE_TRUNC(listings_latest_src_10005.created_at, month) AS listing__created_at__month + , DATE_TRUNC(listings_latest_src_10005.created_at, quarter) AS listing__created_at__quarter + , DATE_TRUNC(listings_latest_src_10005.created_at, year) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_10005.created_at) - 1) AS listing__created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_6 ) subq_7 WHERE subq_7.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multiple_metrics_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multiple_metrics_no_dimensions__plan0_optimized.sql index a19c9a983b..684d18adf2 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multiple_metrics_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multiple_metrics_no_dimensions__plan0_optimized.sql @@ -25,6 +25,6 @@ CROSS JOIN ( -- Compute Metrics via Expressions SELECT SUM(1) AS listings - FROM ***************************.dim_listings_latest listings_latest_src_10004 + FROM ***************************.dim_listings_latest listings_latest_src_10005 WHERE DATE_TRUNC(created_at, day) BETWEEN '2020-01-01' AND '2020-01-01' ) subq_23 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_partitioned_join__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_partitioned_join__plan0.sql index f63d3129c8..cc15e6c1e1 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_partitioned_join__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_partitioned_join__plan0.sql @@ -96,56 +96,56 @@ FROM ( -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , DATE_TRUNC(id_verifications_src_10003.ds, day) AS ds__day - , DATE_TRUNC(id_verifications_src_10003.ds, isoweek) AS ds__week - , DATE_TRUNC(id_verifications_src_10003.ds, month) AS ds__month - , DATE_TRUNC(id_verifications_src_10003.ds, quarter) AS ds__quarter - , DATE_TRUNC(id_verifications_src_10003.ds, year) AS ds__year - , EXTRACT(year FROM id_verifications_src_10003.ds) AS ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds) AS ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds) AS ds__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM id_verifications_src_10003.ds) = 1, 7, EXTRACT(dayofweek FROM id_verifications_src_10003.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM id_verifications_src_10003.ds) AS ds__extract_doy - , DATE_TRUNC(id_verifications_src_10003.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(id_verifications_src_10003.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(id_verifications_src_10003.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(id_verifications_src_10003.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(id_verifications_src_10003.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM id_verifications_src_10003.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM id_verifications_src_10003.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_doy - , id_verifications_src_10003.verification_type - , DATE_TRUNC(id_verifications_src_10003.ds, day) AS verification__ds__day - , DATE_TRUNC(id_verifications_src_10003.ds, isoweek) AS verification__ds__week - , DATE_TRUNC(id_verifications_src_10003.ds, month) AS verification__ds__month - , DATE_TRUNC(id_verifications_src_10003.ds, quarter) AS verification__ds__quarter - , DATE_TRUNC(id_verifications_src_10003.ds, year) AS verification__ds__year - , EXTRACT(year FROM id_verifications_src_10003.ds) AS verification__ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds) AS verification__ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds) AS verification__ds__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds) AS verification__ds__extract_day - , IF(EXTRACT(dayofweek FROM id_verifications_src_10003.ds) = 1, 7, EXTRACT(dayofweek FROM id_verifications_src_10003.ds) - 1) AS verification__ds__extract_dow - , EXTRACT(dayofyear FROM id_verifications_src_10003.ds) AS verification__ds__extract_doy - , DATE_TRUNC(id_verifications_src_10003.ds_partitioned, day) AS verification__ds_partitioned__day - , DATE_TRUNC(id_verifications_src_10003.ds_partitioned, isoweek) AS verification__ds_partitioned__week - , DATE_TRUNC(id_verifications_src_10003.ds_partitioned, month) AS verification__ds_partitioned__month - , DATE_TRUNC(id_verifications_src_10003.ds_partitioned, quarter) AS verification__ds_partitioned__quarter - , DATE_TRUNC(id_verifications_src_10003.ds_partitioned, year) AS verification__ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM id_verifications_src_10003.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM id_verifications_src_10003.ds_partitioned) - 1) AS verification__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_doy - , id_verifications_src_10003.verification_type AS verification__verification_type - , id_verifications_src_10003.verification_id AS verification - , id_verifications_src_10003.user_id AS user - , id_verifications_src_10003.user_id AS verification__user - FROM ***************************.fct_id_verifications id_verifications_src_10003 + , DATE_TRUNC(id_verifications_src_10004.ds, day) AS ds__day + , DATE_TRUNC(id_verifications_src_10004.ds, isoweek) AS ds__week + , DATE_TRUNC(id_verifications_src_10004.ds, month) AS ds__month + , DATE_TRUNC(id_verifications_src_10004.ds, quarter) AS ds__quarter + , DATE_TRUNC(id_verifications_src_10004.ds, year) AS ds__year + , EXTRACT(year FROM id_verifications_src_10004.ds) AS ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds) AS ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds) AS ds__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM id_verifications_src_10004.ds) = 1, 7, EXTRACT(dayofweek FROM id_verifications_src_10004.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM id_verifications_src_10004.ds) AS ds__extract_doy + , DATE_TRUNC(id_verifications_src_10004.ds_partitioned, day) AS ds_partitioned__day + , DATE_TRUNC(id_verifications_src_10004.ds_partitioned, isoweek) AS ds_partitioned__week + , DATE_TRUNC(id_verifications_src_10004.ds_partitioned, month) AS ds_partitioned__month + , DATE_TRUNC(id_verifications_src_10004.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATE_TRUNC(id_verifications_src_10004.ds_partitioned, year) AS ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM id_verifications_src_10004.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM id_verifications_src_10004.ds_partitioned) - 1) AS ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_doy + , id_verifications_src_10004.verification_type + , DATE_TRUNC(id_verifications_src_10004.ds, day) AS verification__ds__day + , DATE_TRUNC(id_verifications_src_10004.ds, isoweek) AS verification__ds__week + , DATE_TRUNC(id_verifications_src_10004.ds, month) AS verification__ds__month + , DATE_TRUNC(id_verifications_src_10004.ds, quarter) AS verification__ds__quarter + , DATE_TRUNC(id_verifications_src_10004.ds, year) AS verification__ds__year + , EXTRACT(year FROM id_verifications_src_10004.ds) AS verification__ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds) AS verification__ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds) AS verification__ds__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds) AS verification__ds__extract_day + , IF(EXTRACT(dayofweek FROM id_verifications_src_10004.ds) = 1, 7, EXTRACT(dayofweek FROM id_verifications_src_10004.ds) - 1) AS verification__ds__extract_dow + , EXTRACT(dayofyear FROM id_verifications_src_10004.ds) AS verification__ds__extract_doy + , DATE_TRUNC(id_verifications_src_10004.ds_partitioned, day) AS verification__ds_partitioned__day + , DATE_TRUNC(id_verifications_src_10004.ds_partitioned, isoweek) AS verification__ds_partitioned__week + , DATE_TRUNC(id_verifications_src_10004.ds_partitioned, month) AS verification__ds_partitioned__month + , DATE_TRUNC(id_verifications_src_10004.ds_partitioned, quarter) AS verification__ds_partitioned__quarter + , DATE_TRUNC(id_verifications_src_10004.ds_partitioned, year) AS verification__ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM id_verifications_src_10004.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM id_verifications_src_10004.ds_partitioned) - 1) AS verification__ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_doy + , id_verifications_src_10004.verification_type AS verification__verification_type + , id_verifications_src_10004.verification_id AS verification + , id_verifications_src_10004.user_id AS user + , id_verifications_src_10004.user_id AS verification__user + FROM ***************************.fct_id_verifications id_verifications_src_10004 ) subq_0 ) subq_1 ) subq_2 @@ -159,76 +159,76 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT - DATE_TRUNC(users_ds_source_src_10007.ds, day) AS ds__day - , DATE_TRUNC(users_ds_source_src_10007.ds, isoweek) AS ds__week - , DATE_TRUNC(users_ds_source_src_10007.ds, month) AS ds__month - , DATE_TRUNC(users_ds_source_src_10007.ds, quarter) AS ds__quarter - , DATE_TRUNC(users_ds_source_src_10007.ds, year) AS ds__year - , EXTRACT(year FROM users_ds_source_src_10007.ds) AS ds__extract_year - , EXTRACT(quarter FROM users_ds_source_src_10007.ds) AS ds__extract_quarter - , EXTRACT(month FROM users_ds_source_src_10007.ds) AS ds__extract_month - , EXTRACT(day FROM users_ds_source_src_10007.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM users_ds_source_src_10007.ds) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_10007.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM users_ds_source_src_10007.ds) AS ds__extract_doy - , DATE_TRUNC(users_ds_source_src_10007.created_at, day) AS created_at__day - , DATE_TRUNC(users_ds_source_src_10007.created_at, isoweek) AS created_at__week - , DATE_TRUNC(users_ds_source_src_10007.created_at, month) AS created_at__month - , DATE_TRUNC(users_ds_source_src_10007.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(users_ds_source_src_10007.created_at, year) AS created_at__year - , EXTRACT(year FROM users_ds_source_src_10007.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_10007.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_10007.created_at) AS created_at__extract_month - , EXTRACT(day FROM users_ds_source_src_10007.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM users_ds_source_src_10007.created_at) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_10007.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM users_ds_source_src_10007.created_at) AS created_at__extract_doy - , DATE_TRUNC(users_ds_source_src_10007.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(users_ds_source_src_10007.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(users_ds_source_src_10007.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(users_ds_source_src_10007.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(users_ds_source_src_10007.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM users_ds_source_src_10007.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_10007.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_doy - , users_ds_source_src_10007.home_state - , DATE_TRUNC(users_ds_source_src_10007.ds, day) AS user__ds__day - , DATE_TRUNC(users_ds_source_src_10007.ds, isoweek) AS user__ds__week - , DATE_TRUNC(users_ds_source_src_10007.ds, month) AS user__ds__month - , DATE_TRUNC(users_ds_source_src_10007.ds, quarter) AS user__ds__quarter - , DATE_TRUNC(users_ds_source_src_10007.ds, year) AS user__ds__year - , EXTRACT(year FROM users_ds_source_src_10007.ds) AS user__ds__extract_year - , EXTRACT(quarter FROM users_ds_source_src_10007.ds) AS user__ds__extract_quarter - , EXTRACT(month FROM users_ds_source_src_10007.ds) AS user__ds__extract_month - , EXTRACT(day FROM users_ds_source_src_10007.ds) AS user__ds__extract_day - , IF(EXTRACT(dayofweek FROM users_ds_source_src_10007.ds) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_10007.ds) - 1) AS user__ds__extract_dow - , EXTRACT(dayofyear FROM users_ds_source_src_10007.ds) AS user__ds__extract_doy - , DATE_TRUNC(users_ds_source_src_10007.created_at, day) AS user__created_at__day - , DATE_TRUNC(users_ds_source_src_10007.created_at, isoweek) AS user__created_at__week - , DATE_TRUNC(users_ds_source_src_10007.created_at, month) AS user__created_at__month - , DATE_TRUNC(users_ds_source_src_10007.created_at, quarter) AS user__created_at__quarter - , DATE_TRUNC(users_ds_source_src_10007.created_at, year) AS user__created_at__year - , EXTRACT(year FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_month - , EXTRACT(day FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_day - , IF(EXTRACT(dayofweek FROM users_ds_source_src_10007.created_at) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_10007.created_at) - 1) AS user__created_at__extract_dow - , EXTRACT(dayofyear FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_doy - , DATE_TRUNC(users_ds_source_src_10007.ds_partitioned, day) AS user__ds_partitioned__day - , DATE_TRUNC(users_ds_source_src_10007.ds_partitioned, isoweek) AS user__ds_partitioned__week - , DATE_TRUNC(users_ds_source_src_10007.ds_partitioned, month) AS user__ds_partitioned__month - , DATE_TRUNC(users_ds_source_src_10007.ds_partitioned, quarter) AS user__ds_partitioned__quarter - , DATE_TRUNC(users_ds_source_src_10007.ds_partitioned, year) AS user__ds_partitioned__year - , EXTRACT(year FROM users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__extract_year - , EXTRACT(quarter FROM users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__extract_quarter - , EXTRACT(month FROM users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__extract_month - , EXTRACT(day FROM users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM users_ds_source_src_10007.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_10007.ds_partitioned) - 1) AS user__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__extract_doy - , users_ds_source_src_10007.home_state AS user__home_state - , users_ds_source_src_10007.user_id AS user - FROM ***************************.dim_users users_ds_source_src_10007 + DATE_TRUNC(users_ds_source_src_10008.ds, day) AS ds__day + , DATE_TRUNC(users_ds_source_src_10008.ds, isoweek) AS ds__week + , DATE_TRUNC(users_ds_source_src_10008.ds, month) AS ds__month + , DATE_TRUNC(users_ds_source_src_10008.ds, quarter) AS ds__quarter + , DATE_TRUNC(users_ds_source_src_10008.ds, year) AS ds__year + , EXTRACT(year FROM users_ds_source_src_10008.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_10008.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_10008.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_10008.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_10008.ds) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_10008.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_10008.ds) AS ds__extract_doy + , DATE_TRUNC(users_ds_source_src_10008.created_at, day) AS created_at__day + , DATE_TRUNC(users_ds_source_src_10008.created_at, isoweek) AS created_at__week + , DATE_TRUNC(users_ds_source_src_10008.created_at, month) AS created_at__month + , DATE_TRUNC(users_ds_source_src_10008.created_at, quarter) AS created_at__quarter + , DATE_TRUNC(users_ds_source_src_10008.created_at, year) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_10008.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_10008.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_10008.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_10008.created_at) AS created_at__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_10008.created_at) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_10008.created_at) - 1) AS created_at__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_10008.created_at) AS created_at__extract_doy + , DATE_TRUNC(users_ds_source_src_10008.ds_partitioned, day) AS ds_partitioned__day + , DATE_TRUNC(users_ds_source_src_10008.ds_partitioned, isoweek) AS ds_partitioned__week + , DATE_TRUNC(users_ds_source_src_10008.ds_partitioned, month) AS ds_partitioned__month + , DATE_TRUNC(users_ds_source_src_10008.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATE_TRUNC(users_ds_source_src_10008.ds_partitioned, year) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_10008.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_10008.ds_partitioned) - 1) AS ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_10008.home_state + , DATE_TRUNC(users_ds_source_src_10008.ds, day) AS user__ds__day + , DATE_TRUNC(users_ds_source_src_10008.ds, isoweek) AS user__ds__week + , DATE_TRUNC(users_ds_source_src_10008.ds, month) AS user__ds__month + , DATE_TRUNC(users_ds_source_src_10008.ds, quarter) AS user__ds__quarter + , DATE_TRUNC(users_ds_source_src_10008.ds, year) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_10008.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_10008.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_10008.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_10008.ds) AS user__ds__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_10008.ds) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_10008.ds) - 1) AS user__ds__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_10008.ds) AS user__ds__extract_doy + , DATE_TRUNC(users_ds_source_src_10008.created_at, day) AS user__created_at__day + , DATE_TRUNC(users_ds_source_src_10008.created_at, isoweek) AS user__created_at__week + , DATE_TRUNC(users_ds_source_src_10008.created_at, month) AS user__created_at__month + , DATE_TRUNC(users_ds_source_src_10008.created_at, quarter) AS user__created_at__quarter + , DATE_TRUNC(users_ds_source_src_10008.created_at, year) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_10008.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_10008.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_10008.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_10008.created_at) AS user__created_at__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_10008.created_at) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_10008.created_at) - 1) AS user__created_at__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_10008.created_at) AS user__created_at__extract_doy + , DATE_TRUNC(users_ds_source_src_10008.ds_partitioned, day) AS user__ds_partitioned__day + , DATE_TRUNC(users_ds_source_src_10008.ds_partitioned, isoweek) AS user__ds_partitioned__week + , DATE_TRUNC(users_ds_source_src_10008.ds_partitioned, month) AS user__ds_partitioned__month + , DATE_TRUNC(users_ds_source_src_10008.ds_partitioned, quarter) AS user__ds_partitioned__quarter + , DATE_TRUNC(users_ds_source_src_10008.ds_partitioned, year) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_10008.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_10008.ds_partitioned) - 1) AS user__ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_10008.home_state AS user__home_state + , users_ds_source_src_10008.user_id AS user + FROM ***************************.dim_users users_ds_source_src_10008 ) subq_3 ) subq_4 ON diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_partitioned_join__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_partitioned_join__plan0_optimized.sql index 9b2d6d25b0..e873089240 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_partitioned_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_partitioned_join__plan0_optimized.sql @@ -4,7 +4,7 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - users_ds_source_src_10007.home_state AS user__home_state + users_ds_source_src_10008.home_state AS user__home_state , SUM(subq_10.identity_verifications) AS identity_verifications FROM ( -- Read Elements From Semantic Model 'id_verifications' @@ -15,15 +15,15 @@ FROM ( DATE_TRUNC(ds_partitioned, day) AS ds_partitioned__day , user_id AS user , 1 AS identity_verifications - FROM ***************************.fct_id_verifications id_verifications_src_10003 + FROM ***************************.fct_id_verifications id_verifications_src_10004 ) subq_10 LEFT OUTER JOIN - ***************************.dim_users users_ds_source_src_10007 + ***************************.dim_users users_ds_source_src_10008 ON ( - subq_10.user = users_ds_source_src_10007.user_id + subq_10.user = users_ds_source_src_10008.user_id ) AND ( - subq_10.ds_partitioned__day = DATE_TRUNC(users_ds_source_src_10007.ds_partitioned, day) + subq_10.ds_partitioned__day = DATE_TRUNC(users_ds_source_src_10008.ds_partitioned, day) ) GROUP BY user__home_state diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_distinct_values__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_distinct_values__plan0.sql index e619b12f0c..748cfafbc5 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_distinct_values__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_distinct_values__plan0.sql @@ -69,62 +69,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_0 WHERE listing__country_latest = 'us' ) subq_1 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_distinct_values__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_distinct_values__plan0_optimized.sql index ec0d94dac2..53c7bf823f 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_distinct_values__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_distinct_values__plan0_optimized.sql @@ -8,7 +8,7 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT country AS listing__country_latest - FROM ***************************.dim_listings_latest listings_latest_src_10004 + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_3 WHERE listing__country_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_on_join_dim__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_on_join_dim__plan0.sql index b9cfda8758..239c0cc527 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_on_join_dim__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_on_join_dim__plan0.sql @@ -316,62 +316,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_3 ) subq_4 ) subq_5 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql index 19b1b78329..d00b32fb24 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql @@ -12,7 +12,7 @@ FROM ( -- ['bookings', 'booking__is_instant', 'listing__country_latest'] SELECT subq_13.booking__is_instant AS booking__is_instant - , listings_latest_src_10004.country AS listing__country_latest + , listings_latest_src_10005.country AS listing__country_latest , subq_13.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -26,9 +26,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_13 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_13.listing = listings_latest_src_10004.listing_id + subq_13.listing = listings_latest_src_10005.listing_id ) subq_18 WHERE listing__country_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_join_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_join_to_scd_dimension__plan0.sql index 3dce9387f2..114fc5d5a3 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_join_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_join_to_scd_dimension__plan0.sql @@ -142,87 +142,87 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_10015.booking_value - , bookings_source_src_10015.guest_id AS bookers - , bookings_source_src_10015.booking_value AS average_booking_value - , bookings_source_src_10015.booking_value AS booking_payments - , bookings_source_src_10015.is_instant - , DATE_TRUNC('day', bookings_source_src_10015.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_10015.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_10015.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_10015.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_10015.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_10015.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_10015.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_10015.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_10015.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS paid_at__extract_doy - , bookings_source_src_10015.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_10015.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_10015.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_10015.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_10015.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_10015.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_10015.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_10015.listing_id AS listing - , bookings_source_src_10015.guest_id AS guest - , bookings_source_src_10015.host_id AS host - , bookings_source_src_10015.guest_id AS user - , bookings_source_src_10015.listing_id AS booking__listing - , bookings_source_src_10015.guest_id AS booking__guest - , bookings_source_src_10015.host_id AS booking__host - , bookings_source_src_10015.guest_id AS booking__user - FROM ***************************.fct_bookings bookings_source_src_10015 + , bookings_source_src_10017.booking_value + , bookings_source_src_10017.guest_id AS bookers + , bookings_source_src_10017.booking_value AS average_booking_value + , bookings_source_src_10017.booking_value AS booking_payments + , bookings_source_src_10017.is_instant + , DATE_TRUNC('day', bookings_source_src_10017.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_10017.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_10017.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_10017.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_10017.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_10017.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_10017.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_10017.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_10017.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_10017.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_10017.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_10017.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.paid_at) AS paid_at__extract_doy + , bookings_source_src_10017.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_10017.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_10017.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_10017.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_10017.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_10017.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_10017.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_10017.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_10017.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_10017.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_10017.listing_id AS listing + , bookings_source_src_10017.guest_id AS guest + , bookings_source_src_10017.host_id AS host + , bookings_source_src_10017.guest_id AS user + , bookings_source_src_10017.listing_id AS booking__listing + , bookings_source_src_10017.guest_id AS booking__guest + , bookings_source_src_10017.host_id AS booking__host + , bookings_source_src_10017.guest_id AS booking__user + FROM ***************************.fct_bookings bookings_source_src_10017 ) subq_0 ) subq_1 ) subq_2 @@ -237,60 +237,60 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'listings' SELECT - listings_src_10017.active_from AS window_start__day - , DATE_TRUNC('week', listings_src_10017.active_from) AS window_start__week - , DATE_TRUNC('month', listings_src_10017.active_from) AS window_start__month - , DATE_TRUNC('quarter', listings_src_10017.active_from) AS window_start__quarter - , DATE_TRUNC('year', listings_src_10017.active_from) AS window_start__year - , EXTRACT(year FROM listings_src_10017.active_from) AS window_start__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_from) AS window_start__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_from) AS window_start__extract_month - , EXTRACT(day FROM listings_src_10017.active_from) AS window_start__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_src_10017.active_from) AS window_start__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_from) AS window_start__extract_doy - , listings_src_10017.active_to AS window_end__day - , DATE_TRUNC('week', listings_src_10017.active_to) AS window_end__week - , DATE_TRUNC('month', listings_src_10017.active_to) AS window_end__month - , DATE_TRUNC('quarter', listings_src_10017.active_to) AS window_end__quarter - , DATE_TRUNC('year', listings_src_10017.active_to) AS window_end__year - , EXTRACT(year FROM listings_src_10017.active_to) AS window_end__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_to) AS window_end__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_to) AS window_end__extract_month - , EXTRACT(day FROM listings_src_10017.active_to) AS window_end__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_src_10017.active_to) AS window_end__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_to) AS window_end__extract_doy - , listings_src_10017.country - , listings_src_10017.is_lux - , listings_src_10017.capacity - , listings_src_10017.active_from AS listing__window_start__day - , DATE_TRUNC('week', listings_src_10017.active_from) AS listing__window_start__week - , DATE_TRUNC('month', listings_src_10017.active_from) AS listing__window_start__month - , DATE_TRUNC('quarter', listings_src_10017.active_from) AS listing__window_start__quarter - , DATE_TRUNC('year', listings_src_10017.active_from) AS listing__window_start__year - , EXTRACT(year FROM listings_src_10017.active_from) AS listing__window_start__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_from) AS listing__window_start__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_from) AS listing__window_start__extract_month - , EXTRACT(day FROM listings_src_10017.active_from) AS listing__window_start__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_src_10017.active_from) AS listing__window_start__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_from) AS listing__window_start__extract_doy - , listings_src_10017.active_to AS listing__window_end__day - , DATE_TRUNC('week', listings_src_10017.active_to) AS listing__window_end__week - , DATE_TRUNC('month', listings_src_10017.active_to) AS listing__window_end__month - , DATE_TRUNC('quarter', listings_src_10017.active_to) AS listing__window_end__quarter - , DATE_TRUNC('year', listings_src_10017.active_to) AS listing__window_end__year - , EXTRACT(year FROM listings_src_10017.active_to) AS listing__window_end__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_to) AS listing__window_end__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_to) AS listing__window_end__extract_month - , EXTRACT(day FROM listings_src_10017.active_to) AS listing__window_end__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_src_10017.active_to) AS listing__window_end__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_to) AS listing__window_end__extract_doy - , listings_src_10017.country AS listing__country - , listings_src_10017.is_lux AS listing__is_lux - , listings_src_10017.capacity AS listing__capacity - , listings_src_10017.listing_id AS listing - , listings_src_10017.user_id AS user - , listings_src_10017.user_id AS listing__user - FROM ***************************.dim_listings listings_src_10017 + listings_src_10019.active_from AS window_start__day + , DATE_TRUNC('week', listings_src_10019.active_from) AS window_start__week + , DATE_TRUNC('month', listings_src_10019.active_from) AS window_start__month + , DATE_TRUNC('quarter', listings_src_10019.active_from) AS window_start__quarter + , DATE_TRUNC('year', listings_src_10019.active_from) AS window_start__year + , EXTRACT(year FROM listings_src_10019.active_from) AS window_start__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_from) AS window_start__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_from) AS window_start__extract_month + , EXTRACT(day FROM listings_src_10019.active_from) AS window_start__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_src_10019.active_from) AS window_start__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_from) AS window_start__extract_doy + , listings_src_10019.active_to AS window_end__day + , DATE_TRUNC('week', listings_src_10019.active_to) AS window_end__week + , DATE_TRUNC('month', listings_src_10019.active_to) AS window_end__month + , DATE_TRUNC('quarter', listings_src_10019.active_to) AS window_end__quarter + , DATE_TRUNC('year', listings_src_10019.active_to) AS window_end__year + , EXTRACT(year FROM listings_src_10019.active_to) AS window_end__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_to) AS window_end__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_to) AS window_end__extract_month + , EXTRACT(day FROM listings_src_10019.active_to) AS window_end__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_src_10019.active_to) AS window_end__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_to) AS window_end__extract_doy + , listings_src_10019.country + , listings_src_10019.is_lux + , listings_src_10019.capacity + , listings_src_10019.active_from AS listing__window_start__day + , DATE_TRUNC('week', listings_src_10019.active_from) AS listing__window_start__week + , DATE_TRUNC('month', listings_src_10019.active_from) AS listing__window_start__month + , DATE_TRUNC('quarter', listings_src_10019.active_from) AS listing__window_start__quarter + , DATE_TRUNC('year', listings_src_10019.active_from) AS listing__window_start__year + , EXTRACT(year FROM listings_src_10019.active_from) AS listing__window_start__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_from) AS listing__window_start__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_from) AS listing__window_start__extract_month + , EXTRACT(day FROM listings_src_10019.active_from) AS listing__window_start__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_src_10019.active_from) AS listing__window_start__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_from) AS listing__window_start__extract_doy + , listings_src_10019.active_to AS listing__window_end__day + , DATE_TRUNC('week', listings_src_10019.active_to) AS listing__window_end__week + , DATE_TRUNC('month', listings_src_10019.active_to) AS listing__window_end__month + , DATE_TRUNC('quarter', listings_src_10019.active_to) AS listing__window_end__quarter + , DATE_TRUNC('year', listings_src_10019.active_to) AS listing__window_end__year + , EXTRACT(year FROM listings_src_10019.active_to) AS listing__window_end__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_to) AS listing__window_end__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_to) AS listing__window_end__extract_month + , EXTRACT(day FROM listings_src_10019.active_to) AS listing__window_end__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_src_10019.active_to) AS listing__window_end__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_to) AS listing__window_end__extract_doy + , listings_src_10019.country AS listing__country + , listings_src_10019.is_lux AS listing__is_lux + , listings_src_10019.capacity AS listing__capacity + , listings_src_10019.listing_id AS listing + , listings_src_10019.user_id AS user + , listings_src_10019.user_id AS listing__user + FROM ***************************.dim_listings listings_src_10019 ) subq_3 ) subq_4 ON diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_join_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_join_to_scd_dimension__plan0_optimized.sql index db1199fc2e..662445e5ef 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_join_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_join_to_scd_dimension__plan0_optimized.sql @@ -12,7 +12,7 @@ FROM ( -- ['bookings', 'listing__capacity', 'metric_time__day'] SELECT subq_12.metric_time__day AS metric_time__day - , listings_src_10017.capacity AS listing__capacity + , listings_src_10019.capacity AS listing__capacity , subq_12.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -23,21 +23,21 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_10015 + FROM ***************************.fct_bookings bookings_source_src_10017 ) subq_12 LEFT OUTER JOIN - ***************************.dim_listings listings_src_10017 + ***************************.dim_listings listings_src_10019 ON ( - subq_12.listing = listings_src_10017.listing_id + subq_12.listing = listings_src_10019.listing_id ) AND ( ( - subq_12.metric_time__day >= listings_src_10017.active_from + subq_12.metric_time__day >= listings_src_10019.active_from ) AND ( ( - subq_12.metric_time__day < listings_src_10017.active_to + subq_12.metric_time__day < listings_src_10019.active_to ) OR ( - listings_src_10017.active_to IS NULL + listings_src_10019.active_to IS NULL ) ) ) diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_local_dimension_using_local_entity__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_local_dimension_using_local_entity__plan0.sql index 2cdc819d2e..900258e2a0 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_local_dimension_using_local_entity__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_local_dimension_using_local_entity__plan0.sql @@ -87,62 +87,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_0 ) subq_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_local_dimension_using_local_entity__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_local_dimension_using_local_entity__plan0_optimized.sql index f7932552c3..2c5690447e 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_local_dimension_using_local_entity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_local_dimension_using_local_entity__plan0_optimized.sql @@ -11,7 +11,7 @@ FROM ( SELECT country AS listing__country_latest , 1 AS listings - FROM ***************************.dim_listings_latest listings_latest_src_10004 + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_6 GROUP BY listing__country_latest diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0.sql index 373cca1728..d73ee4f012 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0.sql @@ -328,62 +328,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_3 ) subq_4 ) subq_5 @@ -717,62 +717,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_15 ) subq_16 ) subq_17 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0_optimized.sql index 3c0c641be9..5581a37a67 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0_optimized.sql @@ -24,13 +24,13 @@ FROM ( -- ['average_booking_value', 'listing__is_lux_latest', 'metric_time__day'] SELECT DATE_TRUNC('day', bookings_source_src_10001.ds) AS metric_time__day - , listings_latest_src_10004.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest , bookings_source_src_10001.booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_10001 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - bookings_source_src_10001.listing_id = listings_latest_src_10004.listing_id + bookings_source_src_10001.listing_id = listings_latest_src_10005.listing_id ) subq_37 WHERE listing__is_lux_latest GROUP BY @@ -51,7 +51,7 @@ FROM ( -- ['bookings', 'listing__is_lux_latest', 'metric_time__day'] SELECT subq_44.metric_time__day AS metric_time__day - , listings_latest_src_10004.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest , subq_44.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -65,9 +65,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_44 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_44.listing = listings_latest_src_10004.listing_id + subq_44.listing = listings_latest_src_10005.listing_id ) subq_49 WHERE listing__is_lux_latest GROUP BY diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql index 12cf835a45..0ddfc222b3 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql @@ -304,62 +304,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_5 ) subq_6 ) subq_7 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql index bd5b5c24ee..1e16df6c0d 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql @@ -22,5 +22,5 @@ CROSS JOIN ( -- Compute Metrics via Expressions SELECT SUM(1) AS listings - FROM ***************************.dim_listings_latest listings_latest_src_10004 + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_20 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0.sql index f1e0646c86..e232b96c39 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0.sql @@ -132,87 +132,87 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_10015.booking_value - , bookings_source_src_10015.guest_id AS bookers - , bookings_source_src_10015.booking_value AS average_booking_value - , bookings_source_src_10015.booking_value AS booking_payments - , bookings_source_src_10015.is_instant - , DATE_TRUNC('day', bookings_source_src_10015.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_10015.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_10015.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_10015.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_10015.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_10015.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_10015.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_10015.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_10015.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS paid_at__extract_doy - , bookings_source_src_10015.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_10015.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_10015.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_10015.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_10015.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_10015.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_10015.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_10015.listing_id AS listing - , bookings_source_src_10015.guest_id AS guest - , bookings_source_src_10015.host_id AS host - , bookings_source_src_10015.guest_id AS user - , bookings_source_src_10015.listing_id AS booking__listing - , bookings_source_src_10015.guest_id AS booking__guest - , bookings_source_src_10015.host_id AS booking__host - , bookings_source_src_10015.guest_id AS booking__user - FROM ***************************.fct_bookings bookings_source_src_10015 + , bookings_source_src_10017.booking_value + , bookings_source_src_10017.guest_id AS bookers + , bookings_source_src_10017.booking_value AS average_booking_value + , bookings_source_src_10017.booking_value AS booking_payments + , bookings_source_src_10017.is_instant + , DATE_TRUNC('day', bookings_source_src_10017.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_10017.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_10017.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_10017.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_10017.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_10017.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_10017.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_10017.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_10017.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_10017.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_10017.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_10017.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.paid_at) AS paid_at__extract_doy + , bookings_source_src_10017.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_10017.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_10017.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_10017.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_10017.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_10017.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_10017.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_10017.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_10017.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_10017.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_10017.listing_id AS listing + , bookings_source_src_10017.guest_id AS guest + , bookings_source_src_10017.host_id AS host + , bookings_source_src_10017.guest_id AS user + , bookings_source_src_10017.listing_id AS booking__listing + , bookings_source_src_10017.guest_id AS booking__guest + , bookings_source_src_10017.host_id AS booking__host + , bookings_source_src_10017.guest_id AS booking__user + FROM ***************************.fct_bookings bookings_source_src_10017 ) subq_0 ) subq_1 ) subq_2 @@ -295,60 +295,60 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'listings' SELECT - listings_src_10017.active_from AS window_start__day - , DATE_TRUNC('week', listings_src_10017.active_from) AS window_start__week - , DATE_TRUNC('month', listings_src_10017.active_from) AS window_start__month - , DATE_TRUNC('quarter', listings_src_10017.active_from) AS window_start__quarter - , DATE_TRUNC('year', listings_src_10017.active_from) AS window_start__year - , EXTRACT(year FROM listings_src_10017.active_from) AS window_start__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_from) AS window_start__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_from) AS window_start__extract_month - , EXTRACT(day FROM listings_src_10017.active_from) AS window_start__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_src_10017.active_from) AS window_start__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_from) AS window_start__extract_doy - , listings_src_10017.active_to AS window_end__day - , DATE_TRUNC('week', listings_src_10017.active_to) AS window_end__week - , DATE_TRUNC('month', listings_src_10017.active_to) AS window_end__month - , DATE_TRUNC('quarter', listings_src_10017.active_to) AS window_end__quarter - , DATE_TRUNC('year', listings_src_10017.active_to) AS window_end__year - , EXTRACT(year FROM listings_src_10017.active_to) AS window_end__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_to) AS window_end__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_to) AS window_end__extract_month - , EXTRACT(day FROM listings_src_10017.active_to) AS window_end__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_src_10017.active_to) AS window_end__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_to) AS window_end__extract_doy - , listings_src_10017.country - , listings_src_10017.is_lux - , listings_src_10017.capacity - , listings_src_10017.active_from AS listing__window_start__day - , DATE_TRUNC('week', listings_src_10017.active_from) AS listing__window_start__week - , DATE_TRUNC('month', listings_src_10017.active_from) AS listing__window_start__month - , DATE_TRUNC('quarter', listings_src_10017.active_from) AS listing__window_start__quarter - , DATE_TRUNC('year', listings_src_10017.active_from) AS listing__window_start__year - , EXTRACT(year FROM listings_src_10017.active_from) AS listing__window_start__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_from) AS listing__window_start__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_from) AS listing__window_start__extract_month - , EXTRACT(day FROM listings_src_10017.active_from) AS listing__window_start__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_src_10017.active_from) AS listing__window_start__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_from) AS listing__window_start__extract_doy - , listings_src_10017.active_to AS listing__window_end__day - , DATE_TRUNC('week', listings_src_10017.active_to) AS listing__window_end__week - , DATE_TRUNC('month', listings_src_10017.active_to) AS listing__window_end__month - , DATE_TRUNC('quarter', listings_src_10017.active_to) AS listing__window_end__quarter - , DATE_TRUNC('year', listings_src_10017.active_to) AS listing__window_end__year - , EXTRACT(year FROM listings_src_10017.active_to) AS listing__window_end__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_to) AS listing__window_end__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_to) AS listing__window_end__extract_month - , EXTRACT(day FROM listings_src_10017.active_to) AS listing__window_end__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_src_10017.active_to) AS listing__window_end__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_to) AS listing__window_end__extract_doy - , listings_src_10017.country AS listing__country - , listings_src_10017.is_lux AS listing__is_lux - , listings_src_10017.capacity AS listing__capacity - , listings_src_10017.listing_id AS listing - , listings_src_10017.user_id AS user - , listings_src_10017.user_id AS listing__user - FROM ***************************.dim_listings listings_src_10017 + listings_src_10019.active_from AS window_start__day + , DATE_TRUNC('week', listings_src_10019.active_from) AS window_start__week + , DATE_TRUNC('month', listings_src_10019.active_from) AS window_start__month + , DATE_TRUNC('quarter', listings_src_10019.active_from) AS window_start__quarter + , DATE_TRUNC('year', listings_src_10019.active_from) AS window_start__year + , EXTRACT(year FROM listings_src_10019.active_from) AS window_start__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_from) AS window_start__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_from) AS window_start__extract_month + , EXTRACT(day FROM listings_src_10019.active_from) AS window_start__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_src_10019.active_from) AS window_start__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_from) AS window_start__extract_doy + , listings_src_10019.active_to AS window_end__day + , DATE_TRUNC('week', listings_src_10019.active_to) AS window_end__week + , DATE_TRUNC('month', listings_src_10019.active_to) AS window_end__month + , DATE_TRUNC('quarter', listings_src_10019.active_to) AS window_end__quarter + , DATE_TRUNC('year', listings_src_10019.active_to) AS window_end__year + , EXTRACT(year FROM listings_src_10019.active_to) AS window_end__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_to) AS window_end__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_to) AS window_end__extract_month + , EXTRACT(day FROM listings_src_10019.active_to) AS window_end__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_src_10019.active_to) AS window_end__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_to) AS window_end__extract_doy + , listings_src_10019.country + , listings_src_10019.is_lux + , listings_src_10019.capacity + , listings_src_10019.active_from AS listing__window_start__day + , DATE_TRUNC('week', listings_src_10019.active_from) AS listing__window_start__week + , DATE_TRUNC('month', listings_src_10019.active_from) AS listing__window_start__month + , DATE_TRUNC('quarter', listings_src_10019.active_from) AS listing__window_start__quarter + , DATE_TRUNC('year', listings_src_10019.active_from) AS listing__window_start__year + , EXTRACT(year FROM listings_src_10019.active_from) AS listing__window_start__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_from) AS listing__window_start__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_from) AS listing__window_start__extract_month + , EXTRACT(day FROM listings_src_10019.active_from) AS listing__window_start__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_src_10019.active_from) AS listing__window_start__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_from) AS listing__window_start__extract_doy + , listings_src_10019.active_to AS listing__window_end__day + , DATE_TRUNC('week', listings_src_10019.active_to) AS listing__window_end__week + , DATE_TRUNC('month', listings_src_10019.active_to) AS listing__window_end__month + , DATE_TRUNC('quarter', listings_src_10019.active_to) AS listing__window_end__quarter + , DATE_TRUNC('year', listings_src_10019.active_to) AS listing__window_end__year + , EXTRACT(year FROM listings_src_10019.active_to) AS listing__window_end__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_to) AS listing__window_end__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_to) AS listing__window_end__extract_month + , EXTRACT(day FROM listings_src_10019.active_to) AS listing__window_end__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_src_10019.active_to) AS listing__window_end__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_to) AS listing__window_end__extract_doy + , listings_src_10019.country AS listing__country + , listings_src_10019.is_lux AS listing__is_lux + , listings_src_10019.capacity AS listing__capacity + , listings_src_10019.listing_id AS listing + , listings_src_10019.user_id AS user + , listings_src_10019.user_id AS listing__user + FROM ***************************.dim_listings listings_src_10019 ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: @@ -406,32 +406,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_10021.ds) AS ds__day - , DATE_TRUNC('week', users_latest_src_10021.ds) AS ds__week - , DATE_TRUNC('month', users_latest_src_10021.ds) AS ds__month - , DATE_TRUNC('quarter', users_latest_src_10021.ds) AS ds__quarter - , DATE_TRUNC('year', users_latest_src_10021.ds) AS ds__year - , EXTRACT(year FROM users_latest_src_10021.ds) AS ds__extract_year - , EXTRACT(quarter FROM users_latest_src_10021.ds) AS ds__extract_quarter - , EXTRACT(month FROM users_latest_src_10021.ds) AS ds__extract_month - , EXTRACT(day FROM users_latest_src_10021.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_10021.ds) AS ds__extract_dow - , EXTRACT(doy FROM users_latest_src_10021.ds) AS ds__extract_doy - , users_latest_src_10021.home_state_latest - , DATE_TRUNC('day', users_latest_src_10021.ds) AS user__ds__day - , DATE_TRUNC('week', users_latest_src_10021.ds) AS user__ds__week - , DATE_TRUNC('month', users_latest_src_10021.ds) AS user__ds__month - , DATE_TRUNC('quarter', users_latest_src_10021.ds) AS user__ds__quarter - , DATE_TRUNC('year', users_latest_src_10021.ds) AS user__ds__year - , EXTRACT(year FROM users_latest_src_10021.ds) AS user__ds__extract_year - , EXTRACT(quarter FROM users_latest_src_10021.ds) AS user__ds__extract_quarter - , EXTRACT(month FROM users_latest_src_10021.ds) AS user__ds__extract_month - , EXTRACT(day FROM users_latest_src_10021.ds) AS user__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_10021.ds) AS user__ds__extract_dow - , EXTRACT(doy FROM users_latest_src_10021.ds) AS user__ds__extract_doy - , users_latest_src_10021.home_state_latest AS user__home_state_latest - , users_latest_src_10021.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_10021 + DATE_TRUNC('day', users_latest_src_10023.ds) AS ds__day + , DATE_TRUNC('week', users_latest_src_10023.ds) AS ds__week + , DATE_TRUNC('month', users_latest_src_10023.ds) AS ds__month + , DATE_TRUNC('quarter', users_latest_src_10023.ds) AS ds__quarter + , DATE_TRUNC('year', users_latest_src_10023.ds) AS ds__year + , EXTRACT(year FROM users_latest_src_10023.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_latest_src_10023.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_latest_src_10023.ds) AS ds__extract_month + , EXTRACT(day FROM users_latest_src_10023.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_10023.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_latest_src_10023.ds) AS ds__extract_doy + , users_latest_src_10023.home_state_latest + , DATE_TRUNC('day', users_latest_src_10023.ds) AS user__ds__day + , DATE_TRUNC('week', users_latest_src_10023.ds) AS user__ds__week + , DATE_TRUNC('month', users_latest_src_10023.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_latest_src_10023.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_latest_src_10023.ds) AS user__ds__year + , EXTRACT(year FROM users_latest_src_10023.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_latest_src_10023.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_latest_src_10023.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_latest_src_10023.ds) AS user__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_10023.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_latest_src_10023.ds) AS user__ds__extract_doy + , users_latest_src_10023.home_state_latest AS user__home_state_latest + , users_latest_src_10023.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_10023 ) subq_4 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0_optimized.sql index aa2ad14d34..afba0439d0 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0_optimized.sql @@ -16,22 +16,22 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_10015 + FROM ***************************.fct_bookings bookings_source_src_10017 ) subq_13 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: -- ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] SELECT - listings_src_10017.active_from AS window_start__day - , listings_src_10017.active_to AS window_end__day - , listings_src_10017.listing_id AS listing - , users_latest_src_10021.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings listings_src_10017 + listings_src_10019.active_from AS window_start__day + , listings_src_10019.active_to AS window_end__day + , listings_src_10019.listing_id AS listing + , users_latest_src_10023.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings listings_src_10019 LEFT OUTER JOIN - ***************************.dim_users_latest users_latest_src_10021 + ***************************.dim_users_latest users_latest_src_10023 ON - listings_src_10017.user_id = users_latest_src_10021.user_id + listings_src_10019.user_id = users_latest_src_10023.user_id ) subq_18 ON ( diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0.sql index d32114ddad..12a8394b00 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0.sql @@ -132,87 +132,87 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_10015.booking_value - , bookings_source_src_10015.guest_id AS bookers - , bookings_source_src_10015.booking_value AS average_booking_value - , bookings_source_src_10015.booking_value AS booking_payments - , bookings_source_src_10015.is_instant - , DATE_TRUNC('day', bookings_source_src_10015.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_10015.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_10015.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_10015.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_10015.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_10015.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_10015.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_10015.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_10015.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS paid_at__extract_doy - , bookings_source_src_10015.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_10015.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_10015.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_10015.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_10015.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_10015.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_10015.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_10015.listing_id AS listing - , bookings_source_src_10015.guest_id AS guest - , bookings_source_src_10015.host_id AS host - , bookings_source_src_10015.guest_id AS user - , bookings_source_src_10015.listing_id AS booking__listing - , bookings_source_src_10015.guest_id AS booking__guest - , bookings_source_src_10015.host_id AS booking__host - , bookings_source_src_10015.guest_id AS booking__user - FROM ***************************.fct_bookings bookings_source_src_10015 + , bookings_source_src_10017.booking_value + , bookings_source_src_10017.guest_id AS bookers + , bookings_source_src_10017.booking_value AS average_booking_value + , bookings_source_src_10017.booking_value AS booking_payments + , bookings_source_src_10017.is_instant + , DATE_TRUNC('day', bookings_source_src_10017.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_10017.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_10017.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_10017.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_10017.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_10017.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_10017.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_10017.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_10017.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_10017.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_10017.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_10017.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.paid_at) AS paid_at__extract_doy + , bookings_source_src_10017.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_10017.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_10017.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_10017.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_10017.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_10017.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_10017.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_10017.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_10017.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_10017.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_10017.listing_id AS listing + , bookings_source_src_10017.guest_id AS guest + , bookings_source_src_10017.host_id AS host + , bookings_source_src_10017.guest_id AS user + , bookings_source_src_10017.listing_id AS booking__listing + , bookings_source_src_10017.guest_id AS booking__guest + , bookings_source_src_10017.host_id AS booking__host + , bookings_source_src_10017.guest_id AS booking__user + FROM ***************************.fct_bookings bookings_source_src_10017 ) subq_0 ) subq_1 ) subq_2 @@ -259,10 +259,10 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'lux_listing_mapping' SELECT - lux_listing_mapping_src_10018.listing_id AS listing - , lux_listing_mapping_src_10018.lux_listing_id AS lux_listing - , lux_listing_mapping_src_10018.lux_listing_id AS listing__lux_listing - FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_10018 + lux_listing_mapping_src_10020.listing_id AS listing + , lux_listing_mapping_src_10020.lux_listing_id AS lux_listing + , lux_listing_mapping_src_10020.lux_listing_id AS listing__lux_listing + FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_10020 ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: @@ -364,54 +364,54 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'lux_listings' SELECT - lux_listings_src_10019.valid_from AS window_start__day - , DATE_TRUNC('week', lux_listings_src_10019.valid_from) AS window_start__week - , DATE_TRUNC('month', lux_listings_src_10019.valid_from) AS window_start__month - , DATE_TRUNC('quarter', lux_listings_src_10019.valid_from) AS window_start__quarter - , DATE_TRUNC('year', lux_listings_src_10019.valid_from) AS window_start__year - , EXTRACT(year FROM lux_listings_src_10019.valid_from) AS window_start__extract_year - , EXTRACT(quarter FROM lux_listings_src_10019.valid_from) AS window_start__extract_quarter - , EXTRACT(month FROM lux_listings_src_10019.valid_from) AS window_start__extract_month - , EXTRACT(day FROM lux_listings_src_10019.valid_from) AS window_start__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM lux_listings_src_10019.valid_from) AS window_start__extract_dow - , EXTRACT(doy FROM lux_listings_src_10019.valid_from) AS window_start__extract_doy - , lux_listings_src_10019.valid_to AS window_end__day - , DATE_TRUNC('week', lux_listings_src_10019.valid_to) AS window_end__week - , DATE_TRUNC('month', lux_listings_src_10019.valid_to) AS window_end__month - , DATE_TRUNC('quarter', lux_listings_src_10019.valid_to) AS window_end__quarter - , DATE_TRUNC('year', lux_listings_src_10019.valid_to) AS window_end__year - , EXTRACT(year FROM lux_listings_src_10019.valid_to) AS window_end__extract_year - , EXTRACT(quarter FROM lux_listings_src_10019.valid_to) AS window_end__extract_quarter - , EXTRACT(month FROM lux_listings_src_10019.valid_to) AS window_end__extract_month - , EXTRACT(day FROM lux_listings_src_10019.valid_to) AS window_end__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM lux_listings_src_10019.valid_to) AS window_end__extract_dow - , EXTRACT(doy FROM lux_listings_src_10019.valid_to) AS window_end__extract_doy - , lux_listings_src_10019.is_confirmed_lux - , lux_listings_src_10019.valid_from AS lux_listing__window_start__day - , DATE_TRUNC('week', lux_listings_src_10019.valid_from) AS lux_listing__window_start__week - , DATE_TRUNC('month', lux_listings_src_10019.valid_from) AS lux_listing__window_start__month - , DATE_TRUNC('quarter', lux_listings_src_10019.valid_from) AS lux_listing__window_start__quarter - , DATE_TRUNC('year', lux_listings_src_10019.valid_from) AS lux_listing__window_start__year - , EXTRACT(year FROM lux_listings_src_10019.valid_from) AS lux_listing__window_start__extract_year - , EXTRACT(quarter FROM lux_listings_src_10019.valid_from) AS lux_listing__window_start__extract_quarter - , EXTRACT(month FROM lux_listings_src_10019.valid_from) AS lux_listing__window_start__extract_month - , EXTRACT(day FROM lux_listings_src_10019.valid_from) AS lux_listing__window_start__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM lux_listings_src_10019.valid_from) AS lux_listing__window_start__extract_dow - , EXTRACT(doy FROM lux_listings_src_10019.valid_from) AS lux_listing__window_start__extract_doy - , lux_listings_src_10019.valid_to AS lux_listing__window_end__day - , DATE_TRUNC('week', lux_listings_src_10019.valid_to) AS lux_listing__window_end__week - , DATE_TRUNC('month', lux_listings_src_10019.valid_to) AS lux_listing__window_end__month - , DATE_TRUNC('quarter', lux_listings_src_10019.valid_to) AS lux_listing__window_end__quarter - , DATE_TRUNC('year', lux_listings_src_10019.valid_to) AS lux_listing__window_end__year - , EXTRACT(year FROM lux_listings_src_10019.valid_to) AS lux_listing__window_end__extract_year - , EXTRACT(quarter FROM lux_listings_src_10019.valid_to) AS lux_listing__window_end__extract_quarter - , EXTRACT(month FROM lux_listings_src_10019.valid_to) AS lux_listing__window_end__extract_month - , EXTRACT(day FROM lux_listings_src_10019.valid_to) AS lux_listing__window_end__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM lux_listings_src_10019.valid_to) AS lux_listing__window_end__extract_dow - , EXTRACT(doy FROM lux_listings_src_10019.valid_to) AS lux_listing__window_end__extract_doy - , lux_listings_src_10019.is_confirmed_lux AS lux_listing__is_confirmed_lux - , lux_listings_src_10019.lux_listing_id AS lux_listing - FROM ***************************.dim_lux_listings lux_listings_src_10019 + lux_listings_src_10021.valid_from AS window_start__day + , DATE_TRUNC('week', lux_listings_src_10021.valid_from) AS window_start__week + , DATE_TRUNC('month', lux_listings_src_10021.valid_from) AS window_start__month + , DATE_TRUNC('quarter', lux_listings_src_10021.valid_from) AS window_start__quarter + , DATE_TRUNC('year', lux_listings_src_10021.valid_from) AS window_start__year + , EXTRACT(year FROM lux_listings_src_10021.valid_from) AS window_start__extract_year + , EXTRACT(quarter FROM lux_listings_src_10021.valid_from) AS window_start__extract_quarter + , EXTRACT(month FROM lux_listings_src_10021.valid_from) AS window_start__extract_month + , EXTRACT(day FROM lux_listings_src_10021.valid_from) AS window_start__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM lux_listings_src_10021.valid_from) AS window_start__extract_dow + , EXTRACT(doy FROM lux_listings_src_10021.valid_from) AS window_start__extract_doy + , lux_listings_src_10021.valid_to AS window_end__day + , DATE_TRUNC('week', lux_listings_src_10021.valid_to) AS window_end__week + , DATE_TRUNC('month', lux_listings_src_10021.valid_to) AS window_end__month + , DATE_TRUNC('quarter', lux_listings_src_10021.valid_to) AS window_end__quarter + , DATE_TRUNC('year', lux_listings_src_10021.valid_to) AS window_end__year + , EXTRACT(year FROM lux_listings_src_10021.valid_to) AS window_end__extract_year + , EXTRACT(quarter FROM lux_listings_src_10021.valid_to) AS window_end__extract_quarter + , EXTRACT(month FROM lux_listings_src_10021.valid_to) AS window_end__extract_month + , EXTRACT(day FROM lux_listings_src_10021.valid_to) AS window_end__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM lux_listings_src_10021.valid_to) AS window_end__extract_dow + , EXTRACT(doy FROM lux_listings_src_10021.valid_to) AS window_end__extract_doy + , lux_listings_src_10021.is_confirmed_lux + , lux_listings_src_10021.valid_from AS lux_listing__window_start__day + , DATE_TRUNC('week', lux_listings_src_10021.valid_from) AS lux_listing__window_start__week + , DATE_TRUNC('month', lux_listings_src_10021.valid_from) AS lux_listing__window_start__month + , DATE_TRUNC('quarter', lux_listings_src_10021.valid_from) AS lux_listing__window_start__quarter + , DATE_TRUNC('year', lux_listings_src_10021.valid_from) AS lux_listing__window_start__year + , EXTRACT(year FROM lux_listings_src_10021.valid_from) AS lux_listing__window_start__extract_year + , EXTRACT(quarter FROM lux_listings_src_10021.valid_from) AS lux_listing__window_start__extract_quarter + , EXTRACT(month FROM lux_listings_src_10021.valid_from) AS lux_listing__window_start__extract_month + , EXTRACT(day FROM lux_listings_src_10021.valid_from) AS lux_listing__window_start__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM lux_listings_src_10021.valid_from) AS lux_listing__window_start__extract_dow + , EXTRACT(doy FROM lux_listings_src_10021.valid_from) AS lux_listing__window_start__extract_doy + , lux_listings_src_10021.valid_to AS lux_listing__window_end__day + , DATE_TRUNC('week', lux_listings_src_10021.valid_to) AS lux_listing__window_end__week + , DATE_TRUNC('month', lux_listings_src_10021.valid_to) AS lux_listing__window_end__month + , DATE_TRUNC('quarter', lux_listings_src_10021.valid_to) AS lux_listing__window_end__quarter + , DATE_TRUNC('year', lux_listings_src_10021.valid_to) AS lux_listing__window_end__year + , EXTRACT(year FROM lux_listings_src_10021.valid_to) AS lux_listing__window_end__extract_year + , EXTRACT(quarter FROM lux_listings_src_10021.valid_to) AS lux_listing__window_end__extract_quarter + , EXTRACT(month FROM lux_listings_src_10021.valid_to) AS lux_listing__window_end__extract_month + , EXTRACT(day FROM lux_listings_src_10021.valid_to) AS lux_listing__window_end__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM lux_listings_src_10021.valid_to) AS lux_listing__window_end__extract_dow + , EXTRACT(doy FROM lux_listings_src_10021.valid_to) AS lux_listing__window_end__extract_doy + , lux_listings_src_10021.is_confirmed_lux AS lux_listing__is_confirmed_lux + , lux_listings_src_10021.lux_listing_id AS lux_listing + FROM ***************************.dim_lux_listings lux_listings_src_10021 ) subq_4 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0_optimized.sql index add7e259ab..16470814e6 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0_optimized.sql @@ -16,7 +16,7 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_10015 + FROM ***************************.fct_bookings bookings_source_src_10017 ) subq_13 LEFT OUTER JOIN ( -- Join Standard Outputs @@ -26,15 +26,15 @@ LEFT OUTER JOIN ( -- 'lux_listing__window_end__day', -- 'listing'] SELECT - lux_listings_src_10019.valid_from AS lux_listing__window_start__day - , lux_listings_src_10019.valid_to AS lux_listing__window_end__day - , lux_listing_mapping_src_10018.listing_id AS listing - , lux_listings_src_10019.is_confirmed_lux AS lux_listing__is_confirmed_lux - FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_10018 + lux_listings_src_10021.valid_from AS lux_listing__window_start__day + , lux_listings_src_10021.valid_to AS lux_listing__window_end__day + , lux_listing_mapping_src_10020.listing_id AS listing + , lux_listings_src_10021.is_confirmed_lux AS lux_listing__is_confirmed_lux + FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_10020 LEFT OUTER JOIN - ***************************.dim_lux_listings lux_listings_src_10019 + ***************************.dim_lux_listings lux_listings_src_10021 ON - lux_listing_mapping_src_10018.lux_listing_id = lux_listings_src_10019.lux_listing_id + lux_listing_mapping_src_10020.lux_listing_id = lux_listings_src_10021.lux_listing_id ) subq_18 ON ( diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multihop_node__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multihop_node__plan0.sql index 24136e4058..7b8daa6dd4 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multihop_node__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multihop_node__plan0.sql @@ -93,55 +93,55 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'account_month_txns' SELECT - account_month_txns_src_10010.txn_count - , DATE_TRUNC('day', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', account_month_txns_src_10010.ds) AS ds__day - , DATE_TRUNC('week', account_month_txns_src_10010.ds) AS ds__week - , DATE_TRUNC('month', account_month_txns_src_10010.ds) AS ds__month - , DATE_TRUNC('quarter', account_month_txns_src_10010.ds) AS ds__quarter - , DATE_TRUNC('year', account_month_txns_src_10010.ds) AS ds__year - , EXTRACT(year FROM account_month_txns_src_10010.ds) AS ds__extract_year - , EXTRACT(quarter FROM account_month_txns_src_10010.ds) AS ds__extract_quarter - , EXTRACT(month FROM account_month_txns_src_10010.ds) AS ds__extract_month - , EXTRACT(day FROM account_month_txns_src_10010.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM account_month_txns_src_10010.ds) AS ds__extract_dow - , EXTRACT(doy FROM account_month_txns_src_10010.ds) AS ds__extract_doy - , account_month_txns_src_10010.account_month - , DATE_TRUNC('day', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__day - , DATE_TRUNC('week', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__week - , DATE_TRUNC('month', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__month - , DATE_TRUNC('quarter', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__quarter - , DATE_TRUNC('year', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__year - , EXTRACT(year FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_month - , EXTRACT(day FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , DATE_TRUNC('day', account_month_txns_src_10010.ds) AS account_id__ds__day - , DATE_TRUNC('week', account_month_txns_src_10010.ds) AS account_id__ds__week - , DATE_TRUNC('month', account_month_txns_src_10010.ds) AS account_id__ds__month - , DATE_TRUNC('quarter', account_month_txns_src_10010.ds) AS account_id__ds__quarter - , DATE_TRUNC('year', account_month_txns_src_10010.ds) AS account_id__ds__year - , EXTRACT(year FROM account_month_txns_src_10010.ds) AS account_id__ds__extract_year - , EXTRACT(quarter FROM account_month_txns_src_10010.ds) AS account_id__ds__extract_quarter - , EXTRACT(month FROM account_month_txns_src_10010.ds) AS account_id__ds__extract_month - , EXTRACT(day FROM account_month_txns_src_10010.ds) AS account_id__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM account_month_txns_src_10010.ds) AS account_id__ds__extract_dow - , EXTRACT(doy FROM account_month_txns_src_10010.ds) AS account_id__ds__extract_doy - , account_month_txns_src_10010.account_month AS account_id__account_month - , account_month_txns_src_10010.account_id - FROM ***************************.account_month_txns account_month_txns_src_10010 + account_month_txns_src_10012.txn_count + , DATE_TRUNC('day', account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', account_month_txns_src_10012.ds) AS ds__day + , DATE_TRUNC('week', account_month_txns_src_10012.ds) AS ds__week + , DATE_TRUNC('month', account_month_txns_src_10012.ds) AS ds__month + , DATE_TRUNC('quarter', account_month_txns_src_10012.ds) AS ds__quarter + , DATE_TRUNC('year', account_month_txns_src_10012.ds) AS ds__year + , EXTRACT(year FROM account_month_txns_src_10012.ds) AS ds__extract_year + , EXTRACT(quarter FROM account_month_txns_src_10012.ds) AS ds__extract_quarter + , EXTRACT(month FROM account_month_txns_src_10012.ds) AS ds__extract_month + , EXTRACT(day FROM account_month_txns_src_10012.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM account_month_txns_src_10012.ds) AS ds__extract_dow + , EXTRACT(doy FROM account_month_txns_src_10012.ds) AS ds__extract_doy + , account_month_txns_src_10012.account_month + , DATE_TRUNC('day', account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__day + , DATE_TRUNC('week', account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__week + , DATE_TRUNC('month', account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__month + , DATE_TRUNC('quarter', account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__quarter + , DATE_TRUNC('year', account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__year + , EXTRACT(year FROM account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__extract_month + , EXTRACT(day FROM account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__extract_doy + , DATE_TRUNC('day', account_month_txns_src_10012.ds) AS account_id__ds__day + , DATE_TRUNC('week', account_month_txns_src_10012.ds) AS account_id__ds__week + , DATE_TRUNC('month', account_month_txns_src_10012.ds) AS account_id__ds__month + , DATE_TRUNC('quarter', account_month_txns_src_10012.ds) AS account_id__ds__quarter + , DATE_TRUNC('year', account_month_txns_src_10012.ds) AS account_id__ds__year + , EXTRACT(year FROM account_month_txns_src_10012.ds) AS account_id__ds__extract_year + , EXTRACT(quarter FROM account_month_txns_src_10012.ds) AS account_id__ds__extract_quarter + , EXTRACT(month FROM account_month_txns_src_10012.ds) AS account_id__ds__extract_month + , EXTRACT(day FROM account_month_txns_src_10012.ds) AS account_id__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM account_month_txns_src_10012.ds) AS account_id__ds__extract_dow + , EXTRACT(doy FROM account_month_txns_src_10012.ds) AS account_id__ds__extract_doy + , account_month_txns_src_10012.account_month AS account_id__account_month + , account_month_txns_src_10012.account_id + FROM ***************************.account_month_txns account_month_txns_src_10012 ) subq_0 ) subq_1 ) subq_2 @@ -212,48 +212,48 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT - bridge_table_src_10011.extra_dim - , DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_doy - , bridge_table_src_10011.extra_dim AS account_id__extra_dim - , DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__day - , DATE_TRUNC('week', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__week - , DATE_TRUNC('month', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__month - , DATE_TRUNC('quarter', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__quarter - , DATE_TRUNC('year', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , bridge_table_src_10011.extra_dim AS bridge_account__extra_dim - , DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__day - , DATE_TRUNC('week', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__week - , DATE_TRUNC('month', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__month - , DATE_TRUNC('quarter', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__quarter - , DATE_TRUNC('year', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__extract_dow - , EXTRACT(doy FROM bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__extract_doy - , bridge_table_src_10011.account_id - , bridge_table_src_10011.customer_id - , bridge_table_src_10011.customer_id AS account_id__customer_id - , bridge_table_src_10011.account_id AS bridge_account__account_id - , bridge_table_src_10011.customer_id AS bridge_account__customer_id - FROM ***************************.bridge_table bridge_table_src_10011 + bridge_table_src_10013.extra_dim + , DATE_TRUNC('day', bridge_table_src_10013.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bridge_table_src_10013.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bridge_table_src_10013.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bridge_table_src_10013.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bridge_table_src_10013.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_10013.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_10013.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_10013.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_10013.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bridge_table_src_10013.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bridge_table_src_10013.ds_partitioned) AS ds_partitioned__extract_doy + , bridge_table_src_10013.extra_dim AS account_id__extra_dim + , DATE_TRUNC('day', bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__day + , DATE_TRUNC('week', bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__week + , DATE_TRUNC('month', bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__month + , DATE_TRUNC('quarter', bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__quarter + , DATE_TRUNC('year', bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__extract_doy + , bridge_table_src_10013.extra_dim AS bridge_account__extra_dim + , DATE_TRUNC('day', bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__day + , DATE_TRUNC('week', bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__week + , DATE_TRUNC('month', bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__month + , DATE_TRUNC('quarter', bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__quarter + , DATE_TRUNC('year', bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__extract_dow + , EXTRACT(doy FROM bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__extract_doy + , bridge_table_src_10013.account_id + , bridge_table_src_10013.customer_id + , bridge_table_src_10013.customer_id AS account_id__customer_id + , bridge_table_src_10013.account_id AS bridge_account__account_id + , bridge_table_src_10013.customer_id AS bridge_account__customer_id + FROM ***************************.bridge_table bridge_table_src_10013 ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: @@ -315,34 +315,34 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'customer_table' SELECT - customer_table_src_10013.customer_name - , customer_table_src_10013.customer_atomic_weight - , DATE_TRUNC('day', customer_table_src_10013.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', customer_table_src_10013.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', customer_table_src_10013.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', customer_table_src_10013.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', customer_table_src_10013.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_doy - , customer_table_src_10013.customer_name AS customer_id__customer_name - , customer_table_src_10013.customer_atomic_weight AS customer_id__customer_atomic_weight - , DATE_TRUNC('day', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__day - , DATE_TRUNC('week', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__week - , DATE_TRUNC('month', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__month - , DATE_TRUNC('quarter', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__quarter - , DATE_TRUNC('year', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__year - , EXTRACT(year FROM customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__extract_month - , EXTRACT(day FROM customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__extract_doy - , customer_table_src_10013.customer_id - FROM ***************************.customer_table customer_table_src_10013 + customer_table_src_10015.customer_name + , customer_table_src_10015.customer_atomic_weight + , DATE_TRUNC('day', customer_table_src_10015.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', customer_table_src_10015.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', customer_table_src_10015.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', customer_table_src_10015.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', customer_table_src_10015.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM customer_table_src_10015.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM customer_table_src_10015.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM customer_table_src_10015.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM customer_table_src_10015.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM customer_table_src_10015.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM customer_table_src_10015.ds_partitioned) AS ds_partitioned__extract_doy + , customer_table_src_10015.customer_name AS customer_id__customer_name + , customer_table_src_10015.customer_atomic_weight AS customer_id__customer_atomic_weight + , DATE_TRUNC('day', customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__day + , DATE_TRUNC('week', customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__week + , DATE_TRUNC('month', customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__month + , DATE_TRUNC('quarter', customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__quarter + , DATE_TRUNC('year', customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__year + , EXTRACT(year FROM customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__extract_month + , EXTRACT(day FROM customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__extract_doy + , customer_table_src_10015.customer_id + FROM ***************************.customer_table customer_table_src_10015 ) subq_4 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multihop_node__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multihop_node__plan0_optimized.sql index 8a42052413..65d688b745 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multihop_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multihop_node__plan0_optimized.sql @@ -5,31 +5,31 @@ -- Compute Metrics via Expressions SELECT subq_18.customer_id__customer_name AS account_id__customer_id__customer_name - , SUM(account_month_txns_src_10010.txn_count) AS txn_count -FROM ***************************.account_month_txns account_month_txns_src_10010 + , SUM(account_month_txns_src_10012.txn_count) AS txn_count +FROM ***************************.account_month_txns account_month_txns_src_10012 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: -- ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__day - , bridge_table_src_10011.account_id AS account_id - , customer_table_src_10013.customer_name AS customer_id__customer_name - FROM ***************************.bridge_table bridge_table_src_10011 + DATE_TRUNC('day', bridge_table_src_10013.ds_partitioned) AS ds_partitioned__day + , bridge_table_src_10013.account_id AS account_id + , customer_table_src_10015.customer_name AS customer_id__customer_name + FROM ***************************.bridge_table bridge_table_src_10013 LEFT OUTER JOIN - ***************************.customer_table customer_table_src_10013 + ***************************.customer_table customer_table_src_10015 ON ( - bridge_table_src_10011.customer_id = customer_table_src_10013.customer_id + bridge_table_src_10013.customer_id = customer_table_src_10015.customer_id ) AND ( - DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) = DATE_TRUNC('day', customer_table_src_10013.ds_partitioned) + DATE_TRUNC('day', bridge_table_src_10013.ds_partitioned) = DATE_TRUNC('day', customer_table_src_10015.ds_partitioned) ) ) subq_18 ON ( - account_month_txns_src_10010.account_id = subq_18.account_id + account_month_txns_src_10012.account_id = subq_18.account_id ) AND ( - DATE_TRUNC('day', account_month_txns_src_10010.ds_partitioned) = subq_18.ds_partitioned__day + DATE_TRUNC('day', account_month_txns_src_10012.ds_partitioned) = subq_18.ds_partitioned__day ) GROUP BY subq_18.customer_id__customer_name diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multiple_metrics_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multiple_metrics_no_dimensions__plan0.sql index bb0ca2196f..36fca98e9f 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multiple_metrics_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multiple_metrics_no_dimensions__plan0.sql @@ -473,62 +473,62 @@ CROSS JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_6 ) subq_7 WHERE subq_7.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multiple_metrics_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multiple_metrics_no_dimensions__plan0_optimized.sql index 631546edf7..5fdefdb6a7 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multiple_metrics_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multiple_metrics_no_dimensions__plan0_optimized.sql @@ -25,6 +25,6 @@ CROSS JOIN ( -- Compute Metrics via Expressions SELECT SUM(1) AS listings - FROM ***************************.dim_listings_latest listings_latest_src_10004 + FROM ***************************.dim_listings_latest listings_latest_src_10005 WHERE DATE_TRUNC('day', created_at) BETWEEN '2020-01-01' AND '2020-01-01' ) subq_23 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_partitioned_join__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_partitioned_join__plan0.sql index 74585c6bf0..bc0993d757 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_partitioned_join__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_partitioned_join__plan0.sql @@ -96,56 +96,56 @@ FROM ( -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , DATE_TRUNC('day', id_verifications_src_10003.ds) AS ds__day - , DATE_TRUNC('week', id_verifications_src_10003.ds) AS ds__week - , DATE_TRUNC('month', id_verifications_src_10003.ds) AS ds__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS ds__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds) AS ds__year - , EXTRACT(year FROM id_verifications_src_10003.ds) AS ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds) AS ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds) AS ds__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM id_verifications_src_10003.ds) AS ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds) AS ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_doy - , id_verifications_src_10003.verification_type - , DATE_TRUNC('day', id_verifications_src_10003.ds) AS verification__ds__day - , DATE_TRUNC('week', id_verifications_src_10003.ds) AS verification__ds__week - , DATE_TRUNC('month', id_verifications_src_10003.ds) AS verification__ds__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS verification__ds__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds) AS verification__ds__year - , EXTRACT(year FROM id_verifications_src_10003.ds) AS verification__ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds) AS verification__ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds) AS verification__ds__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds) AS verification__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM id_verifications_src_10003.ds) AS verification__ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds) AS verification__ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_doy - , id_verifications_src_10003.verification_type AS verification__verification_type - , id_verifications_src_10003.verification_id AS verification - , id_verifications_src_10003.user_id AS user - , id_verifications_src_10003.user_id AS verification__user - FROM ***************************.fct_id_verifications id_verifications_src_10003 + , DATE_TRUNC('day', id_verifications_src_10004.ds) AS ds__day + , DATE_TRUNC('week', id_verifications_src_10004.ds) AS ds__week + , DATE_TRUNC('month', id_verifications_src_10004.ds) AS ds__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds) AS ds__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds) AS ds__year + , EXTRACT(year FROM id_verifications_src_10004.ds) AS ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds) AS ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds) AS ds__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM id_verifications_src_10004.ds) AS ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds) AS ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_doy + , id_verifications_src_10004.verification_type + , DATE_TRUNC('day', id_verifications_src_10004.ds) AS verification__ds__day + , DATE_TRUNC('week', id_verifications_src_10004.ds) AS verification__ds__week + , DATE_TRUNC('month', id_verifications_src_10004.ds) AS verification__ds__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds) AS verification__ds__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds) AS verification__ds__year + , EXTRACT(year FROM id_verifications_src_10004.ds) AS verification__ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds) AS verification__ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds) AS verification__ds__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds) AS verification__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM id_verifications_src_10004.ds) AS verification__ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds) AS verification__ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_doy + , id_verifications_src_10004.verification_type AS verification__verification_type + , id_verifications_src_10004.verification_id AS verification + , id_verifications_src_10004.user_id AS user + , id_verifications_src_10004.user_id AS verification__user + FROM ***************************.fct_id_verifications id_verifications_src_10004 ) subq_0 ) subq_1 ) subq_2 @@ -159,76 +159,76 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT - DATE_TRUNC('day', users_ds_source_src_10007.ds) AS ds__day - , DATE_TRUNC('week', users_ds_source_src_10007.ds) AS ds__week - , DATE_TRUNC('month', users_ds_source_src_10007.ds) AS ds__month - , DATE_TRUNC('quarter', users_ds_source_src_10007.ds) AS ds__quarter - , DATE_TRUNC('year', users_ds_source_src_10007.ds) AS ds__year - , EXTRACT(year FROM users_ds_source_src_10007.ds) AS ds__extract_year - , EXTRACT(quarter FROM users_ds_source_src_10007.ds) AS ds__extract_quarter - , EXTRACT(month FROM users_ds_source_src_10007.ds) AS ds__extract_month - , EXTRACT(day FROM users_ds_source_src_10007.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_10007.ds) AS ds__extract_dow - , EXTRACT(doy FROM users_ds_source_src_10007.ds) AS ds__extract_doy - , DATE_TRUNC('day', users_ds_source_src_10007.created_at) AS created_at__day - , DATE_TRUNC('week', users_ds_source_src_10007.created_at) AS created_at__week - , DATE_TRUNC('month', users_ds_source_src_10007.created_at) AS created_at__month - , DATE_TRUNC('quarter', users_ds_source_src_10007.created_at) AS created_at__quarter - , DATE_TRUNC('year', users_ds_source_src_10007.created_at) AS created_at__year - , EXTRACT(year FROM users_ds_source_src_10007.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_10007.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_10007.created_at) AS created_at__extract_month - , EXTRACT(day FROM users_ds_source_src_10007.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_10007.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_10007.created_at) AS created_at__extract_doy - , DATE_TRUNC('day', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_doy - , users_ds_source_src_10007.home_state - , DATE_TRUNC('day', users_ds_source_src_10007.ds) AS user__ds__day - , DATE_TRUNC('week', users_ds_source_src_10007.ds) AS user__ds__week - , DATE_TRUNC('month', users_ds_source_src_10007.ds) AS user__ds__month - , DATE_TRUNC('quarter', users_ds_source_src_10007.ds) AS user__ds__quarter - , DATE_TRUNC('year', users_ds_source_src_10007.ds) AS user__ds__year - , EXTRACT(year FROM users_ds_source_src_10007.ds) AS user__ds__extract_year - , EXTRACT(quarter FROM users_ds_source_src_10007.ds) AS user__ds__extract_quarter - , EXTRACT(month FROM users_ds_source_src_10007.ds) AS user__ds__extract_month - , EXTRACT(day FROM users_ds_source_src_10007.ds) AS user__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_10007.ds) AS user__ds__extract_dow - , EXTRACT(doy FROM users_ds_source_src_10007.ds) AS user__ds__extract_doy - , DATE_TRUNC('day', users_ds_source_src_10007.created_at) AS user__created_at__day - , DATE_TRUNC('week', users_ds_source_src_10007.created_at) AS user__created_at__week - , DATE_TRUNC('month', users_ds_source_src_10007.created_at) AS user__created_at__month - , DATE_TRUNC('quarter', users_ds_source_src_10007.created_at) AS user__created_at__quarter - , DATE_TRUNC('year', users_ds_source_src_10007.created_at) AS user__created_at__year - , EXTRACT(year FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_month - , EXTRACT(day FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_doy - , DATE_TRUNC('day', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__day - , DATE_TRUNC('week', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__week - , DATE_TRUNC('month', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__month - , DATE_TRUNC('quarter', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__quarter - , DATE_TRUNC('year', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__year - , EXTRACT(year FROM users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__extract_year - , EXTRACT(quarter FROM users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__extract_quarter - , EXTRACT(month FROM users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__extract_month - , EXTRACT(day FROM users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__extract_dow - , EXTRACT(doy FROM users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__extract_doy - , users_ds_source_src_10007.home_state AS user__home_state - , users_ds_source_src_10007.user_id AS user - FROM ***************************.dim_users users_ds_source_src_10007 + DATE_TRUNC('day', users_ds_source_src_10008.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_10008.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_10008.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_10008.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_10008.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_10008.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_10008.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_10008.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_10008.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_10008.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_10008.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_10008.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_10008.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_10008.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_10008.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_10008.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_10008.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_10008.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_10008.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_10008.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_10008.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_10008.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_10008.home_state + , DATE_TRUNC('day', users_ds_source_src_10008.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_10008.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_10008.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_10008.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_10008.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_10008.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_10008.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_10008.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_10008.ds) AS user__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_10008.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_10008.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_10008.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_10008.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_10008.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_10008.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_10008.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_10008.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_10008.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_10008.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_10008.created_at) AS user__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_10008.created_at) AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_10008.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_10008.home_state AS user__home_state + , users_ds_source_src_10008.user_id AS user + FROM ***************************.dim_users users_ds_source_src_10008 ) subq_3 ) subq_4 ON diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_partitioned_join__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_partitioned_join__plan0_optimized.sql index c15982d861..b52d743037 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_partitioned_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_partitioned_join__plan0_optimized.sql @@ -4,7 +4,7 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - users_ds_source_src_10007.home_state AS user__home_state + users_ds_source_src_10008.home_state AS user__home_state , SUM(subq_10.identity_verifications) AS identity_verifications FROM ( -- Read Elements From Semantic Model 'id_verifications' @@ -15,15 +15,15 @@ FROM ( DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , user_id AS user , 1 AS identity_verifications - FROM ***************************.fct_id_verifications id_verifications_src_10003 + FROM ***************************.fct_id_verifications id_verifications_src_10004 ) subq_10 LEFT OUTER JOIN - ***************************.dim_users users_ds_source_src_10007 + ***************************.dim_users users_ds_source_src_10008 ON ( - subq_10.user = users_ds_source_src_10007.user_id + subq_10.user = users_ds_source_src_10008.user_id ) AND ( - subq_10.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_10007.ds_partitioned) + subq_10.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_10008.ds_partitioned) ) GROUP BY - users_ds_source_src_10007.home_state + users_ds_source_src_10008.home_state diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_distinct_values__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_distinct_values__plan0.sql index 7a6a9e1f3d..48e2471976 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_distinct_values__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_distinct_values__plan0.sql @@ -69,62 +69,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_0 WHERE listing__country_latest = 'us' ) subq_1 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_distinct_values__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_distinct_values__plan0_optimized.sql index ec0d94dac2..53c7bf823f 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_distinct_values__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_distinct_values__plan0_optimized.sql @@ -8,7 +8,7 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT country AS listing__country_latest - FROM ***************************.dim_listings_latest listings_latest_src_10004 + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_3 WHERE listing__country_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_filter_with_where_constraint_on_join_dim__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_filter_with_where_constraint_on_join_dim__plan0.sql index 99c4cea0ad..9645c25280 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_filter_with_where_constraint_on_join_dim__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_filter_with_where_constraint_on_join_dim__plan0.sql @@ -316,62 +316,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_3 ) subq_4 ) subq_5 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql index 19b1b78329..d00b32fb24 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql @@ -12,7 +12,7 @@ FROM ( -- ['bookings', 'booking__is_instant', 'listing__country_latest'] SELECT subq_13.booking__is_instant AS booking__is_instant - , listings_latest_src_10004.country AS listing__country_latest + , listings_latest_src_10005.country AS listing__country_latest , subq_13.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -26,9 +26,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_13 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_13.listing = listings_latest_src_10004.listing_id + subq_13.listing = listings_latest_src_10005.listing_id ) subq_18 WHERE listing__country_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_join_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_join_to_scd_dimension__plan0.sql index d6f3055b49..e0d6b9598a 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_join_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_join_to_scd_dimension__plan0.sql @@ -142,87 +142,87 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_10015.booking_value - , bookings_source_src_10015.guest_id AS bookers - , bookings_source_src_10015.booking_value AS average_booking_value - , bookings_source_src_10015.booking_value AS booking_payments - , bookings_source_src_10015.is_instant - , DATE_TRUNC('day', bookings_source_src_10015.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_10015.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_10015.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_10015.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_10015.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_10015.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_10015.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_10015.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_10015.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS paid_at__extract_doy - , bookings_source_src_10015.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_10015.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_10015.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_10015.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_10015.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_10015.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_10015.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_10015.listing_id AS listing - , bookings_source_src_10015.guest_id AS guest - , bookings_source_src_10015.host_id AS host - , bookings_source_src_10015.guest_id AS user - , bookings_source_src_10015.listing_id AS booking__listing - , bookings_source_src_10015.guest_id AS booking__guest - , bookings_source_src_10015.host_id AS booking__host - , bookings_source_src_10015.guest_id AS booking__user - FROM ***************************.fct_bookings bookings_source_src_10015 + , bookings_source_src_10017.booking_value + , bookings_source_src_10017.guest_id AS bookers + , bookings_source_src_10017.booking_value AS average_booking_value + , bookings_source_src_10017.booking_value AS booking_payments + , bookings_source_src_10017.is_instant + , DATE_TRUNC('day', bookings_source_src_10017.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_10017.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_10017.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_10017.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_10017.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_10017.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_10017.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_10017.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_10017.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_10017.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_10017.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_10017.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.paid_at) AS paid_at__extract_doy + , bookings_source_src_10017.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_10017.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_10017.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_10017.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_10017.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_10017.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_10017.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_10017.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_10017.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_10017.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_10017.listing_id AS listing + , bookings_source_src_10017.guest_id AS guest + , bookings_source_src_10017.host_id AS host + , bookings_source_src_10017.guest_id AS user + , bookings_source_src_10017.listing_id AS booking__listing + , bookings_source_src_10017.guest_id AS booking__guest + , bookings_source_src_10017.host_id AS booking__host + , bookings_source_src_10017.guest_id AS booking__user + FROM ***************************.fct_bookings bookings_source_src_10017 ) subq_0 ) subq_1 ) subq_2 @@ -237,60 +237,60 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'listings' SELECT - listings_src_10017.active_from AS window_start__day - , DATE_TRUNC('week', listings_src_10017.active_from) AS window_start__week - , DATE_TRUNC('month', listings_src_10017.active_from) AS window_start__month - , DATE_TRUNC('quarter', listings_src_10017.active_from) AS window_start__quarter - , DATE_TRUNC('year', listings_src_10017.active_from) AS window_start__year - , EXTRACT(year FROM listings_src_10017.active_from) AS window_start__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_from) AS window_start__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_from) AS window_start__extract_month - , EXTRACT(day FROM listings_src_10017.active_from) AS window_start__extract_day - , EXTRACT(isodow FROM listings_src_10017.active_from) AS window_start__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_from) AS window_start__extract_doy - , listings_src_10017.active_to AS window_end__day - , DATE_TRUNC('week', listings_src_10017.active_to) AS window_end__week - , DATE_TRUNC('month', listings_src_10017.active_to) AS window_end__month - , DATE_TRUNC('quarter', listings_src_10017.active_to) AS window_end__quarter - , DATE_TRUNC('year', listings_src_10017.active_to) AS window_end__year - , EXTRACT(year FROM listings_src_10017.active_to) AS window_end__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_to) AS window_end__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_to) AS window_end__extract_month - , EXTRACT(day FROM listings_src_10017.active_to) AS window_end__extract_day - , EXTRACT(isodow FROM listings_src_10017.active_to) AS window_end__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_to) AS window_end__extract_doy - , listings_src_10017.country - , listings_src_10017.is_lux - , listings_src_10017.capacity - , listings_src_10017.active_from AS listing__window_start__day - , DATE_TRUNC('week', listings_src_10017.active_from) AS listing__window_start__week - , DATE_TRUNC('month', listings_src_10017.active_from) AS listing__window_start__month - , DATE_TRUNC('quarter', listings_src_10017.active_from) AS listing__window_start__quarter - , DATE_TRUNC('year', listings_src_10017.active_from) AS listing__window_start__year - , EXTRACT(year FROM listings_src_10017.active_from) AS listing__window_start__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_from) AS listing__window_start__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_from) AS listing__window_start__extract_month - , EXTRACT(day FROM listings_src_10017.active_from) AS listing__window_start__extract_day - , EXTRACT(isodow FROM listings_src_10017.active_from) AS listing__window_start__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_from) AS listing__window_start__extract_doy - , listings_src_10017.active_to AS listing__window_end__day - , DATE_TRUNC('week', listings_src_10017.active_to) AS listing__window_end__week - , DATE_TRUNC('month', listings_src_10017.active_to) AS listing__window_end__month - , DATE_TRUNC('quarter', listings_src_10017.active_to) AS listing__window_end__quarter - , DATE_TRUNC('year', listings_src_10017.active_to) AS listing__window_end__year - , EXTRACT(year FROM listings_src_10017.active_to) AS listing__window_end__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_to) AS listing__window_end__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_to) AS listing__window_end__extract_month - , EXTRACT(day FROM listings_src_10017.active_to) AS listing__window_end__extract_day - , EXTRACT(isodow FROM listings_src_10017.active_to) AS listing__window_end__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_to) AS listing__window_end__extract_doy - , listings_src_10017.country AS listing__country - , listings_src_10017.is_lux AS listing__is_lux - , listings_src_10017.capacity AS listing__capacity - , listings_src_10017.listing_id AS listing - , listings_src_10017.user_id AS user - , listings_src_10017.user_id AS listing__user - FROM ***************************.dim_listings listings_src_10017 + listings_src_10019.active_from AS window_start__day + , DATE_TRUNC('week', listings_src_10019.active_from) AS window_start__week + , DATE_TRUNC('month', listings_src_10019.active_from) AS window_start__month + , DATE_TRUNC('quarter', listings_src_10019.active_from) AS window_start__quarter + , DATE_TRUNC('year', listings_src_10019.active_from) AS window_start__year + , EXTRACT(year FROM listings_src_10019.active_from) AS window_start__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_from) AS window_start__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_from) AS window_start__extract_month + , EXTRACT(day FROM listings_src_10019.active_from) AS window_start__extract_day + , EXTRACT(isodow FROM listings_src_10019.active_from) AS window_start__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_from) AS window_start__extract_doy + , listings_src_10019.active_to AS window_end__day + , DATE_TRUNC('week', listings_src_10019.active_to) AS window_end__week + , DATE_TRUNC('month', listings_src_10019.active_to) AS window_end__month + , DATE_TRUNC('quarter', listings_src_10019.active_to) AS window_end__quarter + , DATE_TRUNC('year', listings_src_10019.active_to) AS window_end__year + , EXTRACT(year FROM listings_src_10019.active_to) AS window_end__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_to) AS window_end__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_to) AS window_end__extract_month + , EXTRACT(day FROM listings_src_10019.active_to) AS window_end__extract_day + , EXTRACT(isodow FROM listings_src_10019.active_to) AS window_end__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_to) AS window_end__extract_doy + , listings_src_10019.country + , listings_src_10019.is_lux + , listings_src_10019.capacity + , listings_src_10019.active_from AS listing__window_start__day + , DATE_TRUNC('week', listings_src_10019.active_from) AS listing__window_start__week + , DATE_TRUNC('month', listings_src_10019.active_from) AS listing__window_start__month + , DATE_TRUNC('quarter', listings_src_10019.active_from) AS listing__window_start__quarter + , DATE_TRUNC('year', listings_src_10019.active_from) AS listing__window_start__year + , EXTRACT(year FROM listings_src_10019.active_from) AS listing__window_start__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_from) AS listing__window_start__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_from) AS listing__window_start__extract_month + , EXTRACT(day FROM listings_src_10019.active_from) AS listing__window_start__extract_day + , EXTRACT(isodow FROM listings_src_10019.active_from) AS listing__window_start__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_from) AS listing__window_start__extract_doy + , listings_src_10019.active_to AS listing__window_end__day + , DATE_TRUNC('week', listings_src_10019.active_to) AS listing__window_end__week + , DATE_TRUNC('month', listings_src_10019.active_to) AS listing__window_end__month + , DATE_TRUNC('quarter', listings_src_10019.active_to) AS listing__window_end__quarter + , DATE_TRUNC('year', listings_src_10019.active_to) AS listing__window_end__year + , EXTRACT(year FROM listings_src_10019.active_to) AS listing__window_end__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_to) AS listing__window_end__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_to) AS listing__window_end__extract_month + , EXTRACT(day FROM listings_src_10019.active_to) AS listing__window_end__extract_day + , EXTRACT(isodow FROM listings_src_10019.active_to) AS listing__window_end__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_to) AS listing__window_end__extract_doy + , listings_src_10019.country AS listing__country + , listings_src_10019.is_lux AS listing__is_lux + , listings_src_10019.capacity AS listing__capacity + , listings_src_10019.listing_id AS listing + , listings_src_10019.user_id AS user + , listings_src_10019.user_id AS listing__user + FROM ***************************.dim_listings listings_src_10019 ) subq_3 ) subq_4 ON diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_join_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_join_to_scd_dimension__plan0_optimized.sql index db1199fc2e..662445e5ef 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_join_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_join_to_scd_dimension__plan0_optimized.sql @@ -12,7 +12,7 @@ FROM ( -- ['bookings', 'listing__capacity', 'metric_time__day'] SELECT subq_12.metric_time__day AS metric_time__day - , listings_src_10017.capacity AS listing__capacity + , listings_src_10019.capacity AS listing__capacity , subq_12.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -23,21 +23,21 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_10015 + FROM ***************************.fct_bookings bookings_source_src_10017 ) subq_12 LEFT OUTER JOIN - ***************************.dim_listings listings_src_10017 + ***************************.dim_listings listings_src_10019 ON ( - subq_12.listing = listings_src_10017.listing_id + subq_12.listing = listings_src_10019.listing_id ) AND ( ( - subq_12.metric_time__day >= listings_src_10017.active_from + subq_12.metric_time__day >= listings_src_10019.active_from ) AND ( ( - subq_12.metric_time__day < listings_src_10017.active_to + subq_12.metric_time__day < listings_src_10019.active_to ) OR ( - listings_src_10017.active_to IS NULL + listings_src_10019.active_to IS NULL ) ) ) diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_local_dimension_using_local_entity__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_local_dimension_using_local_entity__plan0.sql index d3d98e92e5..71d2f78bb5 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_local_dimension_using_local_entity__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_local_dimension_using_local_entity__plan0.sql @@ -87,62 +87,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_0 ) subq_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_local_dimension_using_local_entity__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_local_dimension_using_local_entity__plan0_optimized.sql index f7932552c3..2c5690447e 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_local_dimension_using_local_entity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_local_dimension_using_local_entity__plan0_optimized.sql @@ -11,7 +11,7 @@ FROM ( SELECT country AS listing__country_latest , 1 AS listings - FROM ***************************.dim_listings_latest listings_latest_src_10004 + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_6 GROUP BY listing__country_latest diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint__plan0.sql index b314ea28d3..8a3cdca410 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint__plan0.sql @@ -328,62 +328,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_3 ) subq_4 ) subq_5 @@ -717,62 +717,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_15 ) subq_16 ) subq_17 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint__plan0_optimized.sql index 3c0c641be9..5581a37a67 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint__plan0_optimized.sql @@ -24,13 +24,13 @@ FROM ( -- ['average_booking_value', 'listing__is_lux_latest', 'metric_time__day'] SELECT DATE_TRUNC('day', bookings_source_src_10001.ds) AS metric_time__day - , listings_latest_src_10004.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest , bookings_source_src_10001.booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_10001 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - bookings_source_src_10001.listing_id = listings_latest_src_10004.listing_id + bookings_source_src_10001.listing_id = listings_latest_src_10005.listing_id ) subq_37 WHERE listing__is_lux_latest GROUP BY @@ -51,7 +51,7 @@ FROM ( -- ['bookings', 'listing__is_lux_latest', 'metric_time__day'] SELECT subq_44.metric_time__day AS metric_time__day - , listings_latest_src_10004.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest , subq_44.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -65,9 +65,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_44 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_44.listing = listings_latest_src_10004.listing_id + subq_44.listing = listings_latest_src_10005.listing_id ) subq_49 WHERE listing__is_lux_latest GROUP BY diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql index 1bbbe9b000..1aa0e36f15 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql @@ -304,62 +304,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_5 ) subq_6 ) subq_7 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql index bd5b5c24ee..1e16df6c0d 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql @@ -22,5 +22,5 @@ CROSS JOIN ( -- Compute Metrics via Expressions SELECT SUM(1) AS listings - FROM ***************************.dim_listings_latest listings_latest_src_10004 + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_20 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multi_hop_through_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multi_hop_through_scd_dimension__plan0.sql index dcc369e93e..df68607098 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multi_hop_through_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multi_hop_through_scd_dimension__plan0.sql @@ -132,87 +132,87 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_10015.booking_value - , bookings_source_src_10015.guest_id AS bookers - , bookings_source_src_10015.booking_value AS average_booking_value - , bookings_source_src_10015.booking_value AS booking_payments - , bookings_source_src_10015.is_instant - , DATE_TRUNC('day', bookings_source_src_10015.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_10015.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_10015.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_10015.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_10015.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_10015.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_10015.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_10015.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_10015.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS paid_at__extract_doy - , bookings_source_src_10015.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_10015.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_10015.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_10015.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_10015.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_10015.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_10015.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_10015.listing_id AS listing - , bookings_source_src_10015.guest_id AS guest - , bookings_source_src_10015.host_id AS host - , bookings_source_src_10015.guest_id AS user - , bookings_source_src_10015.listing_id AS booking__listing - , bookings_source_src_10015.guest_id AS booking__guest - , bookings_source_src_10015.host_id AS booking__host - , bookings_source_src_10015.guest_id AS booking__user - FROM ***************************.fct_bookings bookings_source_src_10015 + , bookings_source_src_10017.booking_value + , bookings_source_src_10017.guest_id AS bookers + , bookings_source_src_10017.booking_value AS average_booking_value + , bookings_source_src_10017.booking_value AS booking_payments + , bookings_source_src_10017.is_instant + , DATE_TRUNC('day', bookings_source_src_10017.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_10017.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_10017.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_10017.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_10017.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_10017.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_10017.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_10017.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_10017.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_10017.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_10017.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_10017.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.paid_at) AS paid_at__extract_doy + , bookings_source_src_10017.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_10017.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_10017.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_10017.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_10017.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_10017.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_10017.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_10017.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_10017.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_10017.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_10017.listing_id AS listing + , bookings_source_src_10017.guest_id AS guest + , bookings_source_src_10017.host_id AS host + , bookings_source_src_10017.guest_id AS user + , bookings_source_src_10017.listing_id AS booking__listing + , bookings_source_src_10017.guest_id AS booking__guest + , bookings_source_src_10017.host_id AS booking__host + , bookings_source_src_10017.guest_id AS booking__user + FROM ***************************.fct_bookings bookings_source_src_10017 ) subq_0 ) subq_1 ) subq_2 @@ -295,60 +295,60 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'listings' SELECT - listings_src_10017.active_from AS window_start__day - , DATE_TRUNC('week', listings_src_10017.active_from) AS window_start__week - , DATE_TRUNC('month', listings_src_10017.active_from) AS window_start__month - , DATE_TRUNC('quarter', listings_src_10017.active_from) AS window_start__quarter - , DATE_TRUNC('year', listings_src_10017.active_from) AS window_start__year - , EXTRACT(year FROM listings_src_10017.active_from) AS window_start__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_from) AS window_start__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_from) AS window_start__extract_month - , EXTRACT(day FROM listings_src_10017.active_from) AS window_start__extract_day - , EXTRACT(isodow FROM listings_src_10017.active_from) AS window_start__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_from) AS window_start__extract_doy - , listings_src_10017.active_to AS window_end__day - , DATE_TRUNC('week', listings_src_10017.active_to) AS window_end__week - , DATE_TRUNC('month', listings_src_10017.active_to) AS window_end__month - , DATE_TRUNC('quarter', listings_src_10017.active_to) AS window_end__quarter - , DATE_TRUNC('year', listings_src_10017.active_to) AS window_end__year - , EXTRACT(year FROM listings_src_10017.active_to) AS window_end__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_to) AS window_end__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_to) AS window_end__extract_month - , EXTRACT(day FROM listings_src_10017.active_to) AS window_end__extract_day - , EXTRACT(isodow FROM listings_src_10017.active_to) AS window_end__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_to) AS window_end__extract_doy - , listings_src_10017.country - , listings_src_10017.is_lux - , listings_src_10017.capacity - , listings_src_10017.active_from AS listing__window_start__day - , DATE_TRUNC('week', listings_src_10017.active_from) AS listing__window_start__week - , DATE_TRUNC('month', listings_src_10017.active_from) AS listing__window_start__month - , DATE_TRUNC('quarter', listings_src_10017.active_from) AS listing__window_start__quarter - , DATE_TRUNC('year', listings_src_10017.active_from) AS listing__window_start__year - , EXTRACT(year FROM listings_src_10017.active_from) AS listing__window_start__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_from) AS listing__window_start__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_from) AS listing__window_start__extract_month - , EXTRACT(day FROM listings_src_10017.active_from) AS listing__window_start__extract_day - , EXTRACT(isodow FROM listings_src_10017.active_from) AS listing__window_start__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_from) AS listing__window_start__extract_doy - , listings_src_10017.active_to AS listing__window_end__day - , DATE_TRUNC('week', listings_src_10017.active_to) AS listing__window_end__week - , DATE_TRUNC('month', listings_src_10017.active_to) AS listing__window_end__month - , DATE_TRUNC('quarter', listings_src_10017.active_to) AS listing__window_end__quarter - , DATE_TRUNC('year', listings_src_10017.active_to) AS listing__window_end__year - , EXTRACT(year FROM listings_src_10017.active_to) AS listing__window_end__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_to) AS listing__window_end__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_to) AS listing__window_end__extract_month - , EXTRACT(day FROM listings_src_10017.active_to) AS listing__window_end__extract_day - , EXTRACT(isodow FROM listings_src_10017.active_to) AS listing__window_end__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_to) AS listing__window_end__extract_doy - , listings_src_10017.country AS listing__country - , listings_src_10017.is_lux AS listing__is_lux - , listings_src_10017.capacity AS listing__capacity - , listings_src_10017.listing_id AS listing - , listings_src_10017.user_id AS user - , listings_src_10017.user_id AS listing__user - FROM ***************************.dim_listings listings_src_10017 + listings_src_10019.active_from AS window_start__day + , DATE_TRUNC('week', listings_src_10019.active_from) AS window_start__week + , DATE_TRUNC('month', listings_src_10019.active_from) AS window_start__month + , DATE_TRUNC('quarter', listings_src_10019.active_from) AS window_start__quarter + , DATE_TRUNC('year', listings_src_10019.active_from) AS window_start__year + , EXTRACT(year FROM listings_src_10019.active_from) AS window_start__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_from) AS window_start__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_from) AS window_start__extract_month + , EXTRACT(day FROM listings_src_10019.active_from) AS window_start__extract_day + , EXTRACT(isodow FROM listings_src_10019.active_from) AS window_start__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_from) AS window_start__extract_doy + , listings_src_10019.active_to AS window_end__day + , DATE_TRUNC('week', listings_src_10019.active_to) AS window_end__week + , DATE_TRUNC('month', listings_src_10019.active_to) AS window_end__month + , DATE_TRUNC('quarter', listings_src_10019.active_to) AS window_end__quarter + , DATE_TRUNC('year', listings_src_10019.active_to) AS window_end__year + , EXTRACT(year FROM listings_src_10019.active_to) AS window_end__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_to) AS window_end__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_to) AS window_end__extract_month + , EXTRACT(day FROM listings_src_10019.active_to) AS window_end__extract_day + , EXTRACT(isodow FROM listings_src_10019.active_to) AS window_end__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_to) AS window_end__extract_doy + , listings_src_10019.country + , listings_src_10019.is_lux + , listings_src_10019.capacity + , listings_src_10019.active_from AS listing__window_start__day + , DATE_TRUNC('week', listings_src_10019.active_from) AS listing__window_start__week + , DATE_TRUNC('month', listings_src_10019.active_from) AS listing__window_start__month + , DATE_TRUNC('quarter', listings_src_10019.active_from) AS listing__window_start__quarter + , DATE_TRUNC('year', listings_src_10019.active_from) AS listing__window_start__year + , EXTRACT(year FROM listings_src_10019.active_from) AS listing__window_start__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_from) AS listing__window_start__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_from) AS listing__window_start__extract_month + , EXTRACT(day FROM listings_src_10019.active_from) AS listing__window_start__extract_day + , EXTRACT(isodow FROM listings_src_10019.active_from) AS listing__window_start__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_from) AS listing__window_start__extract_doy + , listings_src_10019.active_to AS listing__window_end__day + , DATE_TRUNC('week', listings_src_10019.active_to) AS listing__window_end__week + , DATE_TRUNC('month', listings_src_10019.active_to) AS listing__window_end__month + , DATE_TRUNC('quarter', listings_src_10019.active_to) AS listing__window_end__quarter + , DATE_TRUNC('year', listings_src_10019.active_to) AS listing__window_end__year + , EXTRACT(year FROM listings_src_10019.active_to) AS listing__window_end__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_to) AS listing__window_end__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_to) AS listing__window_end__extract_month + , EXTRACT(day FROM listings_src_10019.active_to) AS listing__window_end__extract_day + , EXTRACT(isodow FROM listings_src_10019.active_to) AS listing__window_end__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_to) AS listing__window_end__extract_doy + , listings_src_10019.country AS listing__country + , listings_src_10019.is_lux AS listing__is_lux + , listings_src_10019.capacity AS listing__capacity + , listings_src_10019.listing_id AS listing + , listings_src_10019.user_id AS user + , listings_src_10019.user_id AS listing__user + FROM ***************************.dim_listings listings_src_10019 ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: @@ -406,32 +406,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_10021.ds) AS ds__day - , DATE_TRUNC('week', users_latest_src_10021.ds) AS ds__week - , DATE_TRUNC('month', users_latest_src_10021.ds) AS ds__month - , DATE_TRUNC('quarter', users_latest_src_10021.ds) AS ds__quarter - , DATE_TRUNC('year', users_latest_src_10021.ds) AS ds__year - , EXTRACT(year FROM users_latest_src_10021.ds) AS ds__extract_year - , EXTRACT(quarter FROM users_latest_src_10021.ds) AS ds__extract_quarter - , EXTRACT(month FROM users_latest_src_10021.ds) AS ds__extract_month - , EXTRACT(day FROM users_latest_src_10021.ds) AS ds__extract_day - , EXTRACT(isodow FROM users_latest_src_10021.ds) AS ds__extract_dow - , EXTRACT(doy FROM users_latest_src_10021.ds) AS ds__extract_doy - , users_latest_src_10021.home_state_latest - , DATE_TRUNC('day', users_latest_src_10021.ds) AS user__ds__day - , DATE_TRUNC('week', users_latest_src_10021.ds) AS user__ds__week - , DATE_TRUNC('month', users_latest_src_10021.ds) AS user__ds__month - , DATE_TRUNC('quarter', users_latest_src_10021.ds) AS user__ds__quarter - , DATE_TRUNC('year', users_latest_src_10021.ds) AS user__ds__year - , EXTRACT(year FROM users_latest_src_10021.ds) AS user__ds__extract_year - , EXTRACT(quarter FROM users_latest_src_10021.ds) AS user__ds__extract_quarter - , EXTRACT(month FROM users_latest_src_10021.ds) AS user__ds__extract_month - , EXTRACT(day FROM users_latest_src_10021.ds) AS user__ds__extract_day - , EXTRACT(isodow FROM users_latest_src_10021.ds) AS user__ds__extract_dow - , EXTRACT(doy FROM users_latest_src_10021.ds) AS user__ds__extract_doy - , users_latest_src_10021.home_state_latest AS user__home_state_latest - , users_latest_src_10021.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_10021 + DATE_TRUNC('day', users_latest_src_10023.ds) AS ds__day + , DATE_TRUNC('week', users_latest_src_10023.ds) AS ds__week + , DATE_TRUNC('month', users_latest_src_10023.ds) AS ds__month + , DATE_TRUNC('quarter', users_latest_src_10023.ds) AS ds__quarter + , DATE_TRUNC('year', users_latest_src_10023.ds) AS ds__year + , EXTRACT(year FROM users_latest_src_10023.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_latest_src_10023.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_latest_src_10023.ds) AS ds__extract_month + , EXTRACT(day FROM users_latest_src_10023.ds) AS ds__extract_day + , EXTRACT(isodow FROM users_latest_src_10023.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_latest_src_10023.ds) AS ds__extract_doy + , users_latest_src_10023.home_state_latest + , DATE_TRUNC('day', users_latest_src_10023.ds) AS user__ds__day + , DATE_TRUNC('week', users_latest_src_10023.ds) AS user__ds__week + , DATE_TRUNC('month', users_latest_src_10023.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_latest_src_10023.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_latest_src_10023.ds) AS user__ds__year + , EXTRACT(year FROM users_latest_src_10023.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_latest_src_10023.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_latest_src_10023.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_latest_src_10023.ds) AS user__ds__extract_day + , EXTRACT(isodow FROM users_latest_src_10023.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_latest_src_10023.ds) AS user__ds__extract_doy + , users_latest_src_10023.home_state_latest AS user__home_state_latest + , users_latest_src_10023.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_10023 ) subq_4 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multi_hop_through_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multi_hop_through_scd_dimension__plan0_optimized.sql index aa2ad14d34..afba0439d0 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multi_hop_through_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multi_hop_through_scd_dimension__plan0_optimized.sql @@ -16,22 +16,22 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_10015 + FROM ***************************.fct_bookings bookings_source_src_10017 ) subq_13 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: -- ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] SELECT - listings_src_10017.active_from AS window_start__day - , listings_src_10017.active_to AS window_end__day - , listings_src_10017.listing_id AS listing - , users_latest_src_10021.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings listings_src_10017 + listings_src_10019.active_from AS window_start__day + , listings_src_10019.active_to AS window_end__day + , listings_src_10019.listing_id AS listing + , users_latest_src_10023.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings listings_src_10019 LEFT OUTER JOIN - ***************************.dim_users_latest users_latest_src_10021 + ***************************.dim_users_latest users_latest_src_10023 ON - listings_src_10017.user_id = users_latest_src_10021.user_id + listings_src_10019.user_id = users_latest_src_10023.user_id ) subq_18 ON ( diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multi_hop_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multi_hop_to_scd_dimension__plan0.sql index 34675e44cc..663505fb02 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multi_hop_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multi_hop_to_scd_dimension__plan0.sql @@ -132,87 +132,87 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_10015.booking_value - , bookings_source_src_10015.guest_id AS bookers - , bookings_source_src_10015.booking_value AS average_booking_value - , bookings_source_src_10015.booking_value AS booking_payments - , bookings_source_src_10015.is_instant - , DATE_TRUNC('day', bookings_source_src_10015.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_10015.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_10015.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_10015.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_10015.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_10015.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_10015.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_10015.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_10015.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS paid_at__extract_doy - , bookings_source_src_10015.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_10015.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_10015.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_10015.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_10015.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_10015.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_10015.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_10015.listing_id AS listing - , bookings_source_src_10015.guest_id AS guest - , bookings_source_src_10015.host_id AS host - , bookings_source_src_10015.guest_id AS user - , bookings_source_src_10015.listing_id AS booking__listing - , bookings_source_src_10015.guest_id AS booking__guest - , bookings_source_src_10015.host_id AS booking__host - , bookings_source_src_10015.guest_id AS booking__user - FROM ***************************.fct_bookings bookings_source_src_10015 + , bookings_source_src_10017.booking_value + , bookings_source_src_10017.guest_id AS bookers + , bookings_source_src_10017.booking_value AS average_booking_value + , bookings_source_src_10017.booking_value AS booking_payments + , bookings_source_src_10017.is_instant + , DATE_TRUNC('day', bookings_source_src_10017.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_10017.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_10017.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_10017.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_10017.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_10017.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_10017.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_10017.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_10017.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_10017.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_10017.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_10017.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.paid_at) AS paid_at__extract_doy + , bookings_source_src_10017.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_10017.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_10017.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_10017.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_10017.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_10017.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_10017.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_10017.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_10017.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_10017.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_10017.listing_id AS listing + , bookings_source_src_10017.guest_id AS guest + , bookings_source_src_10017.host_id AS host + , bookings_source_src_10017.guest_id AS user + , bookings_source_src_10017.listing_id AS booking__listing + , bookings_source_src_10017.guest_id AS booking__guest + , bookings_source_src_10017.host_id AS booking__host + , bookings_source_src_10017.guest_id AS booking__user + FROM ***************************.fct_bookings bookings_source_src_10017 ) subq_0 ) subq_1 ) subq_2 @@ -259,10 +259,10 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'lux_listing_mapping' SELECT - lux_listing_mapping_src_10018.listing_id AS listing - , lux_listing_mapping_src_10018.lux_listing_id AS lux_listing - , lux_listing_mapping_src_10018.lux_listing_id AS listing__lux_listing - FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_10018 + lux_listing_mapping_src_10020.listing_id AS listing + , lux_listing_mapping_src_10020.lux_listing_id AS lux_listing + , lux_listing_mapping_src_10020.lux_listing_id AS listing__lux_listing + FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_10020 ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: @@ -364,54 +364,54 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'lux_listings' SELECT - lux_listings_src_10019.valid_from AS window_start__day - , DATE_TRUNC('week', lux_listings_src_10019.valid_from) AS window_start__week - , DATE_TRUNC('month', lux_listings_src_10019.valid_from) AS window_start__month - , DATE_TRUNC('quarter', lux_listings_src_10019.valid_from) AS window_start__quarter - , DATE_TRUNC('year', lux_listings_src_10019.valid_from) AS window_start__year - , EXTRACT(year FROM lux_listings_src_10019.valid_from) AS window_start__extract_year - , EXTRACT(quarter FROM lux_listings_src_10019.valid_from) AS window_start__extract_quarter - , EXTRACT(month FROM lux_listings_src_10019.valid_from) AS window_start__extract_month - , EXTRACT(day FROM lux_listings_src_10019.valid_from) AS window_start__extract_day - , EXTRACT(isodow FROM lux_listings_src_10019.valid_from) AS window_start__extract_dow - , EXTRACT(doy FROM lux_listings_src_10019.valid_from) AS window_start__extract_doy - , lux_listings_src_10019.valid_to AS window_end__day - , DATE_TRUNC('week', lux_listings_src_10019.valid_to) AS window_end__week - , DATE_TRUNC('month', lux_listings_src_10019.valid_to) AS window_end__month - , DATE_TRUNC('quarter', lux_listings_src_10019.valid_to) AS window_end__quarter - , DATE_TRUNC('year', lux_listings_src_10019.valid_to) AS window_end__year - , EXTRACT(year FROM lux_listings_src_10019.valid_to) AS window_end__extract_year - , EXTRACT(quarter FROM lux_listings_src_10019.valid_to) AS window_end__extract_quarter - , EXTRACT(month FROM lux_listings_src_10019.valid_to) AS window_end__extract_month - , EXTRACT(day FROM lux_listings_src_10019.valid_to) AS window_end__extract_day - , EXTRACT(isodow FROM lux_listings_src_10019.valid_to) AS window_end__extract_dow - , EXTRACT(doy FROM lux_listings_src_10019.valid_to) AS window_end__extract_doy - , lux_listings_src_10019.is_confirmed_lux - , lux_listings_src_10019.valid_from AS lux_listing__window_start__day - , DATE_TRUNC('week', lux_listings_src_10019.valid_from) AS lux_listing__window_start__week - , DATE_TRUNC('month', lux_listings_src_10019.valid_from) AS lux_listing__window_start__month - , DATE_TRUNC('quarter', lux_listings_src_10019.valid_from) AS lux_listing__window_start__quarter - , DATE_TRUNC('year', lux_listings_src_10019.valid_from) AS lux_listing__window_start__year - , EXTRACT(year FROM lux_listings_src_10019.valid_from) AS lux_listing__window_start__extract_year - , EXTRACT(quarter FROM lux_listings_src_10019.valid_from) AS lux_listing__window_start__extract_quarter - , EXTRACT(month FROM lux_listings_src_10019.valid_from) AS lux_listing__window_start__extract_month - , EXTRACT(day FROM lux_listings_src_10019.valid_from) AS lux_listing__window_start__extract_day - , EXTRACT(isodow FROM lux_listings_src_10019.valid_from) AS lux_listing__window_start__extract_dow - , EXTRACT(doy FROM lux_listings_src_10019.valid_from) AS lux_listing__window_start__extract_doy - , lux_listings_src_10019.valid_to AS lux_listing__window_end__day - , DATE_TRUNC('week', lux_listings_src_10019.valid_to) AS lux_listing__window_end__week - , DATE_TRUNC('month', lux_listings_src_10019.valid_to) AS lux_listing__window_end__month - , DATE_TRUNC('quarter', lux_listings_src_10019.valid_to) AS lux_listing__window_end__quarter - , DATE_TRUNC('year', lux_listings_src_10019.valid_to) AS lux_listing__window_end__year - , EXTRACT(year FROM lux_listings_src_10019.valid_to) AS lux_listing__window_end__extract_year - , EXTRACT(quarter FROM lux_listings_src_10019.valid_to) AS lux_listing__window_end__extract_quarter - , EXTRACT(month FROM lux_listings_src_10019.valid_to) AS lux_listing__window_end__extract_month - , EXTRACT(day FROM lux_listings_src_10019.valid_to) AS lux_listing__window_end__extract_day - , EXTRACT(isodow FROM lux_listings_src_10019.valid_to) AS lux_listing__window_end__extract_dow - , EXTRACT(doy FROM lux_listings_src_10019.valid_to) AS lux_listing__window_end__extract_doy - , lux_listings_src_10019.is_confirmed_lux AS lux_listing__is_confirmed_lux - , lux_listings_src_10019.lux_listing_id AS lux_listing - FROM ***************************.dim_lux_listings lux_listings_src_10019 + lux_listings_src_10021.valid_from AS window_start__day + , DATE_TRUNC('week', lux_listings_src_10021.valid_from) AS window_start__week + , DATE_TRUNC('month', lux_listings_src_10021.valid_from) AS window_start__month + , DATE_TRUNC('quarter', lux_listings_src_10021.valid_from) AS window_start__quarter + , DATE_TRUNC('year', lux_listings_src_10021.valid_from) AS window_start__year + , EXTRACT(year FROM lux_listings_src_10021.valid_from) AS window_start__extract_year + , EXTRACT(quarter FROM lux_listings_src_10021.valid_from) AS window_start__extract_quarter + , EXTRACT(month FROM lux_listings_src_10021.valid_from) AS window_start__extract_month + , EXTRACT(day FROM lux_listings_src_10021.valid_from) AS window_start__extract_day + , EXTRACT(isodow FROM lux_listings_src_10021.valid_from) AS window_start__extract_dow + , EXTRACT(doy FROM lux_listings_src_10021.valid_from) AS window_start__extract_doy + , lux_listings_src_10021.valid_to AS window_end__day + , DATE_TRUNC('week', lux_listings_src_10021.valid_to) AS window_end__week + , DATE_TRUNC('month', lux_listings_src_10021.valid_to) AS window_end__month + , DATE_TRUNC('quarter', lux_listings_src_10021.valid_to) AS window_end__quarter + , DATE_TRUNC('year', lux_listings_src_10021.valid_to) AS window_end__year + , EXTRACT(year FROM lux_listings_src_10021.valid_to) AS window_end__extract_year + , EXTRACT(quarter FROM lux_listings_src_10021.valid_to) AS window_end__extract_quarter + , EXTRACT(month FROM lux_listings_src_10021.valid_to) AS window_end__extract_month + , EXTRACT(day FROM lux_listings_src_10021.valid_to) AS window_end__extract_day + , EXTRACT(isodow FROM lux_listings_src_10021.valid_to) AS window_end__extract_dow + , EXTRACT(doy FROM lux_listings_src_10021.valid_to) AS window_end__extract_doy + , lux_listings_src_10021.is_confirmed_lux + , lux_listings_src_10021.valid_from AS lux_listing__window_start__day + , DATE_TRUNC('week', lux_listings_src_10021.valid_from) AS lux_listing__window_start__week + , DATE_TRUNC('month', lux_listings_src_10021.valid_from) AS lux_listing__window_start__month + , DATE_TRUNC('quarter', lux_listings_src_10021.valid_from) AS lux_listing__window_start__quarter + , DATE_TRUNC('year', lux_listings_src_10021.valid_from) AS lux_listing__window_start__year + , EXTRACT(year FROM lux_listings_src_10021.valid_from) AS lux_listing__window_start__extract_year + , EXTRACT(quarter FROM lux_listings_src_10021.valid_from) AS lux_listing__window_start__extract_quarter + , EXTRACT(month FROM lux_listings_src_10021.valid_from) AS lux_listing__window_start__extract_month + , EXTRACT(day FROM lux_listings_src_10021.valid_from) AS lux_listing__window_start__extract_day + , EXTRACT(isodow FROM lux_listings_src_10021.valid_from) AS lux_listing__window_start__extract_dow + , EXTRACT(doy FROM lux_listings_src_10021.valid_from) AS lux_listing__window_start__extract_doy + , lux_listings_src_10021.valid_to AS lux_listing__window_end__day + , DATE_TRUNC('week', lux_listings_src_10021.valid_to) AS lux_listing__window_end__week + , DATE_TRUNC('month', lux_listings_src_10021.valid_to) AS lux_listing__window_end__month + , DATE_TRUNC('quarter', lux_listings_src_10021.valid_to) AS lux_listing__window_end__quarter + , DATE_TRUNC('year', lux_listings_src_10021.valid_to) AS lux_listing__window_end__year + , EXTRACT(year FROM lux_listings_src_10021.valid_to) AS lux_listing__window_end__extract_year + , EXTRACT(quarter FROM lux_listings_src_10021.valid_to) AS lux_listing__window_end__extract_quarter + , EXTRACT(month FROM lux_listings_src_10021.valid_to) AS lux_listing__window_end__extract_month + , EXTRACT(day FROM lux_listings_src_10021.valid_to) AS lux_listing__window_end__extract_day + , EXTRACT(isodow FROM lux_listings_src_10021.valid_to) AS lux_listing__window_end__extract_dow + , EXTRACT(doy FROM lux_listings_src_10021.valid_to) AS lux_listing__window_end__extract_doy + , lux_listings_src_10021.is_confirmed_lux AS lux_listing__is_confirmed_lux + , lux_listings_src_10021.lux_listing_id AS lux_listing + FROM ***************************.dim_lux_listings lux_listings_src_10021 ) subq_4 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multi_hop_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multi_hop_to_scd_dimension__plan0_optimized.sql index add7e259ab..16470814e6 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multi_hop_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multi_hop_to_scd_dimension__plan0_optimized.sql @@ -16,7 +16,7 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_10015 + FROM ***************************.fct_bookings bookings_source_src_10017 ) subq_13 LEFT OUTER JOIN ( -- Join Standard Outputs @@ -26,15 +26,15 @@ LEFT OUTER JOIN ( -- 'lux_listing__window_end__day', -- 'listing'] SELECT - lux_listings_src_10019.valid_from AS lux_listing__window_start__day - , lux_listings_src_10019.valid_to AS lux_listing__window_end__day - , lux_listing_mapping_src_10018.listing_id AS listing - , lux_listings_src_10019.is_confirmed_lux AS lux_listing__is_confirmed_lux - FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_10018 + lux_listings_src_10021.valid_from AS lux_listing__window_start__day + , lux_listings_src_10021.valid_to AS lux_listing__window_end__day + , lux_listing_mapping_src_10020.listing_id AS listing + , lux_listings_src_10021.is_confirmed_lux AS lux_listing__is_confirmed_lux + FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_10020 LEFT OUTER JOIN - ***************************.dim_lux_listings lux_listings_src_10019 + ***************************.dim_lux_listings lux_listings_src_10021 ON - lux_listing_mapping_src_10018.lux_listing_id = lux_listings_src_10019.lux_listing_id + lux_listing_mapping_src_10020.lux_listing_id = lux_listings_src_10021.lux_listing_id ) subq_18 ON ( diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multihop_node__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multihop_node__plan0.sql index 66555fd231..317c69a37f 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multihop_node__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multihop_node__plan0.sql @@ -93,55 +93,55 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'account_month_txns' SELECT - account_month_txns_src_10010.txn_count - , DATE_TRUNC('day', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', account_month_txns_src_10010.ds) AS ds__day - , DATE_TRUNC('week', account_month_txns_src_10010.ds) AS ds__week - , DATE_TRUNC('month', account_month_txns_src_10010.ds) AS ds__month - , DATE_TRUNC('quarter', account_month_txns_src_10010.ds) AS ds__quarter - , DATE_TRUNC('year', account_month_txns_src_10010.ds) AS ds__year - , EXTRACT(year FROM account_month_txns_src_10010.ds) AS ds__extract_year - , EXTRACT(quarter FROM account_month_txns_src_10010.ds) AS ds__extract_quarter - , EXTRACT(month FROM account_month_txns_src_10010.ds) AS ds__extract_month - , EXTRACT(day FROM account_month_txns_src_10010.ds) AS ds__extract_day - , EXTRACT(isodow FROM account_month_txns_src_10010.ds) AS ds__extract_dow - , EXTRACT(doy FROM account_month_txns_src_10010.ds) AS ds__extract_doy - , account_month_txns_src_10010.account_month - , DATE_TRUNC('day', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__day - , DATE_TRUNC('week', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__week - , DATE_TRUNC('month', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__month - , DATE_TRUNC('quarter', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__quarter - , DATE_TRUNC('year', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__year - , EXTRACT(year FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_month - , EXTRACT(day FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_day - , EXTRACT(isodow FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , DATE_TRUNC('day', account_month_txns_src_10010.ds) AS account_id__ds__day - , DATE_TRUNC('week', account_month_txns_src_10010.ds) AS account_id__ds__week - , DATE_TRUNC('month', account_month_txns_src_10010.ds) AS account_id__ds__month - , DATE_TRUNC('quarter', account_month_txns_src_10010.ds) AS account_id__ds__quarter - , DATE_TRUNC('year', account_month_txns_src_10010.ds) AS account_id__ds__year - , EXTRACT(year FROM account_month_txns_src_10010.ds) AS account_id__ds__extract_year - , EXTRACT(quarter FROM account_month_txns_src_10010.ds) AS account_id__ds__extract_quarter - , EXTRACT(month FROM account_month_txns_src_10010.ds) AS account_id__ds__extract_month - , EXTRACT(day FROM account_month_txns_src_10010.ds) AS account_id__ds__extract_day - , EXTRACT(isodow FROM account_month_txns_src_10010.ds) AS account_id__ds__extract_dow - , EXTRACT(doy FROM account_month_txns_src_10010.ds) AS account_id__ds__extract_doy - , account_month_txns_src_10010.account_month AS account_id__account_month - , account_month_txns_src_10010.account_id - FROM ***************************.account_month_txns account_month_txns_src_10010 + account_month_txns_src_10012.txn_count + , DATE_TRUNC('day', account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', account_month_txns_src_10012.ds) AS ds__day + , DATE_TRUNC('week', account_month_txns_src_10012.ds) AS ds__week + , DATE_TRUNC('month', account_month_txns_src_10012.ds) AS ds__month + , DATE_TRUNC('quarter', account_month_txns_src_10012.ds) AS ds__quarter + , DATE_TRUNC('year', account_month_txns_src_10012.ds) AS ds__year + , EXTRACT(year FROM account_month_txns_src_10012.ds) AS ds__extract_year + , EXTRACT(quarter FROM account_month_txns_src_10012.ds) AS ds__extract_quarter + , EXTRACT(month FROM account_month_txns_src_10012.ds) AS ds__extract_month + , EXTRACT(day FROM account_month_txns_src_10012.ds) AS ds__extract_day + , EXTRACT(isodow FROM account_month_txns_src_10012.ds) AS ds__extract_dow + , EXTRACT(doy FROM account_month_txns_src_10012.ds) AS ds__extract_doy + , account_month_txns_src_10012.account_month + , DATE_TRUNC('day', account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__day + , DATE_TRUNC('week', account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__week + , DATE_TRUNC('month', account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__month + , DATE_TRUNC('quarter', account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__quarter + , DATE_TRUNC('year', account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__year + , EXTRACT(year FROM account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__extract_month + , EXTRACT(day FROM account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__extract_day + , EXTRACT(isodow FROM account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__extract_doy + , DATE_TRUNC('day', account_month_txns_src_10012.ds) AS account_id__ds__day + , DATE_TRUNC('week', account_month_txns_src_10012.ds) AS account_id__ds__week + , DATE_TRUNC('month', account_month_txns_src_10012.ds) AS account_id__ds__month + , DATE_TRUNC('quarter', account_month_txns_src_10012.ds) AS account_id__ds__quarter + , DATE_TRUNC('year', account_month_txns_src_10012.ds) AS account_id__ds__year + , EXTRACT(year FROM account_month_txns_src_10012.ds) AS account_id__ds__extract_year + , EXTRACT(quarter FROM account_month_txns_src_10012.ds) AS account_id__ds__extract_quarter + , EXTRACT(month FROM account_month_txns_src_10012.ds) AS account_id__ds__extract_month + , EXTRACT(day FROM account_month_txns_src_10012.ds) AS account_id__ds__extract_day + , EXTRACT(isodow FROM account_month_txns_src_10012.ds) AS account_id__ds__extract_dow + , EXTRACT(doy FROM account_month_txns_src_10012.ds) AS account_id__ds__extract_doy + , account_month_txns_src_10012.account_month AS account_id__account_month + , account_month_txns_src_10012.account_id + FROM ***************************.account_month_txns account_month_txns_src_10012 ) subq_0 ) subq_1 ) subq_2 @@ -212,48 +212,48 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT - bridge_table_src_10011.extra_dim - , DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_doy - , bridge_table_src_10011.extra_dim AS account_id__extra_dim - , DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__day - , DATE_TRUNC('week', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__week - , DATE_TRUNC('month', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__month - , DATE_TRUNC('quarter', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__quarter - , DATE_TRUNC('year', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_day - , EXTRACT(isodow FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , bridge_table_src_10011.extra_dim AS bridge_account__extra_dim - , DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__day - , DATE_TRUNC('week', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__week - , DATE_TRUNC('month', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__month - , DATE_TRUNC('quarter', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__quarter - , DATE_TRUNC('year', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__extract_day - , EXTRACT(isodow FROM bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__extract_dow - , EXTRACT(doy FROM bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__extract_doy - , bridge_table_src_10011.account_id - , bridge_table_src_10011.customer_id - , bridge_table_src_10011.customer_id AS account_id__customer_id - , bridge_table_src_10011.account_id AS bridge_account__account_id - , bridge_table_src_10011.customer_id AS bridge_account__customer_id - FROM ***************************.bridge_table bridge_table_src_10011 + bridge_table_src_10013.extra_dim + , DATE_TRUNC('day', bridge_table_src_10013.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bridge_table_src_10013.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bridge_table_src_10013.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bridge_table_src_10013.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bridge_table_src_10013.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_10013.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_10013.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_10013.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_10013.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bridge_table_src_10013.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bridge_table_src_10013.ds_partitioned) AS ds_partitioned__extract_doy + , bridge_table_src_10013.extra_dim AS account_id__extra_dim + , DATE_TRUNC('day', bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__day + , DATE_TRUNC('week', bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__week + , DATE_TRUNC('month', bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__month + , DATE_TRUNC('quarter', bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__quarter + , DATE_TRUNC('year', bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__extract_day + , EXTRACT(isodow FROM bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__extract_doy + , bridge_table_src_10013.extra_dim AS bridge_account__extra_dim + , DATE_TRUNC('day', bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__day + , DATE_TRUNC('week', bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__week + , DATE_TRUNC('month', bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__month + , DATE_TRUNC('quarter', bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__quarter + , DATE_TRUNC('year', bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__extract_day + , EXTRACT(isodow FROM bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__extract_dow + , EXTRACT(doy FROM bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__extract_doy + , bridge_table_src_10013.account_id + , bridge_table_src_10013.customer_id + , bridge_table_src_10013.customer_id AS account_id__customer_id + , bridge_table_src_10013.account_id AS bridge_account__account_id + , bridge_table_src_10013.customer_id AS bridge_account__customer_id + FROM ***************************.bridge_table bridge_table_src_10013 ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: @@ -315,34 +315,34 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'customer_table' SELECT - customer_table_src_10013.customer_name - , customer_table_src_10013.customer_atomic_weight - , DATE_TRUNC('day', customer_table_src_10013.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', customer_table_src_10013.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', customer_table_src_10013.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', customer_table_src_10013.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', customer_table_src_10013.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_doy - , customer_table_src_10013.customer_name AS customer_id__customer_name - , customer_table_src_10013.customer_atomic_weight AS customer_id__customer_atomic_weight - , DATE_TRUNC('day', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__day - , DATE_TRUNC('week', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__week - , DATE_TRUNC('month', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__month - , DATE_TRUNC('quarter', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__quarter - , DATE_TRUNC('year', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__year - , EXTRACT(year FROM customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__extract_month - , EXTRACT(day FROM customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__extract_day - , EXTRACT(isodow FROM customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__extract_doy - , customer_table_src_10013.customer_id - FROM ***************************.customer_table customer_table_src_10013 + customer_table_src_10015.customer_name + , customer_table_src_10015.customer_atomic_weight + , DATE_TRUNC('day', customer_table_src_10015.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', customer_table_src_10015.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', customer_table_src_10015.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', customer_table_src_10015.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', customer_table_src_10015.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM customer_table_src_10015.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM customer_table_src_10015.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM customer_table_src_10015.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM customer_table_src_10015.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM customer_table_src_10015.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM customer_table_src_10015.ds_partitioned) AS ds_partitioned__extract_doy + , customer_table_src_10015.customer_name AS customer_id__customer_name + , customer_table_src_10015.customer_atomic_weight AS customer_id__customer_atomic_weight + , DATE_TRUNC('day', customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__day + , DATE_TRUNC('week', customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__week + , DATE_TRUNC('month', customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__month + , DATE_TRUNC('quarter', customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__quarter + , DATE_TRUNC('year', customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__year + , EXTRACT(year FROM customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__extract_month + , EXTRACT(day FROM customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__extract_day + , EXTRACT(isodow FROM customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__extract_doy + , customer_table_src_10015.customer_id + FROM ***************************.customer_table customer_table_src_10015 ) subq_4 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multihop_node__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multihop_node__plan0_optimized.sql index 8a42052413..65d688b745 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multihop_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multihop_node__plan0_optimized.sql @@ -5,31 +5,31 @@ -- Compute Metrics via Expressions SELECT subq_18.customer_id__customer_name AS account_id__customer_id__customer_name - , SUM(account_month_txns_src_10010.txn_count) AS txn_count -FROM ***************************.account_month_txns account_month_txns_src_10010 + , SUM(account_month_txns_src_10012.txn_count) AS txn_count +FROM ***************************.account_month_txns account_month_txns_src_10012 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: -- ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__day - , bridge_table_src_10011.account_id AS account_id - , customer_table_src_10013.customer_name AS customer_id__customer_name - FROM ***************************.bridge_table bridge_table_src_10011 + DATE_TRUNC('day', bridge_table_src_10013.ds_partitioned) AS ds_partitioned__day + , bridge_table_src_10013.account_id AS account_id + , customer_table_src_10015.customer_name AS customer_id__customer_name + FROM ***************************.bridge_table bridge_table_src_10013 LEFT OUTER JOIN - ***************************.customer_table customer_table_src_10013 + ***************************.customer_table customer_table_src_10015 ON ( - bridge_table_src_10011.customer_id = customer_table_src_10013.customer_id + bridge_table_src_10013.customer_id = customer_table_src_10015.customer_id ) AND ( - DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) = DATE_TRUNC('day', customer_table_src_10013.ds_partitioned) + DATE_TRUNC('day', bridge_table_src_10013.ds_partitioned) = DATE_TRUNC('day', customer_table_src_10015.ds_partitioned) ) ) subq_18 ON ( - account_month_txns_src_10010.account_id = subq_18.account_id + account_month_txns_src_10012.account_id = subq_18.account_id ) AND ( - DATE_TRUNC('day', account_month_txns_src_10010.ds_partitioned) = subq_18.ds_partitioned__day + DATE_TRUNC('day', account_month_txns_src_10012.ds_partitioned) = subq_18.ds_partitioned__day ) GROUP BY subq_18.customer_id__customer_name diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multiple_metrics_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multiple_metrics_no_dimensions__plan0.sql index 7ad1c04247..6552f995c8 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multiple_metrics_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multiple_metrics_no_dimensions__plan0.sql @@ -473,62 +473,62 @@ CROSS JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_6 ) subq_7 WHERE subq_7.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multiple_metrics_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multiple_metrics_no_dimensions__plan0_optimized.sql index 631546edf7..5fdefdb6a7 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multiple_metrics_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multiple_metrics_no_dimensions__plan0_optimized.sql @@ -25,6 +25,6 @@ CROSS JOIN ( -- Compute Metrics via Expressions SELECT SUM(1) AS listings - FROM ***************************.dim_listings_latest listings_latest_src_10004 + FROM ***************************.dim_listings_latest listings_latest_src_10005 WHERE DATE_TRUNC('day', created_at) BETWEEN '2020-01-01' AND '2020-01-01' ) subq_23 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_partitioned_join__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_partitioned_join__plan0.sql index 1673729a9a..166092a420 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_partitioned_join__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_partitioned_join__plan0.sql @@ -96,56 +96,56 @@ FROM ( -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , DATE_TRUNC('day', id_verifications_src_10003.ds) AS ds__day - , DATE_TRUNC('week', id_verifications_src_10003.ds) AS ds__week - , DATE_TRUNC('month', id_verifications_src_10003.ds) AS ds__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS ds__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds) AS ds__year - , EXTRACT(year FROM id_verifications_src_10003.ds) AS ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds) AS ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds) AS ds__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds) AS ds__extract_day - , EXTRACT(isodow FROM id_verifications_src_10003.ds) AS ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds) AS ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_doy - , id_verifications_src_10003.verification_type - , DATE_TRUNC('day', id_verifications_src_10003.ds) AS verification__ds__day - , DATE_TRUNC('week', id_verifications_src_10003.ds) AS verification__ds__week - , DATE_TRUNC('month', id_verifications_src_10003.ds) AS verification__ds__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS verification__ds__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds) AS verification__ds__year - , EXTRACT(year FROM id_verifications_src_10003.ds) AS verification__ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds) AS verification__ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds) AS verification__ds__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds) AS verification__ds__extract_day - , EXTRACT(isodow FROM id_verifications_src_10003.ds) AS verification__ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds) AS verification__ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_day - , EXTRACT(isodow FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_doy - , id_verifications_src_10003.verification_type AS verification__verification_type - , id_verifications_src_10003.verification_id AS verification - , id_verifications_src_10003.user_id AS user - , id_verifications_src_10003.user_id AS verification__user - FROM ***************************.fct_id_verifications id_verifications_src_10003 + , DATE_TRUNC('day', id_verifications_src_10004.ds) AS ds__day + , DATE_TRUNC('week', id_verifications_src_10004.ds) AS ds__week + , DATE_TRUNC('month', id_verifications_src_10004.ds) AS ds__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds) AS ds__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds) AS ds__year + , EXTRACT(year FROM id_verifications_src_10004.ds) AS ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds) AS ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds) AS ds__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds) AS ds__extract_day + , EXTRACT(isodow FROM id_verifications_src_10004.ds) AS ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds) AS ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_doy + , id_verifications_src_10004.verification_type + , DATE_TRUNC('day', id_verifications_src_10004.ds) AS verification__ds__day + , DATE_TRUNC('week', id_verifications_src_10004.ds) AS verification__ds__week + , DATE_TRUNC('month', id_verifications_src_10004.ds) AS verification__ds__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds) AS verification__ds__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds) AS verification__ds__year + , EXTRACT(year FROM id_verifications_src_10004.ds) AS verification__ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds) AS verification__ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds) AS verification__ds__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds) AS verification__ds__extract_day + , EXTRACT(isodow FROM id_verifications_src_10004.ds) AS verification__ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds) AS verification__ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_day + , EXTRACT(isodow FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_doy + , id_verifications_src_10004.verification_type AS verification__verification_type + , id_verifications_src_10004.verification_id AS verification + , id_verifications_src_10004.user_id AS user + , id_verifications_src_10004.user_id AS verification__user + FROM ***************************.fct_id_verifications id_verifications_src_10004 ) subq_0 ) subq_1 ) subq_2 @@ -159,76 +159,76 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT - DATE_TRUNC('day', users_ds_source_src_10007.ds) AS ds__day - , DATE_TRUNC('week', users_ds_source_src_10007.ds) AS ds__week - , DATE_TRUNC('month', users_ds_source_src_10007.ds) AS ds__month - , DATE_TRUNC('quarter', users_ds_source_src_10007.ds) AS ds__quarter - , DATE_TRUNC('year', users_ds_source_src_10007.ds) AS ds__year - , EXTRACT(year FROM users_ds_source_src_10007.ds) AS ds__extract_year - , EXTRACT(quarter FROM users_ds_source_src_10007.ds) AS ds__extract_quarter - , EXTRACT(month FROM users_ds_source_src_10007.ds) AS ds__extract_month - , EXTRACT(day FROM users_ds_source_src_10007.ds) AS ds__extract_day - , EXTRACT(isodow FROM users_ds_source_src_10007.ds) AS ds__extract_dow - , EXTRACT(doy FROM users_ds_source_src_10007.ds) AS ds__extract_doy - , DATE_TRUNC('day', users_ds_source_src_10007.created_at) AS created_at__day - , DATE_TRUNC('week', users_ds_source_src_10007.created_at) AS created_at__week - , DATE_TRUNC('month', users_ds_source_src_10007.created_at) AS created_at__month - , DATE_TRUNC('quarter', users_ds_source_src_10007.created_at) AS created_at__quarter - , DATE_TRUNC('year', users_ds_source_src_10007.created_at) AS created_at__year - , EXTRACT(year FROM users_ds_source_src_10007.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_10007.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_10007.created_at) AS created_at__extract_month - , EXTRACT(day FROM users_ds_source_src_10007.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM users_ds_source_src_10007.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_10007.created_at) AS created_at__extract_doy - , DATE_TRUNC('day', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_doy - , users_ds_source_src_10007.home_state - , DATE_TRUNC('day', users_ds_source_src_10007.ds) AS user__ds__day - , DATE_TRUNC('week', users_ds_source_src_10007.ds) AS user__ds__week - , DATE_TRUNC('month', users_ds_source_src_10007.ds) AS user__ds__month - , DATE_TRUNC('quarter', users_ds_source_src_10007.ds) AS user__ds__quarter - , DATE_TRUNC('year', users_ds_source_src_10007.ds) AS user__ds__year - , EXTRACT(year FROM users_ds_source_src_10007.ds) AS user__ds__extract_year - , EXTRACT(quarter FROM users_ds_source_src_10007.ds) AS user__ds__extract_quarter - , EXTRACT(month FROM users_ds_source_src_10007.ds) AS user__ds__extract_month - , EXTRACT(day FROM users_ds_source_src_10007.ds) AS user__ds__extract_day - , EXTRACT(isodow FROM users_ds_source_src_10007.ds) AS user__ds__extract_dow - , EXTRACT(doy FROM users_ds_source_src_10007.ds) AS user__ds__extract_doy - , DATE_TRUNC('day', users_ds_source_src_10007.created_at) AS user__created_at__day - , DATE_TRUNC('week', users_ds_source_src_10007.created_at) AS user__created_at__week - , DATE_TRUNC('month', users_ds_source_src_10007.created_at) AS user__created_at__month - , DATE_TRUNC('quarter', users_ds_source_src_10007.created_at) AS user__created_at__quarter - , DATE_TRUNC('year', users_ds_source_src_10007.created_at) AS user__created_at__year - , EXTRACT(year FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_month - , EXTRACT(day FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_day - , EXTRACT(isodow FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_doy - , DATE_TRUNC('day', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__day - , DATE_TRUNC('week', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__week - , DATE_TRUNC('month', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__month - , DATE_TRUNC('quarter', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__quarter - , DATE_TRUNC('year', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__year - , EXTRACT(year FROM users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__extract_year - , EXTRACT(quarter FROM users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__extract_quarter - , EXTRACT(month FROM users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__extract_month - , EXTRACT(day FROM users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__extract_day - , EXTRACT(isodow FROM users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__extract_dow - , EXTRACT(doy FROM users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__extract_doy - , users_ds_source_src_10007.home_state AS user__home_state - , users_ds_source_src_10007.user_id AS user - FROM ***************************.dim_users users_ds_source_src_10007 + DATE_TRUNC('day', users_ds_source_src_10008.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_10008.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_10008.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_10008.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_10008.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_10008.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_10008.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_10008.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_10008.ds) AS ds__extract_day + , EXTRACT(isodow FROM users_ds_source_src_10008.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_10008.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_10008.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_10008.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_10008.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_10008.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_10008.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_10008.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_10008.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_10008.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_10008.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_10008.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_10008.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_10008.home_state + , DATE_TRUNC('day', users_ds_source_src_10008.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_10008.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_10008.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_10008.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_10008.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_10008.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_10008.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_10008.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_10008.ds) AS user__ds__extract_day + , EXTRACT(isodow FROM users_ds_source_src_10008.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_10008.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_10008.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_10008.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_10008.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_10008.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_10008.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_10008.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_10008.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_10008.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_10008.created_at) AS user__created_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_10008.created_at) AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_10008.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__extract_day + , EXTRACT(isodow FROM users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_10008.home_state AS user__home_state + , users_ds_source_src_10008.user_id AS user + FROM ***************************.dim_users users_ds_source_src_10008 ) subq_3 ) subq_4 ON diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_partitioned_join__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_partitioned_join__plan0_optimized.sql index c15982d861..b52d743037 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_partitioned_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_partitioned_join__plan0_optimized.sql @@ -4,7 +4,7 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - users_ds_source_src_10007.home_state AS user__home_state + users_ds_source_src_10008.home_state AS user__home_state , SUM(subq_10.identity_verifications) AS identity_verifications FROM ( -- Read Elements From Semantic Model 'id_verifications' @@ -15,15 +15,15 @@ FROM ( DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , user_id AS user , 1 AS identity_verifications - FROM ***************************.fct_id_verifications id_verifications_src_10003 + FROM ***************************.fct_id_verifications id_verifications_src_10004 ) subq_10 LEFT OUTER JOIN - ***************************.dim_users users_ds_source_src_10007 + ***************************.dim_users users_ds_source_src_10008 ON ( - subq_10.user = users_ds_source_src_10007.user_id + subq_10.user = users_ds_source_src_10008.user_id ) AND ( - subq_10.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_10007.ds_partitioned) + subq_10.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_10008.ds_partitioned) ) GROUP BY - users_ds_source_src_10007.home_state + users_ds_source_src_10008.home_state diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_distinct_values__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_distinct_values__plan0.sql index 7a6a9e1f3d..48e2471976 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_distinct_values__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_distinct_values__plan0.sql @@ -69,62 +69,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_0 WHERE listing__country_latest = 'us' ) subq_1 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_distinct_values__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_distinct_values__plan0_optimized.sql index ec0d94dac2..53c7bf823f 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_distinct_values__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_distinct_values__plan0_optimized.sql @@ -8,7 +8,7 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT country AS listing__country_latest - FROM ***************************.dim_listings_latest listings_latest_src_10004 + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_3 WHERE listing__country_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_on_join_dim__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_on_join_dim__plan0.sql index 99c4cea0ad..9645c25280 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_on_join_dim__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_on_join_dim__plan0.sql @@ -316,62 +316,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_3 ) subq_4 ) subq_5 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql index 19b1b78329..d00b32fb24 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql @@ -12,7 +12,7 @@ FROM ( -- ['bookings', 'booking__is_instant', 'listing__country_latest'] SELECT subq_13.booking__is_instant AS booking__is_instant - , listings_latest_src_10004.country AS listing__country_latest + , listings_latest_src_10005.country AS listing__country_latest , subq_13.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -26,9 +26,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_13 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_13.listing = listings_latest_src_10004.listing_id + subq_13.listing = listings_latest_src_10005.listing_id ) subq_18 WHERE listing__country_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_join_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_join_to_scd_dimension__plan0.sql index d6f3055b49..e0d6b9598a 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_join_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_join_to_scd_dimension__plan0.sql @@ -142,87 +142,87 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_10015.booking_value - , bookings_source_src_10015.guest_id AS bookers - , bookings_source_src_10015.booking_value AS average_booking_value - , bookings_source_src_10015.booking_value AS booking_payments - , bookings_source_src_10015.is_instant - , DATE_TRUNC('day', bookings_source_src_10015.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_10015.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_10015.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_10015.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_10015.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_10015.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_10015.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_10015.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_10015.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS paid_at__extract_doy - , bookings_source_src_10015.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_10015.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_10015.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_10015.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_10015.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_10015.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_10015.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_10015.listing_id AS listing - , bookings_source_src_10015.guest_id AS guest - , bookings_source_src_10015.host_id AS host - , bookings_source_src_10015.guest_id AS user - , bookings_source_src_10015.listing_id AS booking__listing - , bookings_source_src_10015.guest_id AS booking__guest - , bookings_source_src_10015.host_id AS booking__host - , bookings_source_src_10015.guest_id AS booking__user - FROM ***************************.fct_bookings bookings_source_src_10015 + , bookings_source_src_10017.booking_value + , bookings_source_src_10017.guest_id AS bookers + , bookings_source_src_10017.booking_value AS average_booking_value + , bookings_source_src_10017.booking_value AS booking_payments + , bookings_source_src_10017.is_instant + , DATE_TRUNC('day', bookings_source_src_10017.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_10017.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_10017.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_10017.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_10017.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_10017.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_10017.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_10017.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_10017.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_10017.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_10017.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_10017.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.paid_at) AS paid_at__extract_doy + , bookings_source_src_10017.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_10017.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_10017.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_10017.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_10017.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_10017.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_10017.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_10017.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_10017.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_10017.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_10017.listing_id AS listing + , bookings_source_src_10017.guest_id AS guest + , bookings_source_src_10017.host_id AS host + , bookings_source_src_10017.guest_id AS user + , bookings_source_src_10017.listing_id AS booking__listing + , bookings_source_src_10017.guest_id AS booking__guest + , bookings_source_src_10017.host_id AS booking__host + , bookings_source_src_10017.guest_id AS booking__user + FROM ***************************.fct_bookings bookings_source_src_10017 ) subq_0 ) subq_1 ) subq_2 @@ -237,60 +237,60 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'listings' SELECT - listings_src_10017.active_from AS window_start__day - , DATE_TRUNC('week', listings_src_10017.active_from) AS window_start__week - , DATE_TRUNC('month', listings_src_10017.active_from) AS window_start__month - , DATE_TRUNC('quarter', listings_src_10017.active_from) AS window_start__quarter - , DATE_TRUNC('year', listings_src_10017.active_from) AS window_start__year - , EXTRACT(year FROM listings_src_10017.active_from) AS window_start__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_from) AS window_start__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_from) AS window_start__extract_month - , EXTRACT(day FROM listings_src_10017.active_from) AS window_start__extract_day - , EXTRACT(isodow FROM listings_src_10017.active_from) AS window_start__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_from) AS window_start__extract_doy - , listings_src_10017.active_to AS window_end__day - , DATE_TRUNC('week', listings_src_10017.active_to) AS window_end__week - , DATE_TRUNC('month', listings_src_10017.active_to) AS window_end__month - , DATE_TRUNC('quarter', listings_src_10017.active_to) AS window_end__quarter - , DATE_TRUNC('year', listings_src_10017.active_to) AS window_end__year - , EXTRACT(year FROM listings_src_10017.active_to) AS window_end__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_to) AS window_end__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_to) AS window_end__extract_month - , EXTRACT(day FROM listings_src_10017.active_to) AS window_end__extract_day - , EXTRACT(isodow FROM listings_src_10017.active_to) AS window_end__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_to) AS window_end__extract_doy - , listings_src_10017.country - , listings_src_10017.is_lux - , listings_src_10017.capacity - , listings_src_10017.active_from AS listing__window_start__day - , DATE_TRUNC('week', listings_src_10017.active_from) AS listing__window_start__week - , DATE_TRUNC('month', listings_src_10017.active_from) AS listing__window_start__month - , DATE_TRUNC('quarter', listings_src_10017.active_from) AS listing__window_start__quarter - , DATE_TRUNC('year', listings_src_10017.active_from) AS listing__window_start__year - , EXTRACT(year FROM listings_src_10017.active_from) AS listing__window_start__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_from) AS listing__window_start__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_from) AS listing__window_start__extract_month - , EXTRACT(day FROM listings_src_10017.active_from) AS listing__window_start__extract_day - , EXTRACT(isodow FROM listings_src_10017.active_from) AS listing__window_start__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_from) AS listing__window_start__extract_doy - , listings_src_10017.active_to AS listing__window_end__day - , DATE_TRUNC('week', listings_src_10017.active_to) AS listing__window_end__week - , DATE_TRUNC('month', listings_src_10017.active_to) AS listing__window_end__month - , DATE_TRUNC('quarter', listings_src_10017.active_to) AS listing__window_end__quarter - , DATE_TRUNC('year', listings_src_10017.active_to) AS listing__window_end__year - , EXTRACT(year FROM listings_src_10017.active_to) AS listing__window_end__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_to) AS listing__window_end__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_to) AS listing__window_end__extract_month - , EXTRACT(day FROM listings_src_10017.active_to) AS listing__window_end__extract_day - , EXTRACT(isodow FROM listings_src_10017.active_to) AS listing__window_end__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_to) AS listing__window_end__extract_doy - , listings_src_10017.country AS listing__country - , listings_src_10017.is_lux AS listing__is_lux - , listings_src_10017.capacity AS listing__capacity - , listings_src_10017.listing_id AS listing - , listings_src_10017.user_id AS user - , listings_src_10017.user_id AS listing__user - FROM ***************************.dim_listings listings_src_10017 + listings_src_10019.active_from AS window_start__day + , DATE_TRUNC('week', listings_src_10019.active_from) AS window_start__week + , DATE_TRUNC('month', listings_src_10019.active_from) AS window_start__month + , DATE_TRUNC('quarter', listings_src_10019.active_from) AS window_start__quarter + , DATE_TRUNC('year', listings_src_10019.active_from) AS window_start__year + , EXTRACT(year FROM listings_src_10019.active_from) AS window_start__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_from) AS window_start__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_from) AS window_start__extract_month + , EXTRACT(day FROM listings_src_10019.active_from) AS window_start__extract_day + , EXTRACT(isodow FROM listings_src_10019.active_from) AS window_start__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_from) AS window_start__extract_doy + , listings_src_10019.active_to AS window_end__day + , DATE_TRUNC('week', listings_src_10019.active_to) AS window_end__week + , DATE_TRUNC('month', listings_src_10019.active_to) AS window_end__month + , DATE_TRUNC('quarter', listings_src_10019.active_to) AS window_end__quarter + , DATE_TRUNC('year', listings_src_10019.active_to) AS window_end__year + , EXTRACT(year FROM listings_src_10019.active_to) AS window_end__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_to) AS window_end__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_to) AS window_end__extract_month + , EXTRACT(day FROM listings_src_10019.active_to) AS window_end__extract_day + , EXTRACT(isodow FROM listings_src_10019.active_to) AS window_end__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_to) AS window_end__extract_doy + , listings_src_10019.country + , listings_src_10019.is_lux + , listings_src_10019.capacity + , listings_src_10019.active_from AS listing__window_start__day + , DATE_TRUNC('week', listings_src_10019.active_from) AS listing__window_start__week + , DATE_TRUNC('month', listings_src_10019.active_from) AS listing__window_start__month + , DATE_TRUNC('quarter', listings_src_10019.active_from) AS listing__window_start__quarter + , DATE_TRUNC('year', listings_src_10019.active_from) AS listing__window_start__year + , EXTRACT(year FROM listings_src_10019.active_from) AS listing__window_start__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_from) AS listing__window_start__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_from) AS listing__window_start__extract_month + , EXTRACT(day FROM listings_src_10019.active_from) AS listing__window_start__extract_day + , EXTRACT(isodow FROM listings_src_10019.active_from) AS listing__window_start__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_from) AS listing__window_start__extract_doy + , listings_src_10019.active_to AS listing__window_end__day + , DATE_TRUNC('week', listings_src_10019.active_to) AS listing__window_end__week + , DATE_TRUNC('month', listings_src_10019.active_to) AS listing__window_end__month + , DATE_TRUNC('quarter', listings_src_10019.active_to) AS listing__window_end__quarter + , DATE_TRUNC('year', listings_src_10019.active_to) AS listing__window_end__year + , EXTRACT(year FROM listings_src_10019.active_to) AS listing__window_end__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_to) AS listing__window_end__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_to) AS listing__window_end__extract_month + , EXTRACT(day FROM listings_src_10019.active_to) AS listing__window_end__extract_day + , EXTRACT(isodow FROM listings_src_10019.active_to) AS listing__window_end__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_to) AS listing__window_end__extract_doy + , listings_src_10019.country AS listing__country + , listings_src_10019.is_lux AS listing__is_lux + , listings_src_10019.capacity AS listing__capacity + , listings_src_10019.listing_id AS listing + , listings_src_10019.user_id AS user + , listings_src_10019.user_id AS listing__user + FROM ***************************.dim_listings listings_src_10019 ) subq_3 ) subq_4 ON diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_join_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_join_to_scd_dimension__plan0_optimized.sql index db1199fc2e..662445e5ef 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_join_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_join_to_scd_dimension__plan0_optimized.sql @@ -12,7 +12,7 @@ FROM ( -- ['bookings', 'listing__capacity', 'metric_time__day'] SELECT subq_12.metric_time__day AS metric_time__day - , listings_src_10017.capacity AS listing__capacity + , listings_src_10019.capacity AS listing__capacity , subq_12.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -23,21 +23,21 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_10015 + FROM ***************************.fct_bookings bookings_source_src_10017 ) subq_12 LEFT OUTER JOIN - ***************************.dim_listings listings_src_10017 + ***************************.dim_listings listings_src_10019 ON ( - subq_12.listing = listings_src_10017.listing_id + subq_12.listing = listings_src_10019.listing_id ) AND ( ( - subq_12.metric_time__day >= listings_src_10017.active_from + subq_12.metric_time__day >= listings_src_10019.active_from ) AND ( ( - subq_12.metric_time__day < listings_src_10017.active_to + subq_12.metric_time__day < listings_src_10019.active_to ) OR ( - listings_src_10017.active_to IS NULL + listings_src_10019.active_to IS NULL ) ) ) diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_local_dimension_using_local_entity__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_local_dimension_using_local_entity__plan0.sql index d3d98e92e5..71d2f78bb5 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_local_dimension_using_local_entity__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_local_dimension_using_local_entity__plan0.sql @@ -87,62 +87,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_0 ) subq_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_local_dimension_using_local_entity__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_local_dimension_using_local_entity__plan0_optimized.sql index f7932552c3..2c5690447e 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_local_dimension_using_local_entity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_local_dimension_using_local_entity__plan0_optimized.sql @@ -11,7 +11,7 @@ FROM ( SELECT country AS listing__country_latest , 1 AS listings - FROM ***************************.dim_listings_latest listings_latest_src_10004 + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_6 GROUP BY listing__country_latest diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0.sql index b314ea28d3..8a3cdca410 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0.sql @@ -328,62 +328,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_3 ) subq_4 ) subq_5 @@ -717,62 +717,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_15 ) subq_16 ) subq_17 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0_optimized.sql index 3c0c641be9..5581a37a67 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0_optimized.sql @@ -24,13 +24,13 @@ FROM ( -- ['average_booking_value', 'listing__is_lux_latest', 'metric_time__day'] SELECT DATE_TRUNC('day', bookings_source_src_10001.ds) AS metric_time__day - , listings_latest_src_10004.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest , bookings_source_src_10001.booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_10001 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - bookings_source_src_10001.listing_id = listings_latest_src_10004.listing_id + bookings_source_src_10001.listing_id = listings_latest_src_10005.listing_id ) subq_37 WHERE listing__is_lux_latest GROUP BY @@ -51,7 +51,7 @@ FROM ( -- ['bookings', 'listing__is_lux_latest', 'metric_time__day'] SELECT subq_44.metric_time__day AS metric_time__day - , listings_latest_src_10004.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest , subq_44.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -65,9 +65,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_44 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_44.listing = listings_latest_src_10004.listing_id + subq_44.listing = listings_latest_src_10005.listing_id ) subq_49 WHERE listing__is_lux_latest GROUP BY diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql index 8222b0adff..51a19b2509 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql @@ -304,62 +304,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_5 ) subq_6 ) subq_7 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql index c48f7d8d21..7dc6fd2c91 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql @@ -22,5 +22,5 @@ CROSS JOIN ( -- Compute Metrics via Expressions SELECT SUM(1) AS listings - FROM ***************************.dim_listings_latest listings_latest_src_10004 + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_20 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0.sql index dcc369e93e..df68607098 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0.sql @@ -132,87 +132,87 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_10015.booking_value - , bookings_source_src_10015.guest_id AS bookers - , bookings_source_src_10015.booking_value AS average_booking_value - , bookings_source_src_10015.booking_value AS booking_payments - , bookings_source_src_10015.is_instant - , DATE_TRUNC('day', bookings_source_src_10015.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_10015.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_10015.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_10015.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_10015.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_10015.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_10015.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_10015.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_10015.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS paid_at__extract_doy - , bookings_source_src_10015.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_10015.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_10015.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_10015.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_10015.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_10015.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_10015.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_10015.listing_id AS listing - , bookings_source_src_10015.guest_id AS guest - , bookings_source_src_10015.host_id AS host - , bookings_source_src_10015.guest_id AS user - , bookings_source_src_10015.listing_id AS booking__listing - , bookings_source_src_10015.guest_id AS booking__guest - , bookings_source_src_10015.host_id AS booking__host - , bookings_source_src_10015.guest_id AS booking__user - FROM ***************************.fct_bookings bookings_source_src_10015 + , bookings_source_src_10017.booking_value + , bookings_source_src_10017.guest_id AS bookers + , bookings_source_src_10017.booking_value AS average_booking_value + , bookings_source_src_10017.booking_value AS booking_payments + , bookings_source_src_10017.is_instant + , DATE_TRUNC('day', bookings_source_src_10017.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_10017.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_10017.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_10017.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_10017.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_10017.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_10017.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_10017.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_10017.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_10017.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_10017.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_10017.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.paid_at) AS paid_at__extract_doy + , bookings_source_src_10017.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_10017.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_10017.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_10017.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_10017.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_10017.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_10017.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_10017.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_10017.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_10017.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_10017.listing_id AS listing + , bookings_source_src_10017.guest_id AS guest + , bookings_source_src_10017.host_id AS host + , bookings_source_src_10017.guest_id AS user + , bookings_source_src_10017.listing_id AS booking__listing + , bookings_source_src_10017.guest_id AS booking__guest + , bookings_source_src_10017.host_id AS booking__host + , bookings_source_src_10017.guest_id AS booking__user + FROM ***************************.fct_bookings bookings_source_src_10017 ) subq_0 ) subq_1 ) subq_2 @@ -295,60 +295,60 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'listings' SELECT - listings_src_10017.active_from AS window_start__day - , DATE_TRUNC('week', listings_src_10017.active_from) AS window_start__week - , DATE_TRUNC('month', listings_src_10017.active_from) AS window_start__month - , DATE_TRUNC('quarter', listings_src_10017.active_from) AS window_start__quarter - , DATE_TRUNC('year', listings_src_10017.active_from) AS window_start__year - , EXTRACT(year FROM listings_src_10017.active_from) AS window_start__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_from) AS window_start__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_from) AS window_start__extract_month - , EXTRACT(day FROM listings_src_10017.active_from) AS window_start__extract_day - , EXTRACT(isodow FROM listings_src_10017.active_from) AS window_start__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_from) AS window_start__extract_doy - , listings_src_10017.active_to AS window_end__day - , DATE_TRUNC('week', listings_src_10017.active_to) AS window_end__week - , DATE_TRUNC('month', listings_src_10017.active_to) AS window_end__month - , DATE_TRUNC('quarter', listings_src_10017.active_to) AS window_end__quarter - , DATE_TRUNC('year', listings_src_10017.active_to) AS window_end__year - , EXTRACT(year FROM listings_src_10017.active_to) AS window_end__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_to) AS window_end__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_to) AS window_end__extract_month - , EXTRACT(day FROM listings_src_10017.active_to) AS window_end__extract_day - , EXTRACT(isodow FROM listings_src_10017.active_to) AS window_end__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_to) AS window_end__extract_doy - , listings_src_10017.country - , listings_src_10017.is_lux - , listings_src_10017.capacity - , listings_src_10017.active_from AS listing__window_start__day - , DATE_TRUNC('week', listings_src_10017.active_from) AS listing__window_start__week - , DATE_TRUNC('month', listings_src_10017.active_from) AS listing__window_start__month - , DATE_TRUNC('quarter', listings_src_10017.active_from) AS listing__window_start__quarter - , DATE_TRUNC('year', listings_src_10017.active_from) AS listing__window_start__year - , EXTRACT(year FROM listings_src_10017.active_from) AS listing__window_start__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_from) AS listing__window_start__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_from) AS listing__window_start__extract_month - , EXTRACT(day FROM listings_src_10017.active_from) AS listing__window_start__extract_day - , EXTRACT(isodow FROM listings_src_10017.active_from) AS listing__window_start__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_from) AS listing__window_start__extract_doy - , listings_src_10017.active_to AS listing__window_end__day - , DATE_TRUNC('week', listings_src_10017.active_to) AS listing__window_end__week - , DATE_TRUNC('month', listings_src_10017.active_to) AS listing__window_end__month - , DATE_TRUNC('quarter', listings_src_10017.active_to) AS listing__window_end__quarter - , DATE_TRUNC('year', listings_src_10017.active_to) AS listing__window_end__year - , EXTRACT(year FROM listings_src_10017.active_to) AS listing__window_end__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_to) AS listing__window_end__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_to) AS listing__window_end__extract_month - , EXTRACT(day FROM listings_src_10017.active_to) AS listing__window_end__extract_day - , EXTRACT(isodow FROM listings_src_10017.active_to) AS listing__window_end__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_to) AS listing__window_end__extract_doy - , listings_src_10017.country AS listing__country - , listings_src_10017.is_lux AS listing__is_lux - , listings_src_10017.capacity AS listing__capacity - , listings_src_10017.listing_id AS listing - , listings_src_10017.user_id AS user - , listings_src_10017.user_id AS listing__user - FROM ***************************.dim_listings listings_src_10017 + listings_src_10019.active_from AS window_start__day + , DATE_TRUNC('week', listings_src_10019.active_from) AS window_start__week + , DATE_TRUNC('month', listings_src_10019.active_from) AS window_start__month + , DATE_TRUNC('quarter', listings_src_10019.active_from) AS window_start__quarter + , DATE_TRUNC('year', listings_src_10019.active_from) AS window_start__year + , EXTRACT(year FROM listings_src_10019.active_from) AS window_start__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_from) AS window_start__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_from) AS window_start__extract_month + , EXTRACT(day FROM listings_src_10019.active_from) AS window_start__extract_day + , EXTRACT(isodow FROM listings_src_10019.active_from) AS window_start__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_from) AS window_start__extract_doy + , listings_src_10019.active_to AS window_end__day + , DATE_TRUNC('week', listings_src_10019.active_to) AS window_end__week + , DATE_TRUNC('month', listings_src_10019.active_to) AS window_end__month + , DATE_TRUNC('quarter', listings_src_10019.active_to) AS window_end__quarter + , DATE_TRUNC('year', listings_src_10019.active_to) AS window_end__year + , EXTRACT(year FROM listings_src_10019.active_to) AS window_end__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_to) AS window_end__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_to) AS window_end__extract_month + , EXTRACT(day FROM listings_src_10019.active_to) AS window_end__extract_day + , EXTRACT(isodow FROM listings_src_10019.active_to) AS window_end__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_to) AS window_end__extract_doy + , listings_src_10019.country + , listings_src_10019.is_lux + , listings_src_10019.capacity + , listings_src_10019.active_from AS listing__window_start__day + , DATE_TRUNC('week', listings_src_10019.active_from) AS listing__window_start__week + , DATE_TRUNC('month', listings_src_10019.active_from) AS listing__window_start__month + , DATE_TRUNC('quarter', listings_src_10019.active_from) AS listing__window_start__quarter + , DATE_TRUNC('year', listings_src_10019.active_from) AS listing__window_start__year + , EXTRACT(year FROM listings_src_10019.active_from) AS listing__window_start__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_from) AS listing__window_start__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_from) AS listing__window_start__extract_month + , EXTRACT(day FROM listings_src_10019.active_from) AS listing__window_start__extract_day + , EXTRACT(isodow FROM listings_src_10019.active_from) AS listing__window_start__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_from) AS listing__window_start__extract_doy + , listings_src_10019.active_to AS listing__window_end__day + , DATE_TRUNC('week', listings_src_10019.active_to) AS listing__window_end__week + , DATE_TRUNC('month', listings_src_10019.active_to) AS listing__window_end__month + , DATE_TRUNC('quarter', listings_src_10019.active_to) AS listing__window_end__quarter + , DATE_TRUNC('year', listings_src_10019.active_to) AS listing__window_end__year + , EXTRACT(year FROM listings_src_10019.active_to) AS listing__window_end__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_to) AS listing__window_end__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_to) AS listing__window_end__extract_month + , EXTRACT(day FROM listings_src_10019.active_to) AS listing__window_end__extract_day + , EXTRACT(isodow FROM listings_src_10019.active_to) AS listing__window_end__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_to) AS listing__window_end__extract_doy + , listings_src_10019.country AS listing__country + , listings_src_10019.is_lux AS listing__is_lux + , listings_src_10019.capacity AS listing__capacity + , listings_src_10019.listing_id AS listing + , listings_src_10019.user_id AS user + , listings_src_10019.user_id AS listing__user + FROM ***************************.dim_listings listings_src_10019 ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: @@ -406,32 +406,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_10021.ds) AS ds__day - , DATE_TRUNC('week', users_latest_src_10021.ds) AS ds__week - , DATE_TRUNC('month', users_latest_src_10021.ds) AS ds__month - , DATE_TRUNC('quarter', users_latest_src_10021.ds) AS ds__quarter - , DATE_TRUNC('year', users_latest_src_10021.ds) AS ds__year - , EXTRACT(year FROM users_latest_src_10021.ds) AS ds__extract_year - , EXTRACT(quarter FROM users_latest_src_10021.ds) AS ds__extract_quarter - , EXTRACT(month FROM users_latest_src_10021.ds) AS ds__extract_month - , EXTRACT(day FROM users_latest_src_10021.ds) AS ds__extract_day - , EXTRACT(isodow FROM users_latest_src_10021.ds) AS ds__extract_dow - , EXTRACT(doy FROM users_latest_src_10021.ds) AS ds__extract_doy - , users_latest_src_10021.home_state_latest - , DATE_TRUNC('day', users_latest_src_10021.ds) AS user__ds__day - , DATE_TRUNC('week', users_latest_src_10021.ds) AS user__ds__week - , DATE_TRUNC('month', users_latest_src_10021.ds) AS user__ds__month - , DATE_TRUNC('quarter', users_latest_src_10021.ds) AS user__ds__quarter - , DATE_TRUNC('year', users_latest_src_10021.ds) AS user__ds__year - , EXTRACT(year FROM users_latest_src_10021.ds) AS user__ds__extract_year - , EXTRACT(quarter FROM users_latest_src_10021.ds) AS user__ds__extract_quarter - , EXTRACT(month FROM users_latest_src_10021.ds) AS user__ds__extract_month - , EXTRACT(day FROM users_latest_src_10021.ds) AS user__ds__extract_day - , EXTRACT(isodow FROM users_latest_src_10021.ds) AS user__ds__extract_dow - , EXTRACT(doy FROM users_latest_src_10021.ds) AS user__ds__extract_doy - , users_latest_src_10021.home_state_latest AS user__home_state_latest - , users_latest_src_10021.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_10021 + DATE_TRUNC('day', users_latest_src_10023.ds) AS ds__day + , DATE_TRUNC('week', users_latest_src_10023.ds) AS ds__week + , DATE_TRUNC('month', users_latest_src_10023.ds) AS ds__month + , DATE_TRUNC('quarter', users_latest_src_10023.ds) AS ds__quarter + , DATE_TRUNC('year', users_latest_src_10023.ds) AS ds__year + , EXTRACT(year FROM users_latest_src_10023.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_latest_src_10023.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_latest_src_10023.ds) AS ds__extract_month + , EXTRACT(day FROM users_latest_src_10023.ds) AS ds__extract_day + , EXTRACT(isodow FROM users_latest_src_10023.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_latest_src_10023.ds) AS ds__extract_doy + , users_latest_src_10023.home_state_latest + , DATE_TRUNC('day', users_latest_src_10023.ds) AS user__ds__day + , DATE_TRUNC('week', users_latest_src_10023.ds) AS user__ds__week + , DATE_TRUNC('month', users_latest_src_10023.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_latest_src_10023.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_latest_src_10023.ds) AS user__ds__year + , EXTRACT(year FROM users_latest_src_10023.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_latest_src_10023.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_latest_src_10023.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_latest_src_10023.ds) AS user__ds__extract_day + , EXTRACT(isodow FROM users_latest_src_10023.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_latest_src_10023.ds) AS user__ds__extract_doy + , users_latest_src_10023.home_state_latest AS user__home_state_latest + , users_latest_src_10023.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_10023 ) subq_4 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0_optimized.sql index aa2ad14d34..afba0439d0 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0_optimized.sql @@ -16,22 +16,22 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_10015 + FROM ***************************.fct_bookings bookings_source_src_10017 ) subq_13 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: -- ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] SELECT - listings_src_10017.active_from AS window_start__day - , listings_src_10017.active_to AS window_end__day - , listings_src_10017.listing_id AS listing - , users_latest_src_10021.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings listings_src_10017 + listings_src_10019.active_from AS window_start__day + , listings_src_10019.active_to AS window_end__day + , listings_src_10019.listing_id AS listing + , users_latest_src_10023.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings listings_src_10019 LEFT OUTER JOIN - ***************************.dim_users_latest users_latest_src_10021 + ***************************.dim_users_latest users_latest_src_10023 ON - listings_src_10017.user_id = users_latest_src_10021.user_id + listings_src_10019.user_id = users_latest_src_10023.user_id ) subq_18 ON ( diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0.sql index 34675e44cc..663505fb02 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0.sql @@ -132,87 +132,87 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_10015.booking_value - , bookings_source_src_10015.guest_id AS bookers - , bookings_source_src_10015.booking_value AS average_booking_value - , bookings_source_src_10015.booking_value AS booking_payments - , bookings_source_src_10015.is_instant - , DATE_TRUNC('day', bookings_source_src_10015.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_10015.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_10015.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_10015.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_10015.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_10015.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_10015.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_10015.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_10015.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS paid_at__extract_doy - , bookings_source_src_10015.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_10015.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_10015.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_10015.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_10015.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_10015.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_10015.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_10015.listing_id AS listing - , bookings_source_src_10015.guest_id AS guest - , bookings_source_src_10015.host_id AS host - , bookings_source_src_10015.guest_id AS user - , bookings_source_src_10015.listing_id AS booking__listing - , bookings_source_src_10015.guest_id AS booking__guest - , bookings_source_src_10015.host_id AS booking__host - , bookings_source_src_10015.guest_id AS booking__user - FROM ***************************.fct_bookings bookings_source_src_10015 + , bookings_source_src_10017.booking_value + , bookings_source_src_10017.guest_id AS bookers + , bookings_source_src_10017.booking_value AS average_booking_value + , bookings_source_src_10017.booking_value AS booking_payments + , bookings_source_src_10017.is_instant + , DATE_TRUNC('day', bookings_source_src_10017.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_10017.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_10017.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_10017.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_10017.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_10017.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_10017.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_10017.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_10017.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_10017.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_10017.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_10017.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.paid_at) AS paid_at__extract_doy + , bookings_source_src_10017.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_10017.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_10017.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_10017.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_10017.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_10017.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_10017.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_10017.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_10017.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_10017.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_10017.listing_id AS listing + , bookings_source_src_10017.guest_id AS guest + , bookings_source_src_10017.host_id AS host + , bookings_source_src_10017.guest_id AS user + , bookings_source_src_10017.listing_id AS booking__listing + , bookings_source_src_10017.guest_id AS booking__guest + , bookings_source_src_10017.host_id AS booking__host + , bookings_source_src_10017.guest_id AS booking__user + FROM ***************************.fct_bookings bookings_source_src_10017 ) subq_0 ) subq_1 ) subq_2 @@ -259,10 +259,10 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'lux_listing_mapping' SELECT - lux_listing_mapping_src_10018.listing_id AS listing - , lux_listing_mapping_src_10018.lux_listing_id AS lux_listing - , lux_listing_mapping_src_10018.lux_listing_id AS listing__lux_listing - FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_10018 + lux_listing_mapping_src_10020.listing_id AS listing + , lux_listing_mapping_src_10020.lux_listing_id AS lux_listing + , lux_listing_mapping_src_10020.lux_listing_id AS listing__lux_listing + FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_10020 ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: @@ -364,54 +364,54 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'lux_listings' SELECT - lux_listings_src_10019.valid_from AS window_start__day - , DATE_TRUNC('week', lux_listings_src_10019.valid_from) AS window_start__week - , DATE_TRUNC('month', lux_listings_src_10019.valid_from) AS window_start__month - , DATE_TRUNC('quarter', lux_listings_src_10019.valid_from) AS window_start__quarter - , DATE_TRUNC('year', lux_listings_src_10019.valid_from) AS window_start__year - , EXTRACT(year FROM lux_listings_src_10019.valid_from) AS window_start__extract_year - , EXTRACT(quarter FROM lux_listings_src_10019.valid_from) AS window_start__extract_quarter - , EXTRACT(month FROM lux_listings_src_10019.valid_from) AS window_start__extract_month - , EXTRACT(day FROM lux_listings_src_10019.valid_from) AS window_start__extract_day - , EXTRACT(isodow FROM lux_listings_src_10019.valid_from) AS window_start__extract_dow - , EXTRACT(doy FROM lux_listings_src_10019.valid_from) AS window_start__extract_doy - , lux_listings_src_10019.valid_to AS window_end__day - , DATE_TRUNC('week', lux_listings_src_10019.valid_to) AS window_end__week - , DATE_TRUNC('month', lux_listings_src_10019.valid_to) AS window_end__month - , DATE_TRUNC('quarter', lux_listings_src_10019.valid_to) AS window_end__quarter - , DATE_TRUNC('year', lux_listings_src_10019.valid_to) AS window_end__year - , EXTRACT(year FROM lux_listings_src_10019.valid_to) AS window_end__extract_year - , EXTRACT(quarter FROM lux_listings_src_10019.valid_to) AS window_end__extract_quarter - , EXTRACT(month FROM lux_listings_src_10019.valid_to) AS window_end__extract_month - , EXTRACT(day FROM lux_listings_src_10019.valid_to) AS window_end__extract_day - , EXTRACT(isodow FROM lux_listings_src_10019.valid_to) AS window_end__extract_dow - , EXTRACT(doy FROM lux_listings_src_10019.valid_to) AS window_end__extract_doy - , lux_listings_src_10019.is_confirmed_lux - , lux_listings_src_10019.valid_from AS lux_listing__window_start__day - , DATE_TRUNC('week', lux_listings_src_10019.valid_from) AS lux_listing__window_start__week - , DATE_TRUNC('month', lux_listings_src_10019.valid_from) AS lux_listing__window_start__month - , DATE_TRUNC('quarter', lux_listings_src_10019.valid_from) AS lux_listing__window_start__quarter - , DATE_TRUNC('year', lux_listings_src_10019.valid_from) AS lux_listing__window_start__year - , EXTRACT(year FROM lux_listings_src_10019.valid_from) AS lux_listing__window_start__extract_year - , EXTRACT(quarter FROM lux_listings_src_10019.valid_from) AS lux_listing__window_start__extract_quarter - , EXTRACT(month FROM lux_listings_src_10019.valid_from) AS lux_listing__window_start__extract_month - , EXTRACT(day FROM lux_listings_src_10019.valid_from) AS lux_listing__window_start__extract_day - , EXTRACT(isodow FROM lux_listings_src_10019.valid_from) AS lux_listing__window_start__extract_dow - , EXTRACT(doy FROM lux_listings_src_10019.valid_from) AS lux_listing__window_start__extract_doy - , lux_listings_src_10019.valid_to AS lux_listing__window_end__day - , DATE_TRUNC('week', lux_listings_src_10019.valid_to) AS lux_listing__window_end__week - , DATE_TRUNC('month', lux_listings_src_10019.valid_to) AS lux_listing__window_end__month - , DATE_TRUNC('quarter', lux_listings_src_10019.valid_to) AS lux_listing__window_end__quarter - , DATE_TRUNC('year', lux_listings_src_10019.valid_to) AS lux_listing__window_end__year - , EXTRACT(year FROM lux_listings_src_10019.valid_to) AS lux_listing__window_end__extract_year - , EXTRACT(quarter FROM lux_listings_src_10019.valid_to) AS lux_listing__window_end__extract_quarter - , EXTRACT(month FROM lux_listings_src_10019.valid_to) AS lux_listing__window_end__extract_month - , EXTRACT(day FROM lux_listings_src_10019.valid_to) AS lux_listing__window_end__extract_day - , EXTRACT(isodow FROM lux_listings_src_10019.valid_to) AS lux_listing__window_end__extract_dow - , EXTRACT(doy FROM lux_listings_src_10019.valid_to) AS lux_listing__window_end__extract_doy - , lux_listings_src_10019.is_confirmed_lux AS lux_listing__is_confirmed_lux - , lux_listings_src_10019.lux_listing_id AS lux_listing - FROM ***************************.dim_lux_listings lux_listings_src_10019 + lux_listings_src_10021.valid_from AS window_start__day + , DATE_TRUNC('week', lux_listings_src_10021.valid_from) AS window_start__week + , DATE_TRUNC('month', lux_listings_src_10021.valid_from) AS window_start__month + , DATE_TRUNC('quarter', lux_listings_src_10021.valid_from) AS window_start__quarter + , DATE_TRUNC('year', lux_listings_src_10021.valid_from) AS window_start__year + , EXTRACT(year FROM lux_listings_src_10021.valid_from) AS window_start__extract_year + , EXTRACT(quarter FROM lux_listings_src_10021.valid_from) AS window_start__extract_quarter + , EXTRACT(month FROM lux_listings_src_10021.valid_from) AS window_start__extract_month + , EXTRACT(day FROM lux_listings_src_10021.valid_from) AS window_start__extract_day + , EXTRACT(isodow FROM lux_listings_src_10021.valid_from) AS window_start__extract_dow + , EXTRACT(doy FROM lux_listings_src_10021.valid_from) AS window_start__extract_doy + , lux_listings_src_10021.valid_to AS window_end__day + , DATE_TRUNC('week', lux_listings_src_10021.valid_to) AS window_end__week + , DATE_TRUNC('month', lux_listings_src_10021.valid_to) AS window_end__month + , DATE_TRUNC('quarter', lux_listings_src_10021.valid_to) AS window_end__quarter + , DATE_TRUNC('year', lux_listings_src_10021.valid_to) AS window_end__year + , EXTRACT(year FROM lux_listings_src_10021.valid_to) AS window_end__extract_year + , EXTRACT(quarter FROM lux_listings_src_10021.valid_to) AS window_end__extract_quarter + , EXTRACT(month FROM lux_listings_src_10021.valid_to) AS window_end__extract_month + , EXTRACT(day FROM lux_listings_src_10021.valid_to) AS window_end__extract_day + , EXTRACT(isodow FROM lux_listings_src_10021.valid_to) AS window_end__extract_dow + , EXTRACT(doy FROM lux_listings_src_10021.valid_to) AS window_end__extract_doy + , lux_listings_src_10021.is_confirmed_lux + , lux_listings_src_10021.valid_from AS lux_listing__window_start__day + , DATE_TRUNC('week', lux_listings_src_10021.valid_from) AS lux_listing__window_start__week + , DATE_TRUNC('month', lux_listings_src_10021.valid_from) AS lux_listing__window_start__month + , DATE_TRUNC('quarter', lux_listings_src_10021.valid_from) AS lux_listing__window_start__quarter + , DATE_TRUNC('year', lux_listings_src_10021.valid_from) AS lux_listing__window_start__year + , EXTRACT(year FROM lux_listings_src_10021.valid_from) AS lux_listing__window_start__extract_year + , EXTRACT(quarter FROM lux_listings_src_10021.valid_from) AS lux_listing__window_start__extract_quarter + , EXTRACT(month FROM lux_listings_src_10021.valid_from) AS lux_listing__window_start__extract_month + , EXTRACT(day FROM lux_listings_src_10021.valid_from) AS lux_listing__window_start__extract_day + , EXTRACT(isodow FROM lux_listings_src_10021.valid_from) AS lux_listing__window_start__extract_dow + , EXTRACT(doy FROM lux_listings_src_10021.valid_from) AS lux_listing__window_start__extract_doy + , lux_listings_src_10021.valid_to AS lux_listing__window_end__day + , DATE_TRUNC('week', lux_listings_src_10021.valid_to) AS lux_listing__window_end__week + , DATE_TRUNC('month', lux_listings_src_10021.valid_to) AS lux_listing__window_end__month + , DATE_TRUNC('quarter', lux_listings_src_10021.valid_to) AS lux_listing__window_end__quarter + , DATE_TRUNC('year', lux_listings_src_10021.valid_to) AS lux_listing__window_end__year + , EXTRACT(year FROM lux_listings_src_10021.valid_to) AS lux_listing__window_end__extract_year + , EXTRACT(quarter FROM lux_listings_src_10021.valid_to) AS lux_listing__window_end__extract_quarter + , EXTRACT(month FROM lux_listings_src_10021.valid_to) AS lux_listing__window_end__extract_month + , EXTRACT(day FROM lux_listings_src_10021.valid_to) AS lux_listing__window_end__extract_day + , EXTRACT(isodow FROM lux_listings_src_10021.valid_to) AS lux_listing__window_end__extract_dow + , EXTRACT(doy FROM lux_listings_src_10021.valid_to) AS lux_listing__window_end__extract_doy + , lux_listings_src_10021.is_confirmed_lux AS lux_listing__is_confirmed_lux + , lux_listings_src_10021.lux_listing_id AS lux_listing + FROM ***************************.dim_lux_listings lux_listings_src_10021 ) subq_4 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0_optimized.sql index add7e259ab..16470814e6 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0_optimized.sql @@ -16,7 +16,7 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_10015 + FROM ***************************.fct_bookings bookings_source_src_10017 ) subq_13 LEFT OUTER JOIN ( -- Join Standard Outputs @@ -26,15 +26,15 @@ LEFT OUTER JOIN ( -- 'lux_listing__window_end__day', -- 'listing'] SELECT - lux_listings_src_10019.valid_from AS lux_listing__window_start__day - , lux_listings_src_10019.valid_to AS lux_listing__window_end__day - , lux_listing_mapping_src_10018.listing_id AS listing - , lux_listings_src_10019.is_confirmed_lux AS lux_listing__is_confirmed_lux - FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_10018 + lux_listings_src_10021.valid_from AS lux_listing__window_start__day + , lux_listings_src_10021.valid_to AS lux_listing__window_end__day + , lux_listing_mapping_src_10020.listing_id AS listing + , lux_listings_src_10021.is_confirmed_lux AS lux_listing__is_confirmed_lux + FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_10020 LEFT OUTER JOIN - ***************************.dim_lux_listings lux_listings_src_10019 + ***************************.dim_lux_listings lux_listings_src_10021 ON - lux_listing_mapping_src_10018.lux_listing_id = lux_listings_src_10019.lux_listing_id + lux_listing_mapping_src_10020.lux_listing_id = lux_listings_src_10021.lux_listing_id ) subq_18 ON ( diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multihop_node__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multihop_node__plan0.sql index 66555fd231..317c69a37f 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multihop_node__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multihop_node__plan0.sql @@ -93,55 +93,55 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'account_month_txns' SELECT - account_month_txns_src_10010.txn_count - , DATE_TRUNC('day', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', account_month_txns_src_10010.ds) AS ds__day - , DATE_TRUNC('week', account_month_txns_src_10010.ds) AS ds__week - , DATE_TRUNC('month', account_month_txns_src_10010.ds) AS ds__month - , DATE_TRUNC('quarter', account_month_txns_src_10010.ds) AS ds__quarter - , DATE_TRUNC('year', account_month_txns_src_10010.ds) AS ds__year - , EXTRACT(year FROM account_month_txns_src_10010.ds) AS ds__extract_year - , EXTRACT(quarter FROM account_month_txns_src_10010.ds) AS ds__extract_quarter - , EXTRACT(month FROM account_month_txns_src_10010.ds) AS ds__extract_month - , EXTRACT(day FROM account_month_txns_src_10010.ds) AS ds__extract_day - , EXTRACT(isodow FROM account_month_txns_src_10010.ds) AS ds__extract_dow - , EXTRACT(doy FROM account_month_txns_src_10010.ds) AS ds__extract_doy - , account_month_txns_src_10010.account_month - , DATE_TRUNC('day', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__day - , DATE_TRUNC('week', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__week - , DATE_TRUNC('month', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__month - , DATE_TRUNC('quarter', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__quarter - , DATE_TRUNC('year', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__year - , EXTRACT(year FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_month - , EXTRACT(day FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_day - , EXTRACT(isodow FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , DATE_TRUNC('day', account_month_txns_src_10010.ds) AS account_id__ds__day - , DATE_TRUNC('week', account_month_txns_src_10010.ds) AS account_id__ds__week - , DATE_TRUNC('month', account_month_txns_src_10010.ds) AS account_id__ds__month - , DATE_TRUNC('quarter', account_month_txns_src_10010.ds) AS account_id__ds__quarter - , DATE_TRUNC('year', account_month_txns_src_10010.ds) AS account_id__ds__year - , EXTRACT(year FROM account_month_txns_src_10010.ds) AS account_id__ds__extract_year - , EXTRACT(quarter FROM account_month_txns_src_10010.ds) AS account_id__ds__extract_quarter - , EXTRACT(month FROM account_month_txns_src_10010.ds) AS account_id__ds__extract_month - , EXTRACT(day FROM account_month_txns_src_10010.ds) AS account_id__ds__extract_day - , EXTRACT(isodow FROM account_month_txns_src_10010.ds) AS account_id__ds__extract_dow - , EXTRACT(doy FROM account_month_txns_src_10010.ds) AS account_id__ds__extract_doy - , account_month_txns_src_10010.account_month AS account_id__account_month - , account_month_txns_src_10010.account_id - FROM ***************************.account_month_txns account_month_txns_src_10010 + account_month_txns_src_10012.txn_count + , DATE_TRUNC('day', account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', account_month_txns_src_10012.ds) AS ds__day + , DATE_TRUNC('week', account_month_txns_src_10012.ds) AS ds__week + , DATE_TRUNC('month', account_month_txns_src_10012.ds) AS ds__month + , DATE_TRUNC('quarter', account_month_txns_src_10012.ds) AS ds__quarter + , DATE_TRUNC('year', account_month_txns_src_10012.ds) AS ds__year + , EXTRACT(year FROM account_month_txns_src_10012.ds) AS ds__extract_year + , EXTRACT(quarter FROM account_month_txns_src_10012.ds) AS ds__extract_quarter + , EXTRACT(month FROM account_month_txns_src_10012.ds) AS ds__extract_month + , EXTRACT(day FROM account_month_txns_src_10012.ds) AS ds__extract_day + , EXTRACT(isodow FROM account_month_txns_src_10012.ds) AS ds__extract_dow + , EXTRACT(doy FROM account_month_txns_src_10012.ds) AS ds__extract_doy + , account_month_txns_src_10012.account_month + , DATE_TRUNC('day', account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__day + , DATE_TRUNC('week', account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__week + , DATE_TRUNC('month', account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__month + , DATE_TRUNC('quarter', account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__quarter + , DATE_TRUNC('year', account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__year + , EXTRACT(year FROM account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__extract_month + , EXTRACT(day FROM account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__extract_day + , EXTRACT(isodow FROM account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__extract_doy + , DATE_TRUNC('day', account_month_txns_src_10012.ds) AS account_id__ds__day + , DATE_TRUNC('week', account_month_txns_src_10012.ds) AS account_id__ds__week + , DATE_TRUNC('month', account_month_txns_src_10012.ds) AS account_id__ds__month + , DATE_TRUNC('quarter', account_month_txns_src_10012.ds) AS account_id__ds__quarter + , DATE_TRUNC('year', account_month_txns_src_10012.ds) AS account_id__ds__year + , EXTRACT(year FROM account_month_txns_src_10012.ds) AS account_id__ds__extract_year + , EXTRACT(quarter FROM account_month_txns_src_10012.ds) AS account_id__ds__extract_quarter + , EXTRACT(month FROM account_month_txns_src_10012.ds) AS account_id__ds__extract_month + , EXTRACT(day FROM account_month_txns_src_10012.ds) AS account_id__ds__extract_day + , EXTRACT(isodow FROM account_month_txns_src_10012.ds) AS account_id__ds__extract_dow + , EXTRACT(doy FROM account_month_txns_src_10012.ds) AS account_id__ds__extract_doy + , account_month_txns_src_10012.account_month AS account_id__account_month + , account_month_txns_src_10012.account_id + FROM ***************************.account_month_txns account_month_txns_src_10012 ) subq_0 ) subq_1 ) subq_2 @@ -212,48 +212,48 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT - bridge_table_src_10011.extra_dim - , DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_doy - , bridge_table_src_10011.extra_dim AS account_id__extra_dim - , DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__day - , DATE_TRUNC('week', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__week - , DATE_TRUNC('month', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__month - , DATE_TRUNC('quarter', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__quarter - , DATE_TRUNC('year', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_day - , EXTRACT(isodow FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , bridge_table_src_10011.extra_dim AS bridge_account__extra_dim - , DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__day - , DATE_TRUNC('week', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__week - , DATE_TRUNC('month', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__month - , DATE_TRUNC('quarter', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__quarter - , DATE_TRUNC('year', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__extract_day - , EXTRACT(isodow FROM bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__extract_dow - , EXTRACT(doy FROM bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__extract_doy - , bridge_table_src_10011.account_id - , bridge_table_src_10011.customer_id - , bridge_table_src_10011.customer_id AS account_id__customer_id - , bridge_table_src_10011.account_id AS bridge_account__account_id - , bridge_table_src_10011.customer_id AS bridge_account__customer_id - FROM ***************************.bridge_table bridge_table_src_10011 + bridge_table_src_10013.extra_dim + , DATE_TRUNC('day', bridge_table_src_10013.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bridge_table_src_10013.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bridge_table_src_10013.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bridge_table_src_10013.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bridge_table_src_10013.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_10013.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_10013.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_10013.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_10013.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bridge_table_src_10013.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bridge_table_src_10013.ds_partitioned) AS ds_partitioned__extract_doy + , bridge_table_src_10013.extra_dim AS account_id__extra_dim + , DATE_TRUNC('day', bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__day + , DATE_TRUNC('week', bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__week + , DATE_TRUNC('month', bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__month + , DATE_TRUNC('quarter', bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__quarter + , DATE_TRUNC('year', bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__extract_day + , EXTRACT(isodow FROM bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__extract_doy + , bridge_table_src_10013.extra_dim AS bridge_account__extra_dim + , DATE_TRUNC('day', bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__day + , DATE_TRUNC('week', bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__week + , DATE_TRUNC('month', bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__month + , DATE_TRUNC('quarter', bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__quarter + , DATE_TRUNC('year', bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__extract_day + , EXTRACT(isodow FROM bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__extract_dow + , EXTRACT(doy FROM bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__extract_doy + , bridge_table_src_10013.account_id + , bridge_table_src_10013.customer_id + , bridge_table_src_10013.customer_id AS account_id__customer_id + , bridge_table_src_10013.account_id AS bridge_account__account_id + , bridge_table_src_10013.customer_id AS bridge_account__customer_id + FROM ***************************.bridge_table bridge_table_src_10013 ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: @@ -315,34 +315,34 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'customer_table' SELECT - customer_table_src_10013.customer_name - , customer_table_src_10013.customer_atomic_weight - , DATE_TRUNC('day', customer_table_src_10013.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', customer_table_src_10013.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', customer_table_src_10013.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', customer_table_src_10013.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', customer_table_src_10013.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_doy - , customer_table_src_10013.customer_name AS customer_id__customer_name - , customer_table_src_10013.customer_atomic_weight AS customer_id__customer_atomic_weight - , DATE_TRUNC('day', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__day - , DATE_TRUNC('week', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__week - , DATE_TRUNC('month', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__month - , DATE_TRUNC('quarter', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__quarter - , DATE_TRUNC('year', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__year - , EXTRACT(year FROM customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__extract_month - , EXTRACT(day FROM customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__extract_day - , EXTRACT(isodow FROM customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__extract_doy - , customer_table_src_10013.customer_id - FROM ***************************.customer_table customer_table_src_10013 + customer_table_src_10015.customer_name + , customer_table_src_10015.customer_atomic_weight + , DATE_TRUNC('day', customer_table_src_10015.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', customer_table_src_10015.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', customer_table_src_10015.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', customer_table_src_10015.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', customer_table_src_10015.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM customer_table_src_10015.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM customer_table_src_10015.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM customer_table_src_10015.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM customer_table_src_10015.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM customer_table_src_10015.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM customer_table_src_10015.ds_partitioned) AS ds_partitioned__extract_doy + , customer_table_src_10015.customer_name AS customer_id__customer_name + , customer_table_src_10015.customer_atomic_weight AS customer_id__customer_atomic_weight + , DATE_TRUNC('day', customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__day + , DATE_TRUNC('week', customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__week + , DATE_TRUNC('month', customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__month + , DATE_TRUNC('quarter', customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__quarter + , DATE_TRUNC('year', customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__year + , EXTRACT(year FROM customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__extract_month + , EXTRACT(day FROM customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__extract_day + , EXTRACT(isodow FROM customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__extract_doy + , customer_table_src_10015.customer_id + FROM ***************************.customer_table customer_table_src_10015 ) subq_4 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multihop_node__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multihop_node__plan0_optimized.sql index 8a42052413..65d688b745 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multihop_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multihop_node__plan0_optimized.sql @@ -5,31 +5,31 @@ -- Compute Metrics via Expressions SELECT subq_18.customer_id__customer_name AS account_id__customer_id__customer_name - , SUM(account_month_txns_src_10010.txn_count) AS txn_count -FROM ***************************.account_month_txns account_month_txns_src_10010 + , SUM(account_month_txns_src_10012.txn_count) AS txn_count +FROM ***************************.account_month_txns account_month_txns_src_10012 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: -- ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__day - , bridge_table_src_10011.account_id AS account_id - , customer_table_src_10013.customer_name AS customer_id__customer_name - FROM ***************************.bridge_table bridge_table_src_10011 + DATE_TRUNC('day', bridge_table_src_10013.ds_partitioned) AS ds_partitioned__day + , bridge_table_src_10013.account_id AS account_id + , customer_table_src_10015.customer_name AS customer_id__customer_name + FROM ***************************.bridge_table bridge_table_src_10013 LEFT OUTER JOIN - ***************************.customer_table customer_table_src_10013 + ***************************.customer_table customer_table_src_10015 ON ( - bridge_table_src_10011.customer_id = customer_table_src_10013.customer_id + bridge_table_src_10013.customer_id = customer_table_src_10015.customer_id ) AND ( - DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) = DATE_TRUNC('day', customer_table_src_10013.ds_partitioned) + DATE_TRUNC('day', bridge_table_src_10013.ds_partitioned) = DATE_TRUNC('day', customer_table_src_10015.ds_partitioned) ) ) subq_18 ON ( - account_month_txns_src_10010.account_id = subq_18.account_id + account_month_txns_src_10012.account_id = subq_18.account_id ) AND ( - DATE_TRUNC('day', account_month_txns_src_10010.ds_partitioned) = subq_18.ds_partitioned__day + DATE_TRUNC('day', account_month_txns_src_10012.ds_partitioned) = subq_18.ds_partitioned__day ) GROUP BY subq_18.customer_id__customer_name diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multiple_metrics_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multiple_metrics_no_dimensions__plan0.sql index 7ad1c04247..6552f995c8 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multiple_metrics_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multiple_metrics_no_dimensions__plan0.sql @@ -473,62 +473,62 @@ CROSS JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_6 ) subq_7 WHERE subq_7.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multiple_metrics_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multiple_metrics_no_dimensions__plan0_optimized.sql index 631546edf7..5fdefdb6a7 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multiple_metrics_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multiple_metrics_no_dimensions__plan0_optimized.sql @@ -25,6 +25,6 @@ CROSS JOIN ( -- Compute Metrics via Expressions SELECT SUM(1) AS listings - FROM ***************************.dim_listings_latest listings_latest_src_10004 + FROM ***************************.dim_listings_latest listings_latest_src_10005 WHERE DATE_TRUNC('day', created_at) BETWEEN '2020-01-01' AND '2020-01-01' ) subq_23 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_partitioned_join__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_partitioned_join__plan0.sql index 1673729a9a..166092a420 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_partitioned_join__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_partitioned_join__plan0.sql @@ -96,56 +96,56 @@ FROM ( -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , DATE_TRUNC('day', id_verifications_src_10003.ds) AS ds__day - , DATE_TRUNC('week', id_verifications_src_10003.ds) AS ds__week - , DATE_TRUNC('month', id_verifications_src_10003.ds) AS ds__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS ds__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds) AS ds__year - , EXTRACT(year FROM id_verifications_src_10003.ds) AS ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds) AS ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds) AS ds__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds) AS ds__extract_day - , EXTRACT(isodow FROM id_verifications_src_10003.ds) AS ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds) AS ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_doy - , id_verifications_src_10003.verification_type - , DATE_TRUNC('day', id_verifications_src_10003.ds) AS verification__ds__day - , DATE_TRUNC('week', id_verifications_src_10003.ds) AS verification__ds__week - , DATE_TRUNC('month', id_verifications_src_10003.ds) AS verification__ds__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS verification__ds__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds) AS verification__ds__year - , EXTRACT(year FROM id_verifications_src_10003.ds) AS verification__ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds) AS verification__ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds) AS verification__ds__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds) AS verification__ds__extract_day - , EXTRACT(isodow FROM id_verifications_src_10003.ds) AS verification__ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds) AS verification__ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_day - , EXTRACT(isodow FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_doy - , id_verifications_src_10003.verification_type AS verification__verification_type - , id_verifications_src_10003.verification_id AS verification - , id_verifications_src_10003.user_id AS user - , id_verifications_src_10003.user_id AS verification__user - FROM ***************************.fct_id_verifications id_verifications_src_10003 + , DATE_TRUNC('day', id_verifications_src_10004.ds) AS ds__day + , DATE_TRUNC('week', id_verifications_src_10004.ds) AS ds__week + , DATE_TRUNC('month', id_verifications_src_10004.ds) AS ds__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds) AS ds__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds) AS ds__year + , EXTRACT(year FROM id_verifications_src_10004.ds) AS ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds) AS ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds) AS ds__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds) AS ds__extract_day + , EXTRACT(isodow FROM id_verifications_src_10004.ds) AS ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds) AS ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_doy + , id_verifications_src_10004.verification_type + , DATE_TRUNC('day', id_verifications_src_10004.ds) AS verification__ds__day + , DATE_TRUNC('week', id_verifications_src_10004.ds) AS verification__ds__week + , DATE_TRUNC('month', id_verifications_src_10004.ds) AS verification__ds__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds) AS verification__ds__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds) AS verification__ds__year + , EXTRACT(year FROM id_verifications_src_10004.ds) AS verification__ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds) AS verification__ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds) AS verification__ds__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds) AS verification__ds__extract_day + , EXTRACT(isodow FROM id_verifications_src_10004.ds) AS verification__ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds) AS verification__ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_day + , EXTRACT(isodow FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_doy + , id_verifications_src_10004.verification_type AS verification__verification_type + , id_verifications_src_10004.verification_id AS verification + , id_verifications_src_10004.user_id AS user + , id_verifications_src_10004.user_id AS verification__user + FROM ***************************.fct_id_verifications id_verifications_src_10004 ) subq_0 ) subq_1 ) subq_2 @@ -159,76 +159,76 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT - DATE_TRUNC('day', users_ds_source_src_10007.ds) AS ds__day - , DATE_TRUNC('week', users_ds_source_src_10007.ds) AS ds__week - , DATE_TRUNC('month', users_ds_source_src_10007.ds) AS ds__month - , DATE_TRUNC('quarter', users_ds_source_src_10007.ds) AS ds__quarter - , DATE_TRUNC('year', users_ds_source_src_10007.ds) AS ds__year - , EXTRACT(year FROM users_ds_source_src_10007.ds) AS ds__extract_year - , EXTRACT(quarter FROM users_ds_source_src_10007.ds) AS ds__extract_quarter - , EXTRACT(month FROM users_ds_source_src_10007.ds) AS ds__extract_month - , EXTRACT(day FROM users_ds_source_src_10007.ds) AS ds__extract_day - , EXTRACT(isodow FROM users_ds_source_src_10007.ds) AS ds__extract_dow - , EXTRACT(doy FROM users_ds_source_src_10007.ds) AS ds__extract_doy - , DATE_TRUNC('day', users_ds_source_src_10007.created_at) AS created_at__day - , DATE_TRUNC('week', users_ds_source_src_10007.created_at) AS created_at__week - , DATE_TRUNC('month', users_ds_source_src_10007.created_at) AS created_at__month - , DATE_TRUNC('quarter', users_ds_source_src_10007.created_at) AS created_at__quarter - , DATE_TRUNC('year', users_ds_source_src_10007.created_at) AS created_at__year - , EXTRACT(year FROM users_ds_source_src_10007.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_10007.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_10007.created_at) AS created_at__extract_month - , EXTRACT(day FROM users_ds_source_src_10007.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM users_ds_source_src_10007.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_10007.created_at) AS created_at__extract_doy - , DATE_TRUNC('day', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_doy - , users_ds_source_src_10007.home_state - , DATE_TRUNC('day', users_ds_source_src_10007.ds) AS user__ds__day - , DATE_TRUNC('week', users_ds_source_src_10007.ds) AS user__ds__week - , DATE_TRUNC('month', users_ds_source_src_10007.ds) AS user__ds__month - , DATE_TRUNC('quarter', users_ds_source_src_10007.ds) AS user__ds__quarter - , DATE_TRUNC('year', users_ds_source_src_10007.ds) AS user__ds__year - , EXTRACT(year FROM users_ds_source_src_10007.ds) AS user__ds__extract_year - , EXTRACT(quarter FROM users_ds_source_src_10007.ds) AS user__ds__extract_quarter - , EXTRACT(month FROM users_ds_source_src_10007.ds) AS user__ds__extract_month - , EXTRACT(day FROM users_ds_source_src_10007.ds) AS user__ds__extract_day - , EXTRACT(isodow FROM users_ds_source_src_10007.ds) AS user__ds__extract_dow - , EXTRACT(doy FROM users_ds_source_src_10007.ds) AS user__ds__extract_doy - , DATE_TRUNC('day', users_ds_source_src_10007.created_at) AS user__created_at__day - , DATE_TRUNC('week', users_ds_source_src_10007.created_at) AS user__created_at__week - , DATE_TRUNC('month', users_ds_source_src_10007.created_at) AS user__created_at__month - , DATE_TRUNC('quarter', users_ds_source_src_10007.created_at) AS user__created_at__quarter - , DATE_TRUNC('year', users_ds_source_src_10007.created_at) AS user__created_at__year - , EXTRACT(year FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_month - , EXTRACT(day FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_day - , EXTRACT(isodow FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_doy - , DATE_TRUNC('day', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__day - , DATE_TRUNC('week', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__week - , DATE_TRUNC('month', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__month - , DATE_TRUNC('quarter', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__quarter - , DATE_TRUNC('year', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__year - , EXTRACT(year FROM users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__extract_year - , EXTRACT(quarter FROM users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__extract_quarter - , EXTRACT(month FROM users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__extract_month - , EXTRACT(day FROM users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__extract_day - , EXTRACT(isodow FROM users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__extract_dow - , EXTRACT(doy FROM users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__extract_doy - , users_ds_source_src_10007.home_state AS user__home_state - , users_ds_source_src_10007.user_id AS user - FROM ***************************.dim_users users_ds_source_src_10007 + DATE_TRUNC('day', users_ds_source_src_10008.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_10008.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_10008.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_10008.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_10008.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_10008.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_10008.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_10008.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_10008.ds) AS ds__extract_day + , EXTRACT(isodow FROM users_ds_source_src_10008.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_10008.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_10008.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_10008.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_10008.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_10008.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_10008.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_10008.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_10008.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_10008.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_10008.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_10008.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_10008.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_10008.home_state + , DATE_TRUNC('day', users_ds_source_src_10008.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_10008.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_10008.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_10008.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_10008.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_10008.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_10008.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_10008.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_10008.ds) AS user__ds__extract_day + , EXTRACT(isodow FROM users_ds_source_src_10008.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_10008.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_10008.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_10008.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_10008.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_10008.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_10008.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_10008.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_10008.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_10008.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_10008.created_at) AS user__created_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_10008.created_at) AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_10008.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__extract_day + , EXTRACT(isodow FROM users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_10008.home_state AS user__home_state + , users_ds_source_src_10008.user_id AS user + FROM ***************************.dim_users users_ds_source_src_10008 ) subq_3 ) subq_4 ON diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_partitioned_join__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_partitioned_join__plan0_optimized.sql index c15982d861..b52d743037 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_partitioned_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_partitioned_join__plan0_optimized.sql @@ -4,7 +4,7 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - users_ds_source_src_10007.home_state AS user__home_state + users_ds_source_src_10008.home_state AS user__home_state , SUM(subq_10.identity_verifications) AS identity_verifications FROM ( -- Read Elements From Semantic Model 'id_verifications' @@ -15,15 +15,15 @@ FROM ( DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , user_id AS user , 1 AS identity_verifications - FROM ***************************.fct_id_verifications id_verifications_src_10003 + FROM ***************************.fct_id_verifications id_verifications_src_10004 ) subq_10 LEFT OUTER JOIN - ***************************.dim_users users_ds_source_src_10007 + ***************************.dim_users users_ds_source_src_10008 ON ( - subq_10.user = users_ds_source_src_10007.user_id + subq_10.user = users_ds_source_src_10008.user_id ) AND ( - subq_10.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_10007.ds_partitioned) + subq_10.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_10008.ds_partitioned) ) GROUP BY - users_ds_source_src_10007.home_state + users_ds_source_src_10008.home_state diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_distinct_values__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_distinct_values__plan0.sql index e2ba51fbd9..38d809df95 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_distinct_values__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_distinct_values__plan0.sql @@ -69,62 +69,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_0 WHERE listing__country_latest = 'us' ) subq_1 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_distinct_values__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_distinct_values__plan0_optimized.sql index ec0d94dac2..53c7bf823f 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_distinct_values__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_distinct_values__plan0_optimized.sql @@ -8,7 +8,7 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT country AS listing__country_latest - FROM ***************************.dim_listings_latest listings_latest_src_10004 + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_3 WHERE listing__country_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_on_join_dim__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_on_join_dim__plan0.sql index 7c96102439..8859373c3d 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_on_join_dim__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_on_join_dim__plan0.sql @@ -316,62 +316,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_3 ) subq_4 ) subq_5 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql index 19b1b78329..d00b32fb24 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql @@ -12,7 +12,7 @@ FROM ( -- ['bookings', 'booking__is_instant', 'listing__country_latest'] SELECT subq_13.booking__is_instant AS booking__is_instant - , listings_latest_src_10004.country AS listing__country_latest + , listings_latest_src_10005.country AS listing__country_latest , subq_13.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -26,9 +26,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_13 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_13.listing = listings_latest_src_10004.listing_id + subq_13.listing = listings_latest_src_10005.listing_id ) subq_18 WHERE listing__country_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_join_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_join_to_scd_dimension__plan0.sql index 7c3d369cac..96088f0b77 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_join_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_join_to_scd_dimension__plan0.sql @@ -142,87 +142,87 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_10015.booking_value - , bookings_source_src_10015.guest_id AS bookers - , bookings_source_src_10015.booking_value AS average_booking_value - , bookings_source_src_10015.booking_value AS booking_payments - , bookings_source_src_10015.is_instant - , DATE_TRUNC('day', bookings_source_src_10015.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_10015.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_10015.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_10015.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_10015.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_10015.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_10015.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_10015.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_10015.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_10015.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_10015.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_10015.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_10015.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS paid_at__extract_doy - , bookings_source_src_10015.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_10015.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_10015.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_10015.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_10015.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_10015.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_10015.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_10015.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_10015.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_10015.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_10015.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_10015.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_10015.listing_id AS listing - , bookings_source_src_10015.guest_id AS guest - , bookings_source_src_10015.host_id AS host - , bookings_source_src_10015.guest_id AS user - , bookings_source_src_10015.listing_id AS booking__listing - , bookings_source_src_10015.guest_id AS booking__guest - , bookings_source_src_10015.host_id AS booking__host - , bookings_source_src_10015.guest_id AS booking__user - FROM ***************************.fct_bookings bookings_source_src_10015 + , bookings_source_src_10017.booking_value + , bookings_source_src_10017.guest_id AS bookers + , bookings_source_src_10017.booking_value AS average_booking_value + , bookings_source_src_10017.booking_value AS booking_payments + , bookings_source_src_10017.is_instant + , DATE_TRUNC('day', bookings_source_src_10017.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_10017.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_10017.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_10017.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_10017.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_10017.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_10017.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_10017.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_10017.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_10017.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_10017.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_10017.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_10017.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_10017.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_10017.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_10017.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_10017.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_10017.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_10017.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.paid_at) AS paid_at__extract_doy + , bookings_source_src_10017.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_10017.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_10017.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_10017.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_10017.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_10017.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_10017.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_10017.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_10017.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_10017.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_10017.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_10017.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_10017.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_10017.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_10017.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_10017.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_10017.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_10017.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_10017.listing_id AS listing + , bookings_source_src_10017.guest_id AS guest + , bookings_source_src_10017.host_id AS host + , bookings_source_src_10017.guest_id AS user + , bookings_source_src_10017.listing_id AS booking__listing + , bookings_source_src_10017.guest_id AS booking__guest + , bookings_source_src_10017.host_id AS booking__host + , bookings_source_src_10017.guest_id AS booking__user + FROM ***************************.fct_bookings bookings_source_src_10017 ) subq_0 ) subq_1 ) subq_2 @@ -237,60 +237,60 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'listings' SELECT - listings_src_10017.active_from AS window_start__day - , DATE_TRUNC('week', listings_src_10017.active_from) AS window_start__week - , DATE_TRUNC('month', listings_src_10017.active_from) AS window_start__month - , DATE_TRUNC('quarter', listings_src_10017.active_from) AS window_start__quarter - , DATE_TRUNC('year', listings_src_10017.active_from) AS window_start__year - , EXTRACT(year FROM listings_src_10017.active_from) AS window_start__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_from) AS window_start__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_from) AS window_start__extract_month - , EXTRACT(day FROM listings_src_10017.active_from) AS window_start__extract_day - , CASE WHEN EXTRACT(dow FROM listings_src_10017.active_from) = 0 THEN EXTRACT(dow FROM listings_src_10017.active_from) + 7 ELSE EXTRACT(dow FROM listings_src_10017.active_from) END AS window_start__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_from) AS window_start__extract_doy - , listings_src_10017.active_to AS window_end__day - , DATE_TRUNC('week', listings_src_10017.active_to) AS window_end__week - , DATE_TRUNC('month', listings_src_10017.active_to) AS window_end__month - , DATE_TRUNC('quarter', listings_src_10017.active_to) AS window_end__quarter - , DATE_TRUNC('year', listings_src_10017.active_to) AS window_end__year - , EXTRACT(year FROM listings_src_10017.active_to) AS window_end__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_to) AS window_end__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_to) AS window_end__extract_month - , EXTRACT(day FROM listings_src_10017.active_to) AS window_end__extract_day - , CASE WHEN EXTRACT(dow FROM listings_src_10017.active_to) = 0 THEN EXTRACT(dow FROM listings_src_10017.active_to) + 7 ELSE EXTRACT(dow FROM listings_src_10017.active_to) END AS window_end__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_to) AS window_end__extract_doy - , listings_src_10017.country - , listings_src_10017.is_lux - , listings_src_10017.capacity - , listings_src_10017.active_from AS listing__window_start__day - , DATE_TRUNC('week', listings_src_10017.active_from) AS listing__window_start__week - , DATE_TRUNC('month', listings_src_10017.active_from) AS listing__window_start__month - , DATE_TRUNC('quarter', listings_src_10017.active_from) AS listing__window_start__quarter - , DATE_TRUNC('year', listings_src_10017.active_from) AS listing__window_start__year - , EXTRACT(year FROM listings_src_10017.active_from) AS listing__window_start__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_from) AS listing__window_start__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_from) AS listing__window_start__extract_month - , EXTRACT(day FROM listings_src_10017.active_from) AS listing__window_start__extract_day - , CASE WHEN EXTRACT(dow FROM listings_src_10017.active_from) = 0 THEN EXTRACT(dow FROM listings_src_10017.active_from) + 7 ELSE EXTRACT(dow FROM listings_src_10017.active_from) END AS listing__window_start__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_from) AS listing__window_start__extract_doy - , listings_src_10017.active_to AS listing__window_end__day - , DATE_TRUNC('week', listings_src_10017.active_to) AS listing__window_end__week - , DATE_TRUNC('month', listings_src_10017.active_to) AS listing__window_end__month - , DATE_TRUNC('quarter', listings_src_10017.active_to) AS listing__window_end__quarter - , DATE_TRUNC('year', listings_src_10017.active_to) AS listing__window_end__year - , EXTRACT(year FROM listings_src_10017.active_to) AS listing__window_end__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_to) AS listing__window_end__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_to) AS listing__window_end__extract_month - , EXTRACT(day FROM listings_src_10017.active_to) AS listing__window_end__extract_day - , CASE WHEN EXTRACT(dow FROM listings_src_10017.active_to) = 0 THEN EXTRACT(dow FROM listings_src_10017.active_to) + 7 ELSE EXTRACT(dow FROM listings_src_10017.active_to) END AS listing__window_end__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_to) AS listing__window_end__extract_doy - , listings_src_10017.country AS listing__country - , listings_src_10017.is_lux AS listing__is_lux - , listings_src_10017.capacity AS listing__capacity - , listings_src_10017.listing_id AS listing - , listings_src_10017.user_id AS user - , listings_src_10017.user_id AS listing__user - FROM ***************************.dim_listings listings_src_10017 + listings_src_10019.active_from AS window_start__day + , DATE_TRUNC('week', listings_src_10019.active_from) AS window_start__week + , DATE_TRUNC('month', listings_src_10019.active_from) AS window_start__month + , DATE_TRUNC('quarter', listings_src_10019.active_from) AS window_start__quarter + , DATE_TRUNC('year', listings_src_10019.active_from) AS window_start__year + , EXTRACT(year FROM listings_src_10019.active_from) AS window_start__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_from) AS window_start__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_from) AS window_start__extract_month + , EXTRACT(day FROM listings_src_10019.active_from) AS window_start__extract_day + , CASE WHEN EXTRACT(dow FROM listings_src_10019.active_from) = 0 THEN EXTRACT(dow FROM listings_src_10019.active_from) + 7 ELSE EXTRACT(dow FROM listings_src_10019.active_from) END AS window_start__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_from) AS window_start__extract_doy + , listings_src_10019.active_to AS window_end__day + , DATE_TRUNC('week', listings_src_10019.active_to) AS window_end__week + , DATE_TRUNC('month', listings_src_10019.active_to) AS window_end__month + , DATE_TRUNC('quarter', listings_src_10019.active_to) AS window_end__quarter + , DATE_TRUNC('year', listings_src_10019.active_to) AS window_end__year + , EXTRACT(year FROM listings_src_10019.active_to) AS window_end__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_to) AS window_end__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_to) AS window_end__extract_month + , EXTRACT(day FROM listings_src_10019.active_to) AS window_end__extract_day + , CASE WHEN EXTRACT(dow FROM listings_src_10019.active_to) = 0 THEN EXTRACT(dow FROM listings_src_10019.active_to) + 7 ELSE EXTRACT(dow FROM listings_src_10019.active_to) END AS window_end__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_to) AS window_end__extract_doy + , listings_src_10019.country + , listings_src_10019.is_lux + , listings_src_10019.capacity + , listings_src_10019.active_from AS listing__window_start__day + , DATE_TRUNC('week', listings_src_10019.active_from) AS listing__window_start__week + , DATE_TRUNC('month', listings_src_10019.active_from) AS listing__window_start__month + , DATE_TRUNC('quarter', listings_src_10019.active_from) AS listing__window_start__quarter + , DATE_TRUNC('year', listings_src_10019.active_from) AS listing__window_start__year + , EXTRACT(year FROM listings_src_10019.active_from) AS listing__window_start__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_from) AS listing__window_start__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_from) AS listing__window_start__extract_month + , EXTRACT(day FROM listings_src_10019.active_from) AS listing__window_start__extract_day + , CASE WHEN EXTRACT(dow FROM listings_src_10019.active_from) = 0 THEN EXTRACT(dow FROM listings_src_10019.active_from) + 7 ELSE EXTRACT(dow FROM listings_src_10019.active_from) END AS listing__window_start__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_from) AS listing__window_start__extract_doy + , listings_src_10019.active_to AS listing__window_end__day + , DATE_TRUNC('week', listings_src_10019.active_to) AS listing__window_end__week + , DATE_TRUNC('month', listings_src_10019.active_to) AS listing__window_end__month + , DATE_TRUNC('quarter', listings_src_10019.active_to) AS listing__window_end__quarter + , DATE_TRUNC('year', listings_src_10019.active_to) AS listing__window_end__year + , EXTRACT(year FROM listings_src_10019.active_to) AS listing__window_end__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_to) AS listing__window_end__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_to) AS listing__window_end__extract_month + , EXTRACT(day FROM listings_src_10019.active_to) AS listing__window_end__extract_day + , CASE WHEN EXTRACT(dow FROM listings_src_10019.active_to) = 0 THEN EXTRACT(dow FROM listings_src_10019.active_to) + 7 ELSE EXTRACT(dow FROM listings_src_10019.active_to) END AS listing__window_end__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_to) AS listing__window_end__extract_doy + , listings_src_10019.country AS listing__country + , listings_src_10019.is_lux AS listing__is_lux + , listings_src_10019.capacity AS listing__capacity + , listings_src_10019.listing_id AS listing + , listings_src_10019.user_id AS user + , listings_src_10019.user_id AS listing__user + FROM ***************************.dim_listings listings_src_10019 ) subq_3 ) subq_4 ON diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_join_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_join_to_scd_dimension__plan0_optimized.sql index db1199fc2e..662445e5ef 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_join_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_join_to_scd_dimension__plan0_optimized.sql @@ -12,7 +12,7 @@ FROM ( -- ['bookings', 'listing__capacity', 'metric_time__day'] SELECT subq_12.metric_time__day AS metric_time__day - , listings_src_10017.capacity AS listing__capacity + , listings_src_10019.capacity AS listing__capacity , subq_12.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -23,21 +23,21 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_10015 + FROM ***************************.fct_bookings bookings_source_src_10017 ) subq_12 LEFT OUTER JOIN - ***************************.dim_listings listings_src_10017 + ***************************.dim_listings listings_src_10019 ON ( - subq_12.listing = listings_src_10017.listing_id + subq_12.listing = listings_src_10019.listing_id ) AND ( ( - subq_12.metric_time__day >= listings_src_10017.active_from + subq_12.metric_time__day >= listings_src_10019.active_from ) AND ( ( - subq_12.metric_time__day < listings_src_10017.active_to + subq_12.metric_time__day < listings_src_10019.active_to ) OR ( - listings_src_10017.active_to IS NULL + listings_src_10019.active_to IS NULL ) ) ) diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_local_dimension_using_local_entity__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_local_dimension_using_local_entity__plan0.sql index 39ce6f58ff..db64c65fd4 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_local_dimension_using_local_entity__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_local_dimension_using_local_entity__plan0.sql @@ -87,62 +87,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_0 ) subq_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_local_dimension_using_local_entity__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_local_dimension_using_local_entity__plan0_optimized.sql index f7932552c3..2c5690447e 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_local_dimension_using_local_entity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_local_dimension_using_local_entity__plan0_optimized.sql @@ -11,7 +11,7 @@ FROM ( SELECT country AS listing__country_latest , 1 AS listings - FROM ***************************.dim_listings_latest listings_latest_src_10004 + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_6 GROUP BY listing__country_latest diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0.sql index 0afe15717f..e502ee282b 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0.sql @@ -328,62 +328,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_3 ) subq_4 ) subq_5 @@ -717,62 +717,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_15 ) subq_16 ) subq_17 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0_optimized.sql index 3c0c641be9..5581a37a67 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0_optimized.sql @@ -24,13 +24,13 @@ FROM ( -- ['average_booking_value', 'listing__is_lux_latest', 'metric_time__day'] SELECT DATE_TRUNC('day', bookings_source_src_10001.ds) AS metric_time__day - , listings_latest_src_10004.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest , bookings_source_src_10001.booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_10001 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - bookings_source_src_10001.listing_id = listings_latest_src_10004.listing_id + bookings_source_src_10001.listing_id = listings_latest_src_10005.listing_id ) subq_37 WHERE listing__is_lux_latest GROUP BY @@ -51,7 +51,7 @@ FROM ( -- ['bookings', 'listing__is_lux_latest', 'metric_time__day'] SELECT subq_44.metric_time__day AS metric_time__day - , listings_latest_src_10004.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest , subq_44.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -65,9 +65,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_44 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_44.listing = listings_latest_src_10004.listing_id + subq_44.listing = listings_latest_src_10005.listing_id ) subq_49 WHERE listing__is_lux_latest GROUP BY diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql index 5791199c8f..4f7b5af3a8 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql @@ -304,62 +304,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_5 ) subq_6 ) subq_7 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql index c48f7d8d21..7dc6fd2c91 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql @@ -22,5 +22,5 @@ CROSS JOIN ( -- Compute Metrics via Expressions SELECT SUM(1) AS listings - FROM ***************************.dim_listings_latest listings_latest_src_10004 + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_20 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0.sql index ad0f49b3b9..fd50d0a6a1 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0.sql @@ -132,87 +132,87 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_10015.booking_value - , bookings_source_src_10015.guest_id AS bookers - , bookings_source_src_10015.booking_value AS average_booking_value - , bookings_source_src_10015.booking_value AS booking_payments - , bookings_source_src_10015.is_instant - , DATE_TRUNC('day', bookings_source_src_10015.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_10015.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_10015.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_10015.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_10015.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_10015.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_10015.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_10015.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_10015.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_10015.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_10015.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_10015.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_10015.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS paid_at__extract_doy - , bookings_source_src_10015.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_10015.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_10015.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_10015.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_10015.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_10015.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_10015.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_10015.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_10015.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_10015.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_10015.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_10015.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_10015.listing_id AS listing - , bookings_source_src_10015.guest_id AS guest - , bookings_source_src_10015.host_id AS host - , bookings_source_src_10015.guest_id AS user - , bookings_source_src_10015.listing_id AS booking__listing - , bookings_source_src_10015.guest_id AS booking__guest - , bookings_source_src_10015.host_id AS booking__host - , bookings_source_src_10015.guest_id AS booking__user - FROM ***************************.fct_bookings bookings_source_src_10015 + , bookings_source_src_10017.booking_value + , bookings_source_src_10017.guest_id AS bookers + , bookings_source_src_10017.booking_value AS average_booking_value + , bookings_source_src_10017.booking_value AS booking_payments + , bookings_source_src_10017.is_instant + , DATE_TRUNC('day', bookings_source_src_10017.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_10017.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_10017.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_10017.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_10017.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_10017.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_10017.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_10017.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_10017.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_10017.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_10017.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_10017.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_10017.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_10017.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_10017.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_10017.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_10017.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_10017.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_10017.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.paid_at) AS paid_at__extract_doy + , bookings_source_src_10017.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_10017.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_10017.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_10017.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_10017.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_10017.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_10017.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_10017.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_10017.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_10017.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_10017.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_10017.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_10017.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_10017.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_10017.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_10017.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_10017.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_10017.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_10017.listing_id AS listing + , bookings_source_src_10017.guest_id AS guest + , bookings_source_src_10017.host_id AS host + , bookings_source_src_10017.guest_id AS user + , bookings_source_src_10017.listing_id AS booking__listing + , bookings_source_src_10017.guest_id AS booking__guest + , bookings_source_src_10017.host_id AS booking__host + , bookings_source_src_10017.guest_id AS booking__user + FROM ***************************.fct_bookings bookings_source_src_10017 ) subq_0 ) subq_1 ) subq_2 @@ -295,60 +295,60 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'listings' SELECT - listings_src_10017.active_from AS window_start__day - , DATE_TRUNC('week', listings_src_10017.active_from) AS window_start__week - , DATE_TRUNC('month', listings_src_10017.active_from) AS window_start__month - , DATE_TRUNC('quarter', listings_src_10017.active_from) AS window_start__quarter - , DATE_TRUNC('year', listings_src_10017.active_from) AS window_start__year - , EXTRACT(year FROM listings_src_10017.active_from) AS window_start__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_from) AS window_start__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_from) AS window_start__extract_month - , EXTRACT(day FROM listings_src_10017.active_from) AS window_start__extract_day - , CASE WHEN EXTRACT(dow FROM listings_src_10017.active_from) = 0 THEN EXTRACT(dow FROM listings_src_10017.active_from) + 7 ELSE EXTRACT(dow FROM listings_src_10017.active_from) END AS window_start__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_from) AS window_start__extract_doy - , listings_src_10017.active_to AS window_end__day - , DATE_TRUNC('week', listings_src_10017.active_to) AS window_end__week - , DATE_TRUNC('month', listings_src_10017.active_to) AS window_end__month - , DATE_TRUNC('quarter', listings_src_10017.active_to) AS window_end__quarter - , DATE_TRUNC('year', listings_src_10017.active_to) AS window_end__year - , EXTRACT(year FROM listings_src_10017.active_to) AS window_end__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_to) AS window_end__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_to) AS window_end__extract_month - , EXTRACT(day FROM listings_src_10017.active_to) AS window_end__extract_day - , CASE WHEN EXTRACT(dow FROM listings_src_10017.active_to) = 0 THEN EXTRACT(dow FROM listings_src_10017.active_to) + 7 ELSE EXTRACT(dow FROM listings_src_10017.active_to) END AS window_end__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_to) AS window_end__extract_doy - , listings_src_10017.country - , listings_src_10017.is_lux - , listings_src_10017.capacity - , listings_src_10017.active_from AS listing__window_start__day - , DATE_TRUNC('week', listings_src_10017.active_from) AS listing__window_start__week - , DATE_TRUNC('month', listings_src_10017.active_from) AS listing__window_start__month - , DATE_TRUNC('quarter', listings_src_10017.active_from) AS listing__window_start__quarter - , DATE_TRUNC('year', listings_src_10017.active_from) AS listing__window_start__year - , EXTRACT(year FROM listings_src_10017.active_from) AS listing__window_start__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_from) AS listing__window_start__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_from) AS listing__window_start__extract_month - , EXTRACT(day FROM listings_src_10017.active_from) AS listing__window_start__extract_day - , CASE WHEN EXTRACT(dow FROM listings_src_10017.active_from) = 0 THEN EXTRACT(dow FROM listings_src_10017.active_from) + 7 ELSE EXTRACT(dow FROM listings_src_10017.active_from) END AS listing__window_start__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_from) AS listing__window_start__extract_doy - , listings_src_10017.active_to AS listing__window_end__day - , DATE_TRUNC('week', listings_src_10017.active_to) AS listing__window_end__week - , DATE_TRUNC('month', listings_src_10017.active_to) AS listing__window_end__month - , DATE_TRUNC('quarter', listings_src_10017.active_to) AS listing__window_end__quarter - , DATE_TRUNC('year', listings_src_10017.active_to) AS listing__window_end__year - , EXTRACT(year FROM listings_src_10017.active_to) AS listing__window_end__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_to) AS listing__window_end__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_to) AS listing__window_end__extract_month - , EXTRACT(day FROM listings_src_10017.active_to) AS listing__window_end__extract_day - , CASE WHEN EXTRACT(dow FROM listings_src_10017.active_to) = 0 THEN EXTRACT(dow FROM listings_src_10017.active_to) + 7 ELSE EXTRACT(dow FROM listings_src_10017.active_to) END AS listing__window_end__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_to) AS listing__window_end__extract_doy - , listings_src_10017.country AS listing__country - , listings_src_10017.is_lux AS listing__is_lux - , listings_src_10017.capacity AS listing__capacity - , listings_src_10017.listing_id AS listing - , listings_src_10017.user_id AS user - , listings_src_10017.user_id AS listing__user - FROM ***************************.dim_listings listings_src_10017 + listings_src_10019.active_from AS window_start__day + , DATE_TRUNC('week', listings_src_10019.active_from) AS window_start__week + , DATE_TRUNC('month', listings_src_10019.active_from) AS window_start__month + , DATE_TRUNC('quarter', listings_src_10019.active_from) AS window_start__quarter + , DATE_TRUNC('year', listings_src_10019.active_from) AS window_start__year + , EXTRACT(year FROM listings_src_10019.active_from) AS window_start__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_from) AS window_start__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_from) AS window_start__extract_month + , EXTRACT(day FROM listings_src_10019.active_from) AS window_start__extract_day + , CASE WHEN EXTRACT(dow FROM listings_src_10019.active_from) = 0 THEN EXTRACT(dow FROM listings_src_10019.active_from) + 7 ELSE EXTRACT(dow FROM listings_src_10019.active_from) END AS window_start__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_from) AS window_start__extract_doy + , listings_src_10019.active_to AS window_end__day + , DATE_TRUNC('week', listings_src_10019.active_to) AS window_end__week + , DATE_TRUNC('month', listings_src_10019.active_to) AS window_end__month + , DATE_TRUNC('quarter', listings_src_10019.active_to) AS window_end__quarter + , DATE_TRUNC('year', listings_src_10019.active_to) AS window_end__year + , EXTRACT(year FROM listings_src_10019.active_to) AS window_end__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_to) AS window_end__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_to) AS window_end__extract_month + , EXTRACT(day FROM listings_src_10019.active_to) AS window_end__extract_day + , CASE WHEN EXTRACT(dow FROM listings_src_10019.active_to) = 0 THEN EXTRACT(dow FROM listings_src_10019.active_to) + 7 ELSE EXTRACT(dow FROM listings_src_10019.active_to) END AS window_end__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_to) AS window_end__extract_doy + , listings_src_10019.country + , listings_src_10019.is_lux + , listings_src_10019.capacity + , listings_src_10019.active_from AS listing__window_start__day + , DATE_TRUNC('week', listings_src_10019.active_from) AS listing__window_start__week + , DATE_TRUNC('month', listings_src_10019.active_from) AS listing__window_start__month + , DATE_TRUNC('quarter', listings_src_10019.active_from) AS listing__window_start__quarter + , DATE_TRUNC('year', listings_src_10019.active_from) AS listing__window_start__year + , EXTRACT(year FROM listings_src_10019.active_from) AS listing__window_start__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_from) AS listing__window_start__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_from) AS listing__window_start__extract_month + , EXTRACT(day FROM listings_src_10019.active_from) AS listing__window_start__extract_day + , CASE WHEN EXTRACT(dow FROM listings_src_10019.active_from) = 0 THEN EXTRACT(dow FROM listings_src_10019.active_from) + 7 ELSE EXTRACT(dow FROM listings_src_10019.active_from) END AS listing__window_start__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_from) AS listing__window_start__extract_doy + , listings_src_10019.active_to AS listing__window_end__day + , DATE_TRUNC('week', listings_src_10019.active_to) AS listing__window_end__week + , DATE_TRUNC('month', listings_src_10019.active_to) AS listing__window_end__month + , DATE_TRUNC('quarter', listings_src_10019.active_to) AS listing__window_end__quarter + , DATE_TRUNC('year', listings_src_10019.active_to) AS listing__window_end__year + , EXTRACT(year FROM listings_src_10019.active_to) AS listing__window_end__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_to) AS listing__window_end__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_to) AS listing__window_end__extract_month + , EXTRACT(day FROM listings_src_10019.active_to) AS listing__window_end__extract_day + , CASE WHEN EXTRACT(dow FROM listings_src_10019.active_to) = 0 THEN EXTRACT(dow FROM listings_src_10019.active_to) + 7 ELSE EXTRACT(dow FROM listings_src_10019.active_to) END AS listing__window_end__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_to) AS listing__window_end__extract_doy + , listings_src_10019.country AS listing__country + , listings_src_10019.is_lux AS listing__is_lux + , listings_src_10019.capacity AS listing__capacity + , listings_src_10019.listing_id AS listing + , listings_src_10019.user_id AS user + , listings_src_10019.user_id AS listing__user + FROM ***************************.dim_listings listings_src_10019 ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: @@ -406,32 +406,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_10021.ds) AS ds__day - , DATE_TRUNC('week', users_latest_src_10021.ds) AS ds__week - , DATE_TRUNC('month', users_latest_src_10021.ds) AS ds__month - , DATE_TRUNC('quarter', users_latest_src_10021.ds) AS ds__quarter - , DATE_TRUNC('year', users_latest_src_10021.ds) AS ds__year - , EXTRACT(year FROM users_latest_src_10021.ds) AS ds__extract_year - , EXTRACT(quarter FROM users_latest_src_10021.ds) AS ds__extract_quarter - , EXTRACT(month FROM users_latest_src_10021.ds) AS ds__extract_month - , EXTRACT(day FROM users_latest_src_10021.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM users_latest_src_10021.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_10021.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_10021.ds) END AS ds__extract_dow - , EXTRACT(doy FROM users_latest_src_10021.ds) AS ds__extract_doy - , users_latest_src_10021.home_state_latest - , DATE_TRUNC('day', users_latest_src_10021.ds) AS user__ds__day - , DATE_TRUNC('week', users_latest_src_10021.ds) AS user__ds__week - , DATE_TRUNC('month', users_latest_src_10021.ds) AS user__ds__month - , DATE_TRUNC('quarter', users_latest_src_10021.ds) AS user__ds__quarter - , DATE_TRUNC('year', users_latest_src_10021.ds) AS user__ds__year - , EXTRACT(year FROM users_latest_src_10021.ds) AS user__ds__extract_year - , EXTRACT(quarter FROM users_latest_src_10021.ds) AS user__ds__extract_quarter - , EXTRACT(month FROM users_latest_src_10021.ds) AS user__ds__extract_month - , EXTRACT(day FROM users_latest_src_10021.ds) AS user__ds__extract_day - , CASE WHEN EXTRACT(dow FROM users_latest_src_10021.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_10021.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_10021.ds) END AS user__ds__extract_dow - , EXTRACT(doy FROM users_latest_src_10021.ds) AS user__ds__extract_doy - , users_latest_src_10021.home_state_latest AS user__home_state_latest - , users_latest_src_10021.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_10021 + DATE_TRUNC('day', users_latest_src_10023.ds) AS ds__day + , DATE_TRUNC('week', users_latest_src_10023.ds) AS ds__week + , DATE_TRUNC('month', users_latest_src_10023.ds) AS ds__month + , DATE_TRUNC('quarter', users_latest_src_10023.ds) AS ds__quarter + , DATE_TRUNC('year', users_latest_src_10023.ds) AS ds__year + , EXTRACT(year FROM users_latest_src_10023.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_latest_src_10023.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_latest_src_10023.ds) AS ds__extract_month + , EXTRACT(day FROM users_latest_src_10023.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM users_latest_src_10023.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_10023.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_10023.ds) END AS ds__extract_dow + , EXTRACT(doy FROM users_latest_src_10023.ds) AS ds__extract_doy + , users_latest_src_10023.home_state_latest + , DATE_TRUNC('day', users_latest_src_10023.ds) AS user__ds__day + , DATE_TRUNC('week', users_latest_src_10023.ds) AS user__ds__week + , DATE_TRUNC('month', users_latest_src_10023.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_latest_src_10023.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_latest_src_10023.ds) AS user__ds__year + , EXTRACT(year FROM users_latest_src_10023.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_latest_src_10023.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_latest_src_10023.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_latest_src_10023.ds) AS user__ds__extract_day + , CASE WHEN EXTRACT(dow FROM users_latest_src_10023.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_10023.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_10023.ds) END AS user__ds__extract_dow + , EXTRACT(doy FROM users_latest_src_10023.ds) AS user__ds__extract_doy + , users_latest_src_10023.home_state_latest AS user__home_state_latest + , users_latest_src_10023.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_10023 ) subq_4 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0_optimized.sql index aa2ad14d34..afba0439d0 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0_optimized.sql @@ -16,22 +16,22 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_10015 + FROM ***************************.fct_bookings bookings_source_src_10017 ) subq_13 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: -- ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] SELECT - listings_src_10017.active_from AS window_start__day - , listings_src_10017.active_to AS window_end__day - , listings_src_10017.listing_id AS listing - , users_latest_src_10021.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings listings_src_10017 + listings_src_10019.active_from AS window_start__day + , listings_src_10019.active_to AS window_end__day + , listings_src_10019.listing_id AS listing + , users_latest_src_10023.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings listings_src_10019 LEFT OUTER JOIN - ***************************.dim_users_latest users_latest_src_10021 + ***************************.dim_users_latest users_latest_src_10023 ON - listings_src_10017.user_id = users_latest_src_10021.user_id + listings_src_10019.user_id = users_latest_src_10023.user_id ) subq_18 ON ( diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0.sql index 17c8d99d3a..cf08bcd97c 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0.sql @@ -132,87 +132,87 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_10015.booking_value - , bookings_source_src_10015.guest_id AS bookers - , bookings_source_src_10015.booking_value AS average_booking_value - , bookings_source_src_10015.booking_value AS booking_payments - , bookings_source_src_10015.is_instant - , DATE_TRUNC('day', bookings_source_src_10015.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_10015.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_10015.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_10015.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_10015.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_10015.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_10015.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_10015.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_10015.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_10015.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_10015.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_10015.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_10015.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS paid_at__extract_doy - , bookings_source_src_10015.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_10015.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_10015.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_10015.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_10015.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_10015.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_10015.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_10015.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_10015.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_10015.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_10015.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_10015.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_10015.listing_id AS listing - , bookings_source_src_10015.guest_id AS guest - , bookings_source_src_10015.host_id AS host - , bookings_source_src_10015.guest_id AS user - , bookings_source_src_10015.listing_id AS booking__listing - , bookings_source_src_10015.guest_id AS booking__guest - , bookings_source_src_10015.host_id AS booking__host - , bookings_source_src_10015.guest_id AS booking__user - FROM ***************************.fct_bookings bookings_source_src_10015 + , bookings_source_src_10017.booking_value + , bookings_source_src_10017.guest_id AS bookers + , bookings_source_src_10017.booking_value AS average_booking_value + , bookings_source_src_10017.booking_value AS booking_payments + , bookings_source_src_10017.is_instant + , DATE_TRUNC('day', bookings_source_src_10017.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_10017.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_10017.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_10017.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_10017.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_10017.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_10017.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_10017.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_10017.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_10017.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_10017.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_10017.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_10017.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_10017.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_10017.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_10017.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_10017.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_10017.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_10017.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.paid_at) AS paid_at__extract_doy + , bookings_source_src_10017.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_10017.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_10017.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_10017.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_10017.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_10017.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_10017.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_10017.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_10017.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_10017.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_10017.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_10017.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_10017.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_10017.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_10017.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_10017.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_10017.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_10017.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_10017.listing_id AS listing + , bookings_source_src_10017.guest_id AS guest + , bookings_source_src_10017.host_id AS host + , bookings_source_src_10017.guest_id AS user + , bookings_source_src_10017.listing_id AS booking__listing + , bookings_source_src_10017.guest_id AS booking__guest + , bookings_source_src_10017.host_id AS booking__host + , bookings_source_src_10017.guest_id AS booking__user + FROM ***************************.fct_bookings bookings_source_src_10017 ) subq_0 ) subq_1 ) subq_2 @@ -259,10 +259,10 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'lux_listing_mapping' SELECT - lux_listing_mapping_src_10018.listing_id AS listing - , lux_listing_mapping_src_10018.lux_listing_id AS lux_listing - , lux_listing_mapping_src_10018.lux_listing_id AS listing__lux_listing - FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_10018 + lux_listing_mapping_src_10020.listing_id AS listing + , lux_listing_mapping_src_10020.lux_listing_id AS lux_listing + , lux_listing_mapping_src_10020.lux_listing_id AS listing__lux_listing + FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_10020 ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: @@ -364,54 +364,54 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'lux_listings' SELECT - lux_listings_src_10019.valid_from AS window_start__day - , DATE_TRUNC('week', lux_listings_src_10019.valid_from) AS window_start__week - , DATE_TRUNC('month', lux_listings_src_10019.valid_from) AS window_start__month - , DATE_TRUNC('quarter', lux_listings_src_10019.valid_from) AS window_start__quarter - , DATE_TRUNC('year', lux_listings_src_10019.valid_from) AS window_start__year - , EXTRACT(year FROM lux_listings_src_10019.valid_from) AS window_start__extract_year - , EXTRACT(quarter FROM lux_listings_src_10019.valid_from) AS window_start__extract_quarter - , EXTRACT(month FROM lux_listings_src_10019.valid_from) AS window_start__extract_month - , EXTRACT(day FROM lux_listings_src_10019.valid_from) AS window_start__extract_day - , CASE WHEN EXTRACT(dow FROM lux_listings_src_10019.valid_from) = 0 THEN EXTRACT(dow FROM lux_listings_src_10019.valid_from) + 7 ELSE EXTRACT(dow FROM lux_listings_src_10019.valid_from) END AS window_start__extract_dow - , EXTRACT(doy FROM lux_listings_src_10019.valid_from) AS window_start__extract_doy - , lux_listings_src_10019.valid_to AS window_end__day - , DATE_TRUNC('week', lux_listings_src_10019.valid_to) AS window_end__week - , DATE_TRUNC('month', lux_listings_src_10019.valid_to) AS window_end__month - , DATE_TRUNC('quarter', lux_listings_src_10019.valid_to) AS window_end__quarter - , DATE_TRUNC('year', lux_listings_src_10019.valid_to) AS window_end__year - , EXTRACT(year FROM lux_listings_src_10019.valid_to) AS window_end__extract_year - , EXTRACT(quarter FROM lux_listings_src_10019.valid_to) AS window_end__extract_quarter - , EXTRACT(month FROM lux_listings_src_10019.valid_to) AS window_end__extract_month - , EXTRACT(day FROM lux_listings_src_10019.valid_to) AS window_end__extract_day - , CASE WHEN EXTRACT(dow FROM lux_listings_src_10019.valid_to) = 0 THEN EXTRACT(dow FROM lux_listings_src_10019.valid_to) + 7 ELSE EXTRACT(dow FROM lux_listings_src_10019.valid_to) END AS window_end__extract_dow - , EXTRACT(doy FROM lux_listings_src_10019.valid_to) AS window_end__extract_doy - , lux_listings_src_10019.is_confirmed_lux - , lux_listings_src_10019.valid_from AS lux_listing__window_start__day - , DATE_TRUNC('week', lux_listings_src_10019.valid_from) AS lux_listing__window_start__week - , DATE_TRUNC('month', lux_listings_src_10019.valid_from) AS lux_listing__window_start__month - , DATE_TRUNC('quarter', lux_listings_src_10019.valid_from) AS lux_listing__window_start__quarter - , DATE_TRUNC('year', lux_listings_src_10019.valid_from) AS lux_listing__window_start__year - , EXTRACT(year FROM lux_listings_src_10019.valid_from) AS lux_listing__window_start__extract_year - , EXTRACT(quarter FROM lux_listings_src_10019.valid_from) AS lux_listing__window_start__extract_quarter - , EXTRACT(month FROM lux_listings_src_10019.valid_from) AS lux_listing__window_start__extract_month - , EXTRACT(day FROM lux_listings_src_10019.valid_from) AS lux_listing__window_start__extract_day - , CASE WHEN EXTRACT(dow FROM lux_listings_src_10019.valid_from) = 0 THEN EXTRACT(dow FROM lux_listings_src_10019.valid_from) + 7 ELSE EXTRACT(dow FROM lux_listings_src_10019.valid_from) END AS lux_listing__window_start__extract_dow - , EXTRACT(doy FROM lux_listings_src_10019.valid_from) AS lux_listing__window_start__extract_doy - , lux_listings_src_10019.valid_to AS lux_listing__window_end__day - , DATE_TRUNC('week', lux_listings_src_10019.valid_to) AS lux_listing__window_end__week - , DATE_TRUNC('month', lux_listings_src_10019.valid_to) AS lux_listing__window_end__month - , DATE_TRUNC('quarter', lux_listings_src_10019.valid_to) AS lux_listing__window_end__quarter - , DATE_TRUNC('year', lux_listings_src_10019.valid_to) AS lux_listing__window_end__year - , EXTRACT(year FROM lux_listings_src_10019.valid_to) AS lux_listing__window_end__extract_year - , EXTRACT(quarter FROM lux_listings_src_10019.valid_to) AS lux_listing__window_end__extract_quarter - , EXTRACT(month FROM lux_listings_src_10019.valid_to) AS lux_listing__window_end__extract_month - , EXTRACT(day FROM lux_listings_src_10019.valid_to) AS lux_listing__window_end__extract_day - , CASE WHEN EXTRACT(dow FROM lux_listings_src_10019.valid_to) = 0 THEN EXTRACT(dow FROM lux_listings_src_10019.valid_to) + 7 ELSE EXTRACT(dow FROM lux_listings_src_10019.valid_to) END AS lux_listing__window_end__extract_dow - , EXTRACT(doy FROM lux_listings_src_10019.valid_to) AS lux_listing__window_end__extract_doy - , lux_listings_src_10019.is_confirmed_lux AS lux_listing__is_confirmed_lux - , lux_listings_src_10019.lux_listing_id AS lux_listing - FROM ***************************.dim_lux_listings lux_listings_src_10019 + lux_listings_src_10021.valid_from AS window_start__day + , DATE_TRUNC('week', lux_listings_src_10021.valid_from) AS window_start__week + , DATE_TRUNC('month', lux_listings_src_10021.valid_from) AS window_start__month + , DATE_TRUNC('quarter', lux_listings_src_10021.valid_from) AS window_start__quarter + , DATE_TRUNC('year', lux_listings_src_10021.valid_from) AS window_start__year + , EXTRACT(year FROM lux_listings_src_10021.valid_from) AS window_start__extract_year + , EXTRACT(quarter FROM lux_listings_src_10021.valid_from) AS window_start__extract_quarter + , EXTRACT(month FROM lux_listings_src_10021.valid_from) AS window_start__extract_month + , EXTRACT(day FROM lux_listings_src_10021.valid_from) AS window_start__extract_day + , CASE WHEN EXTRACT(dow FROM lux_listings_src_10021.valid_from) = 0 THEN EXTRACT(dow FROM lux_listings_src_10021.valid_from) + 7 ELSE EXTRACT(dow FROM lux_listings_src_10021.valid_from) END AS window_start__extract_dow + , EXTRACT(doy FROM lux_listings_src_10021.valid_from) AS window_start__extract_doy + , lux_listings_src_10021.valid_to AS window_end__day + , DATE_TRUNC('week', lux_listings_src_10021.valid_to) AS window_end__week + , DATE_TRUNC('month', lux_listings_src_10021.valid_to) AS window_end__month + , DATE_TRUNC('quarter', lux_listings_src_10021.valid_to) AS window_end__quarter + , DATE_TRUNC('year', lux_listings_src_10021.valid_to) AS window_end__year + , EXTRACT(year FROM lux_listings_src_10021.valid_to) AS window_end__extract_year + , EXTRACT(quarter FROM lux_listings_src_10021.valid_to) AS window_end__extract_quarter + , EXTRACT(month FROM lux_listings_src_10021.valid_to) AS window_end__extract_month + , EXTRACT(day FROM lux_listings_src_10021.valid_to) AS window_end__extract_day + , CASE WHEN EXTRACT(dow FROM lux_listings_src_10021.valid_to) = 0 THEN EXTRACT(dow FROM lux_listings_src_10021.valid_to) + 7 ELSE EXTRACT(dow FROM lux_listings_src_10021.valid_to) END AS window_end__extract_dow + , EXTRACT(doy FROM lux_listings_src_10021.valid_to) AS window_end__extract_doy + , lux_listings_src_10021.is_confirmed_lux + , lux_listings_src_10021.valid_from AS lux_listing__window_start__day + , DATE_TRUNC('week', lux_listings_src_10021.valid_from) AS lux_listing__window_start__week + , DATE_TRUNC('month', lux_listings_src_10021.valid_from) AS lux_listing__window_start__month + , DATE_TRUNC('quarter', lux_listings_src_10021.valid_from) AS lux_listing__window_start__quarter + , DATE_TRUNC('year', lux_listings_src_10021.valid_from) AS lux_listing__window_start__year + , EXTRACT(year FROM lux_listings_src_10021.valid_from) AS lux_listing__window_start__extract_year + , EXTRACT(quarter FROM lux_listings_src_10021.valid_from) AS lux_listing__window_start__extract_quarter + , EXTRACT(month FROM lux_listings_src_10021.valid_from) AS lux_listing__window_start__extract_month + , EXTRACT(day FROM lux_listings_src_10021.valid_from) AS lux_listing__window_start__extract_day + , CASE WHEN EXTRACT(dow FROM lux_listings_src_10021.valid_from) = 0 THEN EXTRACT(dow FROM lux_listings_src_10021.valid_from) + 7 ELSE EXTRACT(dow FROM lux_listings_src_10021.valid_from) END AS lux_listing__window_start__extract_dow + , EXTRACT(doy FROM lux_listings_src_10021.valid_from) AS lux_listing__window_start__extract_doy + , lux_listings_src_10021.valid_to AS lux_listing__window_end__day + , DATE_TRUNC('week', lux_listings_src_10021.valid_to) AS lux_listing__window_end__week + , DATE_TRUNC('month', lux_listings_src_10021.valid_to) AS lux_listing__window_end__month + , DATE_TRUNC('quarter', lux_listings_src_10021.valid_to) AS lux_listing__window_end__quarter + , DATE_TRUNC('year', lux_listings_src_10021.valid_to) AS lux_listing__window_end__year + , EXTRACT(year FROM lux_listings_src_10021.valid_to) AS lux_listing__window_end__extract_year + , EXTRACT(quarter FROM lux_listings_src_10021.valid_to) AS lux_listing__window_end__extract_quarter + , EXTRACT(month FROM lux_listings_src_10021.valid_to) AS lux_listing__window_end__extract_month + , EXTRACT(day FROM lux_listings_src_10021.valid_to) AS lux_listing__window_end__extract_day + , CASE WHEN EXTRACT(dow FROM lux_listings_src_10021.valid_to) = 0 THEN EXTRACT(dow FROM lux_listings_src_10021.valid_to) + 7 ELSE EXTRACT(dow FROM lux_listings_src_10021.valid_to) END AS lux_listing__window_end__extract_dow + , EXTRACT(doy FROM lux_listings_src_10021.valid_to) AS lux_listing__window_end__extract_doy + , lux_listings_src_10021.is_confirmed_lux AS lux_listing__is_confirmed_lux + , lux_listings_src_10021.lux_listing_id AS lux_listing + FROM ***************************.dim_lux_listings lux_listings_src_10021 ) subq_4 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0_optimized.sql index add7e259ab..16470814e6 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0_optimized.sql @@ -16,7 +16,7 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_10015 + FROM ***************************.fct_bookings bookings_source_src_10017 ) subq_13 LEFT OUTER JOIN ( -- Join Standard Outputs @@ -26,15 +26,15 @@ LEFT OUTER JOIN ( -- 'lux_listing__window_end__day', -- 'listing'] SELECT - lux_listings_src_10019.valid_from AS lux_listing__window_start__day - , lux_listings_src_10019.valid_to AS lux_listing__window_end__day - , lux_listing_mapping_src_10018.listing_id AS listing - , lux_listings_src_10019.is_confirmed_lux AS lux_listing__is_confirmed_lux - FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_10018 + lux_listings_src_10021.valid_from AS lux_listing__window_start__day + , lux_listings_src_10021.valid_to AS lux_listing__window_end__day + , lux_listing_mapping_src_10020.listing_id AS listing + , lux_listings_src_10021.is_confirmed_lux AS lux_listing__is_confirmed_lux + FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_10020 LEFT OUTER JOIN - ***************************.dim_lux_listings lux_listings_src_10019 + ***************************.dim_lux_listings lux_listings_src_10021 ON - lux_listing_mapping_src_10018.lux_listing_id = lux_listings_src_10019.lux_listing_id + lux_listing_mapping_src_10020.lux_listing_id = lux_listings_src_10021.lux_listing_id ) subq_18 ON ( diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multihop_node__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multihop_node__plan0.sql index 457bcd7107..bceef5d6c6 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multihop_node__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multihop_node__plan0.sql @@ -93,55 +93,55 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'account_month_txns' SELECT - account_month_txns_src_10010.txn_count - , DATE_TRUNC('day', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM account_month_txns_src_10010.ds_partitioned) = 0 THEN EXTRACT(dow FROM account_month_txns_src_10010.ds_partitioned) + 7 ELSE EXTRACT(dow FROM account_month_txns_src_10010.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', account_month_txns_src_10010.ds) AS ds__day - , DATE_TRUNC('week', account_month_txns_src_10010.ds) AS ds__week - , DATE_TRUNC('month', account_month_txns_src_10010.ds) AS ds__month - , DATE_TRUNC('quarter', account_month_txns_src_10010.ds) AS ds__quarter - , DATE_TRUNC('year', account_month_txns_src_10010.ds) AS ds__year - , EXTRACT(year FROM account_month_txns_src_10010.ds) AS ds__extract_year - , EXTRACT(quarter FROM account_month_txns_src_10010.ds) AS ds__extract_quarter - , EXTRACT(month FROM account_month_txns_src_10010.ds) AS ds__extract_month - , EXTRACT(day FROM account_month_txns_src_10010.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM account_month_txns_src_10010.ds) = 0 THEN EXTRACT(dow FROM account_month_txns_src_10010.ds) + 7 ELSE EXTRACT(dow FROM account_month_txns_src_10010.ds) END AS ds__extract_dow - , EXTRACT(doy FROM account_month_txns_src_10010.ds) AS ds__extract_doy - , account_month_txns_src_10010.account_month - , DATE_TRUNC('day', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__day - , DATE_TRUNC('week', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__week - , DATE_TRUNC('month', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__month - , DATE_TRUNC('quarter', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__quarter - , DATE_TRUNC('year', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__year - , EXTRACT(year FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_month - , EXTRACT(day FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM account_month_txns_src_10010.ds_partitioned) = 0 THEN EXTRACT(dow FROM account_month_txns_src_10010.ds_partitioned) + 7 ELSE EXTRACT(dow FROM account_month_txns_src_10010.ds_partitioned) END AS account_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , DATE_TRUNC('day', account_month_txns_src_10010.ds) AS account_id__ds__day - , DATE_TRUNC('week', account_month_txns_src_10010.ds) AS account_id__ds__week - , DATE_TRUNC('month', account_month_txns_src_10010.ds) AS account_id__ds__month - , DATE_TRUNC('quarter', account_month_txns_src_10010.ds) AS account_id__ds__quarter - , DATE_TRUNC('year', account_month_txns_src_10010.ds) AS account_id__ds__year - , EXTRACT(year FROM account_month_txns_src_10010.ds) AS account_id__ds__extract_year - , EXTRACT(quarter FROM account_month_txns_src_10010.ds) AS account_id__ds__extract_quarter - , EXTRACT(month FROM account_month_txns_src_10010.ds) AS account_id__ds__extract_month - , EXTRACT(day FROM account_month_txns_src_10010.ds) AS account_id__ds__extract_day - , CASE WHEN EXTRACT(dow FROM account_month_txns_src_10010.ds) = 0 THEN EXTRACT(dow FROM account_month_txns_src_10010.ds) + 7 ELSE EXTRACT(dow FROM account_month_txns_src_10010.ds) END AS account_id__ds__extract_dow - , EXTRACT(doy FROM account_month_txns_src_10010.ds) AS account_id__ds__extract_doy - , account_month_txns_src_10010.account_month AS account_id__account_month - , account_month_txns_src_10010.account_id - FROM ***************************.account_month_txns account_month_txns_src_10010 + account_month_txns_src_10012.txn_count + , DATE_TRUNC('day', account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM account_month_txns_src_10012.ds_partitioned) = 0 THEN EXTRACT(dow FROM account_month_txns_src_10012.ds_partitioned) + 7 ELSE EXTRACT(dow FROM account_month_txns_src_10012.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', account_month_txns_src_10012.ds) AS ds__day + , DATE_TRUNC('week', account_month_txns_src_10012.ds) AS ds__week + , DATE_TRUNC('month', account_month_txns_src_10012.ds) AS ds__month + , DATE_TRUNC('quarter', account_month_txns_src_10012.ds) AS ds__quarter + , DATE_TRUNC('year', account_month_txns_src_10012.ds) AS ds__year + , EXTRACT(year FROM account_month_txns_src_10012.ds) AS ds__extract_year + , EXTRACT(quarter FROM account_month_txns_src_10012.ds) AS ds__extract_quarter + , EXTRACT(month FROM account_month_txns_src_10012.ds) AS ds__extract_month + , EXTRACT(day FROM account_month_txns_src_10012.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM account_month_txns_src_10012.ds) = 0 THEN EXTRACT(dow FROM account_month_txns_src_10012.ds) + 7 ELSE EXTRACT(dow FROM account_month_txns_src_10012.ds) END AS ds__extract_dow + , EXTRACT(doy FROM account_month_txns_src_10012.ds) AS ds__extract_doy + , account_month_txns_src_10012.account_month + , DATE_TRUNC('day', account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__day + , DATE_TRUNC('week', account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__week + , DATE_TRUNC('month', account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__month + , DATE_TRUNC('quarter', account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__quarter + , DATE_TRUNC('year', account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__year + , EXTRACT(year FROM account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__extract_month + , EXTRACT(day FROM account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM account_month_txns_src_10012.ds_partitioned) = 0 THEN EXTRACT(dow FROM account_month_txns_src_10012.ds_partitioned) + 7 ELSE EXTRACT(dow FROM account_month_txns_src_10012.ds_partitioned) END AS account_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__extract_doy + , DATE_TRUNC('day', account_month_txns_src_10012.ds) AS account_id__ds__day + , DATE_TRUNC('week', account_month_txns_src_10012.ds) AS account_id__ds__week + , DATE_TRUNC('month', account_month_txns_src_10012.ds) AS account_id__ds__month + , DATE_TRUNC('quarter', account_month_txns_src_10012.ds) AS account_id__ds__quarter + , DATE_TRUNC('year', account_month_txns_src_10012.ds) AS account_id__ds__year + , EXTRACT(year FROM account_month_txns_src_10012.ds) AS account_id__ds__extract_year + , EXTRACT(quarter FROM account_month_txns_src_10012.ds) AS account_id__ds__extract_quarter + , EXTRACT(month FROM account_month_txns_src_10012.ds) AS account_id__ds__extract_month + , EXTRACT(day FROM account_month_txns_src_10012.ds) AS account_id__ds__extract_day + , CASE WHEN EXTRACT(dow FROM account_month_txns_src_10012.ds) = 0 THEN EXTRACT(dow FROM account_month_txns_src_10012.ds) + 7 ELSE EXTRACT(dow FROM account_month_txns_src_10012.ds) END AS account_id__ds__extract_dow + , EXTRACT(doy FROM account_month_txns_src_10012.ds) AS account_id__ds__extract_doy + , account_month_txns_src_10012.account_month AS account_id__account_month + , account_month_txns_src_10012.account_id + FROM ***************************.account_month_txns account_month_txns_src_10012 ) subq_0 ) subq_1 ) subq_2 @@ -212,48 +212,48 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT - bridge_table_src_10011.extra_dim - , DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bridge_table_src_10011.ds_partitioned) = 0 THEN EXTRACT(dow FROM bridge_table_src_10011.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bridge_table_src_10011.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_doy - , bridge_table_src_10011.extra_dim AS account_id__extra_dim - , DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__day - , DATE_TRUNC('week', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__week - , DATE_TRUNC('month', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__month - , DATE_TRUNC('quarter', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__quarter - , DATE_TRUNC('year', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bridge_table_src_10011.ds_partitioned) = 0 THEN EXTRACT(dow FROM bridge_table_src_10011.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bridge_table_src_10011.ds_partitioned) END AS account_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , bridge_table_src_10011.extra_dim AS bridge_account__extra_dim - , DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__day - , DATE_TRUNC('week', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__week - , DATE_TRUNC('month', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__month - , DATE_TRUNC('quarter', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__quarter - , DATE_TRUNC('year', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bridge_table_src_10011.ds_partitioned) = 0 THEN EXTRACT(dow FROM bridge_table_src_10011.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bridge_table_src_10011.ds_partitioned) END AS bridge_account__ds_partitioned__extract_dow - , EXTRACT(doy FROM bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__extract_doy - , bridge_table_src_10011.account_id - , bridge_table_src_10011.customer_id - , bridge_table_src_10011.customer_id AS account_id__customer_id - , bridge_table_src_10011.account_id AS bridge_account__account_id - , bridge_table_src_10011.customer_id AS bridge_account__customer_id - FROM ***************************.bridge_table bridge_table_src_10011 + bridge_table_src_10013.extra_dim + , DATE_TRUNC('day', bridge_table_src_10013.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bridge_table_src_10013.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bridge_table_src_10013.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bridge_table_src_10013.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bridge_table_src_10013.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_10013.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_10013.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_10013.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_10013.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bridge_table_src_10013.ds_partitioned) = 0 THEN EXTRACT(dow FROM bridge_table_src_10013.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bridge_table_src_10013.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bridge_table_src_10013.ds_partitioned) AS ds_partitioned__extract_doy + , bridge_table_src_10013.extra_dim AS account_id__extra_dim + , DATE_TRUNC('day', bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__day + , DATE_TRUNC('week', bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__week + , DATE_TRUNC('month', bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__month + , DATE_TRUNC('quarter', bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__quarter + , DATE_TRUNC('year', bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bridge_table_src_10013.ds_partitioned) = 0 THEN EXTRACT(dow FROM bridge_table_src_10013.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bridge_table_src_10013.ds_partitioned) END AS account_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__extract_doy + , bridge_table_src_10013.extra_dim AS bridge_account__extra_dim + , DATE_TRUNC('day', bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__day + , DATE_TRUNC('week', bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__week + , DATE_TRUNC('month', bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__month + , DATE_TRUNC('quarter', bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__quarter + , DATE_TRUNC('year', bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bridge_table_src_10013.ds_partitioned) = 0 THEN EXTRACT(dow FROM bridge_table_src_10013.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bridge_table_src_10013.ds_partitioned) END AS bridge_account__ds_partitioned__extract_dow + , EXTRACT(doy FROM bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__extract_doy + , bridge_table_src_10013.account_id + , bridge_table_src_10013.customer_id + , bridge_table_src_10013.customer_id AS account_id__customer_id + , bridge_table_src_10013.account_id AS bridge_account__account_id + , bridge_table_src_10013.customer_id AS bridge_account__customer_id + FROM ***************************.bridge_table bridge_table_src_10013 ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: @@ -315,34 +315,34 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'customer_table' SELECT - customer_table_src_10013.customer_name - , customer_table_src_10013.customer_atomic_weight - , DATE_TRUNC('day', customer_table_src_10013.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', customer_table_src_10013.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', customer_table_src_10013.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', customer_table_src_10013.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', customer_table_src_10013.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM customer_table_src_10013.ds_partitioned) = 0 THEN EXTRACT(dow FROM customer_table_src_10013.ds_partitioned) + 7 ELSE EXTRACT(dow FROM customer_table_src_10013.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_doy - , customer_table_src_10013.customer_name AS customer_id__customer_name - , customer_table_src_10013.customer_atomic_weight AS customer_id__customer_atomic_weight - , DATE_TRUNC('day', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__day - , DATE_TRUNC('week', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__week - , DATE_TRUNC('month', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__month - , DATE_TRUNC('quarter', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__quarter - , DATE_TRUNC('year', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__year - , EXTRACT(year FROM customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__extract_month - , EXTRACT(day FROM customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM customer_table_src_10013.ds_partitioned) = 0 THEN EXTRACT(dow FROM customer_table_src_10013.ds_partitioned) + 7 ELSE EXTRACT(dow FROM customer_table_src_10013.ds_partitioned) END AS customer_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__extract_doy - , customer_table_src_10013.customer_id - FROM ***************************.customer_table customer_table_src_10013 + customer_table_src_10015.customer_name + , customer_table_src_10015.customer_atomic_weight + , DATE_TRUNC('day', customer_table_src_10015.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', customer_table_src_10015.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', customer_table_src_10015.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', customer_table_src_10015.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', customer_table_src_10015.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM customer_table_src_10015.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM customer_table_src_10015.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM customer_table_src_10015.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM customer_table_src_10015.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM customer_table_src_10015.ds_partitioned) = 0 THEN EXTRACT(dow FROM customer_table_src_10015.ds_partitioned) + 7 ELSE EXTRACT(dow FROM customer_table_src_10015.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM customer_table_src_10015.ds_partitioned) AS ds_partitioned__extract_doy + , customer_table_src_10015.customer_name AS customer_id__customer_name + , customer_table_src_10015.customer_atomic_weight AS customer_id__customer_atomic_weight + , DATE_TRUNC('day', customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__day + , DATE_TRUNC('week', customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__week + , DATE_TRUNC('month', customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__month + , DATE_TRUNC('quarter', customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__quarter + , DATE_TRUNC('year', customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__year + , EXTRACT(year FROM customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__extract_month + , EXTRACT(day FROM customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM customer_table_src_10015.ds_partitioned) = 0 THEN EXTRACT(dow FROM customer_table_src_10015.ds_partitioned) + 7 ELSE EXTRACT(dow FROM customer_table_src_10015.ds_partitioned) END AS customer_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__extract_doy + , customer_table_src_10015.customer_id + FROM ***************************.customer_table customer_table_src_10015 ) subq_4 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multihop_node__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multihop_node__plan0_optimized.sql index 8a42052413..65d688b745 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multihop_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multihop_node__plan0_optimized.sql @@ -5,31 +5,31 @@ -- Compute Metrics via Expressions SELECT subq_18.customer_id__customer_name AS account_id__customer_id__customer_name - , SUM(account_month_txns_src_10010.txn_count) AS txn_count -FROM ***************************.account_month_txns account_month_txns_src_10010 + , SUM(account_month_txns_src_10012.txn_count) AS txn_count +FROM ***************************.account_month_txns account_month_txns_src_10012 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: -- ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__day - , bridge_table_src_10011.account_id AS account_id - , customer_table_src_10013.customer_name AS customer_id__customer_name - FROM ***************************.bridge_table bridge_table_src_10011 + DATE_TRUNC('day', bridge_table_src_10013.ds_partitioned) AS ds_partitioned__day + , bridge_table_src_10013.account_id AS account_id + , customer_table_src_10015.customer_name AS customer_id__customer_name + FROM ***************************.bridge_table bridge_table_src_10013 LEFT OUTER JOIN - ***************************.customer_table customer_table_src_10013 + ***************************.customer_table customer_table_src_10015 ON ( - bridge_table_src_10011.customer_id = customer_table_src_10013.customer_id + bridge_table_src_10013.customer_id = customer_table_src_10015.customer_id ) AND ( - DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) = DATE_TRUNC('day', customer_table_src_10013.ds_partitioned) + DATE_TRUNC('day', bridge_table_src_10013.ds_partitioned) = DATE_TRUNC('day', customer_table_src_10015.ds_partitioned) ) ) subq_18 ON ( - account_month_txns_src_10010.account_id = subq_18.account_id + account_month_txns_src_10012.account_id = subq_18.account_id ) AND ( - DATE_TRUNC('day', account_month_txns_src_10010.ds_partitioned) = subq_18.ds_partitioned__day + DATE_TRUNC('day', account_month_txns_src_10012.ds_partitioned) = subq_18.ds_partitioned__day ) GROUP BY subq_18.customer_id__customer_name diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multiple_metrics_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multiple_metrics_no_dimensions__plan0.sql index b245b7e6dc..6dce146107 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multiple_metrics_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multiple_metrics_no_dimensions__plan0.sql @@ -473,62 +473,62 @@ CROSS JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_10004.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10004.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10004.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_10005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_10005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_10005.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_6 ) subq_7 WHERE subq_7.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multiple_metrics_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multiple_metrics_no_dimensions__plan0_optimized.sql index 631546edf7..5fdefdb6a7 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multiple_metrics_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multiple_metrics_no_dimensions__plan0_optimized.sql @@ -25,6 +25,6 @@ CROSS JOIN ( -- Compute Metrics via Expressions SELECT SUM(1) AS listings - FROM ***************************.dim_listings_latest listings_latest_src_10004 + FROM ***************************.dim_listings_latest listings_latest_src_10005 WHERE DATE_TRUNC('day', created_at) BETWEEN '2020-01-01' AND '2020-01-01' ) subq_23 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_partitioned_join__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_partitioned_join__plan0.sql index b1a86fa4b8..1970158077 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_partitioned_join__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_partitioned_join__plan0.sql @@ -96,56 +96,56 @@ FROM ( -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , DATE_TRUNC('day', id_verifications_src_10003.ds) AS ds__day - , DATE_TRUNC('week', id_verifications_src_10003.ds) AS ds__week - , DATE_TRUNC('month', id_verifications_src_10003.ds) AS ds__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS ds__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds) AS ds__year - , EXTRACT(year FROM id_verifications_src_10003.ds) AS ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds) AS ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds) AS ds__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM id_verifications_src_10003.ds) = 0 THEN EXTRACT(dow FROM id_verifications_src_10003.ds) + 7 ELSE EXTRACT(dow FROM id_verifications_src_10003.ds) END AS ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds) AS ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM id_verifications_src_10003.ds_partitioned) = 0 THEN EXTRACT(dow FROM id_verifications_src_10003.ds_partitioned) + 7 ELSE EXTRACT(dow FROM id_verifications_src_10003.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_doy - , id_verifications_src_10003.verification_type - , DATE_TRUNC('day', id_verifications_src_10003.ds) AS verification__ds__day - , DATE_TRUNC('week', id_verifications_src_10003.ds) AS verification__ds__week - , DATE_TRUNC('month', id_verifications_src_10003.ds) AS verification__ds__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS verification__ds__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds) AS verification__ds__year - , EXTRACT(year FROM id_verifications_src_10003.ds) AS verification__ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds) AS verification__ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds) AS verification__ds__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds) AS verification__ds__extract_day - , CASE WHEN EXTRACT(dow FROM id_verifications_src_10003.ds) = 0 THEN EXTRACT(dow FROM id_verifications_src_10003.ds) + 7 ELSE EXTRACT(dow FROM id_verifications_src_10003.ds) END AS verification__ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds) AS verification__ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM id_verifications_src_10003.ds_partitioned) = 0 THEN EXTRACT(dow FROM id_verifications_src_10003.ds_partitioned) + 7 ELSE EXTRACT(dow FROM id_verifications_src_10003.ds_partitioned) END AS verification__ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_doy - , id_verifications_src_10003.verification_type AS verification__verification_type - , id_verifications_src_10003.verification_id AS verification - , id_verifications_src_10003.user_id AS user - , id_verifications_src_10003.user_id AS verification__user - FROM ***************************.fct_id_verifications id_verifications_src_10003 + , DATE_TRUNC('day', id_verifications_src_10004.ds) AS ds__day + , DATE_TRUNC('week', id_verifications_src_10004.ds) AS ds__week + , DATE_TRUNC('month', id_verifications_src_10004.ds) AS ds__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds) AS ds__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds) AS ds__year + , EXTRACT(year FROM id_verifications_src_10004.ds) AS ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds) AS ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds) AS ds__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM id_verifications_src_10004.ds) = 0 THEN EXTRACT(dow FROM id_verifications_src_10004.ds) + 7 ELSE EXTRACT(dow FROM id_verifications_src_10004.ds) END AS ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds) AS ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM id_verifications_src_10004.ds_partitioned) = 0 THEN EXTRACT(dow FROM id_verifications_src_10004.ds_partitioned) + 7 ELSE EXTRACT(dow FROM id_verifications_src_10004.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_doy + , id_verifications_src_10004.verification_type + , DATE_TRUNC('day', id_verifications_src_10004.ds) AS verification__ds__day + , DATE_TRUNC('week', id_verifications_src_10004.ds) AS verification__ds__week + , DATE_TRUNC('month', id_verifications_src_10004.ds) AS verification__ds__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds) AS verification__ds__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds) AS verification__ds__year + , EXTRACT(year FROM id_verifications_src_10004.ds) AS verification__ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds) AS verification__ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds) AS verification__ds__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds) AS verification__ds__extract_day + , CASE WHEN EXTRACT(dow FROM id_verifications_src_10004.ds) = 0 THEN EXTRACT(dow FROM id_verifications_src_10004.ds) + 7 ELSE EXTRACT(dow FROM id_verifications_src_10004.ds) END AS verification__ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds) AS verification__ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM id_verifications_src_10004.ds_partitioned) = 0 THEN EXTRACT(dow FROM id_verifications_src_10004.ds_partitioned) + 7 ELSE EXTRACT(dow FROM id_verifications_src_10004.ds_partitioned) END AS verification__ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_doy + , id_verifications_src_10004.verification_type AS verification__verification_type + , id_verifications_src_10004.verification_id AS verification + , id_verifications_src_10004.user_id AS user + , id_verifications_src_10004.user_id AS verification__user + FROM ***************************.fct_id_verifications id_verifications_src_10004 ) subq_0 ) subq_1 ) subq_2 @@ -159,76 +159,76 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT - DATE_TRUNC('day', users_ds_source_src_10007.ds) AS ds__day - , DATE_TRUNC('week', users_ds_source_src_10007.ds) AS ds__week - , DATE_TRUNC('month', users_ds_source_src_10007.ds) AS ds__month - , DATE_TRUNC('quarter', users_ds_source_src_10007.ds) AS ds__quarter - , DATE_TRUNC('year', users_ds_source_src_10007.ds) AS ds__year - , EXTRACT(year FROM users_ds_source_src_10007.ds) AS ds__extract_year - , EXTRACT(quarter FROM users_ds_source_src_10007.ds) AS ds__extract_quarter - , EXTRACT(month FROM users_ds_source_src_10007.ds) AS ds__extract_month - , EXTRACT(day FROM users_ds_source_src_10007.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM users_ds_source_src_10007.ds) = 0 THEN EXTRACT(dow FROM users_ds_source_src_10007.ds) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_10007.ds) END AS ds__extract_dow - , EXTRACT(doy FROM users_ds_source_src_10007.ds) AS ds__extract_doy - , DATE_TRUNC('day', users_ds_source_src_10007.created_at) AS created_at__day - , DATE_TRUNC('week', users_ds_source_src_10007.created_at) AS created_at__week - , DATE_TRUNC('month', users_ds_source_src_10007.created_at) AS created_at__month - , DATE_TRUNC('quarter', users_ds_source_src_10007.created_at) AS created_at__quarter - , DATE_TRUNC('year', users_ds_source_src_10007.created_at) AS created_at__year - , EXTRACT(year FROM users_ds_source_src_10007.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_10007.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_10007.created_at) AS created_at__extract_month - , EXTRACT(day FROM users_ds_source_src_10007.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM users_ds_source_src_10007.created_at) = 0 THEN EXTRACT(dow FROM users_ds_source_src_10007.created_at) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_10007.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_10007.created_at) AS created_at__extract_doy - , DATE_TRUNC('day', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM users_ds_source_src_10007.ds_partitioned) = 0 THEN EXTRACT(dow FROM users_ds_source_src_10007.ds_partitioned) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_10007.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_doy - , users_ds_source_src_10007.home_state - , DATE_TRUNC('day', users_ds_source_src_10007.ds) AS user__ds__day - , DATE_TRUNC('week', users_ds_source_src_10007.ds) AS user__ds__week - , DATE_TRUNC('month', users_ds_source_src_10007.ds) AS user__ds__month - , DATE_TRUNC('quarter', users_ds_source_src_10007.ds) AS user__ds__quarter - , DATE_TRUNC('year', users_ds_source_src_10007.ds) AS user__ds__year - , EXTRACT(year FROM users_ds_source_src_10007.ds) AS user__ds__extract_year - , EXTRACT(quarter FROM users_ds_source_src_10007.ds) AS user__ds__extract_quarter - , EXTRACT(month FROM users_ds_source_src_10007.ds) AS user__ds__extract_month - , EXTRACT(day FROM users_ds_source_src_10007.ds) AS user__ds__extract_day - , CASE WHEN EXTRACT(dow FROM users_ds_source_src_10007.ds) = 0 THEN EXTRACT(dow FROM users_ds_source_src_10007.ds) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_10007.ds) END AS user__ds__extract_dow - , EXTRACT(doy FROM users_ds_source_src_10007.ds) AS user__ds__extract_doy - , DATE_TRUNC('day', users_ds_source_src_10007.created_at) AS user__created_at__day - , DATE_TRUNC('week', users_ds_source_src_10007.created_at) AS user__created_at__week - , DATE_TRUNC('month', users_ds_source_src_10007.created_at) AS user__created_at__month - , DATE_TRUNC('quarter', users_ds_source_src_10007.created_at) AS user__created_at__quarter - , DATE_TRUNC('year', users_ds_source_src_10007.created_at) AS user__created_at__year - , EXTRACT(year FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_month - , EXTRACT(day FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM users_ds_source_src_10007.created_at) = 0 THEN EXTRACT(dow FROM users_ds_source_src_10007.created_at) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_10007.created_at) END AS user__created_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_doy - , DATE_TRUNC('day', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__day - , DATE_TRUNC('week', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__week - , DATE_TRUNC('month', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__month - , DATE_TRUNC('quarter', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__quarter - , DATE_TRUNC('year', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__year - , EXTRACT(year FROM users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__extract_year - , EXTRACT(quarter FROM users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__extract_quarter - , EXTRACT(month FROM users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__extract_month - , EXTRACT(day FROM users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM users_ds_source_src_10007.ds_partitioned) = 0 THEN EXTRACT(dow FROM users_ds_source_src_10007.ds_partitioned) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_10007.ds_partitioned) END AS user__ds_partitioned__extract_dow - , EXTRACT(doy FROM users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__extract_doy - , users_ds_source_src_10007.home_state AS user__home_state - , users_ds_source_src_10007.user_id AS user - FROM ***************************.dim_users users_ds_source_src_10007 + DATE_TRUNC('day', users_ds_source_src_10008.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_10008.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_10008.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_10008.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_10008.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_10008.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_10008.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_10008.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_10008.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_10008.ds) = 0 THEN EXTRACT(dow FROM users_ds_source_src_10008.ds) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_10008.ds) END AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_10008.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_10008.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_10008.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_10008.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_10008.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_10008.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_10008.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_10008.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_10008.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_10008.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_10008.created_at) = 0 THEN EXTRACT(dow FROM users_ds_source_src_10008.created_at) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_10008.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_10008.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_10008.ds_partitioned) = 0 THEN EXTRACT(dow FROM users_ds_source_src_10008.ds_partitioned) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_10008.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_10008.home_state + , DATE_TRUNC('day', users_ds_source_src_10008.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_10008.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_10008.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_10008.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_10008.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_10008.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_10008.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_10008.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_10008.ds) AS user__ds__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_10008.ds) = 0 THEN EXTRACT(dow FROM users_ds_source_src_10008.ds) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_10008.ds) END AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_10008.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_10008.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_10008.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_10008.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_10008.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_10008.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_10008.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_10008.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_10008.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_10008.created_at) AS user__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_10008.created_at) = 0 THEN EXTRACT(dow FROM users_ds_source_src_10008.created_at) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_10008.created_at) END AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_10008.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_10008.ds_partitioned) = 0 THEN EXTRACT(dow FROM users_ds_source_src_10008.ds_partitioned) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_10008.ds_partitioned) END AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_10008.home_state AS user__home_state + , users_ds_source_src_10008.user_id AS user + FROM ***************************.dim_users users_ds_source_src_10008 ) subq_3 ) subq_4 ON diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_partitioned_join__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_partitioned_join__plan0_optimized.sql index c15982d861..b52d743037 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_partitioned_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_partitioned_join__plan0_optimized.sql @@ -4,7 +4,7 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - users_ds_source_src_10007.home_state AS user__home_state + users_ds_source_src_10008.home_state AS user__home_state , SUM(subq_10.identity_verifications) AS identity_verifications FROM ( -- Read Elements From Semantic Model 'id_verifications' @@ -15,15 +15,15 @@ FROM ( DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , user_id AS user , 1 AS identity_verifications - FROM ***************************.fct_id_verifications id_verifications_src_10003 + FROM ***************************.fct_id_verifications id_verifications_src_10004 ) subq_10 LEFT OUTER JOIN - ***************************.dim_users users_ds_source_src_10007 + ***************************.dim_users users_ds_source_src_10008 ON ( - subq_10.user = users_ds_source_src_10007.user_id + subq_10.user = users_ds_source_src_10008.user_id ) AND ( - subq_10.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_10007.ds_partitioned) + subq_10.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_10008.ds_partitioned) ) GROUP BY - users_ds_source_src_10007.home_state + users_ds_source_src_10008.home_state diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_distinct_values__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_distinct_values__plan0.sql index 6df070d71c..cbb522ba2a 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_distinct_values__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_distinct_values__plan0.sql @@ -69,62 +69,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_0 WHERE listing__country_latest = 'us' ) subq_1 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_distinct_values__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_distinct_values__plan0_optimized.sql index ec0d94dac2..53c7bf823f 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_distinct_values__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_distinct_values__plan0_optimized.sql @@ -8,7 +8,7 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT country AS listing__country_latest - FROM ***************************.dim_listings_latest listings_latest_src_10004 + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_3 WHERE listing__country_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_on_join_dim__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_on_join_dim__plan0.sql index f5cf8052e8..3f89a72cfc 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_on_join_dim__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_on_join_dim__plan0.sql @@ -316,62 +316,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_3 ) subq_4 ) subq_5 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql index 19b1b78329..d00b32fb24 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql @@ -12,7 +12,7 @@ FROM ( -- ['bookings', 'booking__is_instant', 'listing__country_latest'] SELECT subq_13.booking__is_instant AS booking__is_instant - , listings_latest_src_10004.country AS listing__country_latest + , listings_latest_src_10005.country AS listing__country_latest , subq_13.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -26,9 +26,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_13 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_13.listing = listings_latest_src_10004.listing_id + subq_13.listing = listings_latest_src_10005.listing_id ) subq_18 WHERE listing__country_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_join_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_join_to_scd_dimension__plan0.sql index 06b2beab7f..96e202dc14 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_join_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_join_to_scd_dimension__plan0.sql @@ -142,87 +142,87 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_10015.booking_value - , bookings_source_src_10015.guest_id AS bookers - , bookings_source_src_10015.booking_value AS average_booking_value - , bookings_source_src_10015.booking_value AS booking_payments - , bookings_source_src_10015.is_instant - , DATE_TRUNC('day', bookings_source_src_10015.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_10015.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_10015.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_10015.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_10015.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_10015.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_10015.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_10015.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_10015.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS paid_at__extract_doy - , bookings_source_src_10015.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_10015.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_10015.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_10015.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_10015.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_10015.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_10015.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_10015.listing_id AS listing - , bookings_source_src_10015.guest_id AS guest - , bookings_source_src_10015.host_id AS host - , bookings_source_src_10015.guest_id AS user - , bookings_source_src_10015.listing_id AS booking__listing - , bookings_source_src_10015.guest_id AS booking__guest - , bookings_source_src_10015.host_id AS booking__host - , bookings_source_src_10015.guest_id AS booking__user - FROM ***************************.fct_bookings bookings_source_src_10015 + , bookings_source_src_10017.booking_value + , bookings_source_src_10017.guest_id AS bookers + , bookings_source_src_10017.booking_value AS average_booking_value + , bookings_source_src_10017.booking_value AS booking_payments + , bookings_source_src_10017.is_instant + , DATE_TRUNC('day', bookings_source_src_10017.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_10017.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_10017.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_10017.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_10017.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_10017.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_10017.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_10017.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_10017.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_10017.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_10017.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_10017.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.paid_at) AS paid_at__extract_doy + , bookings_source_src_10017.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_10017.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_10017.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_10017.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_10017.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_10017.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_10017.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_10017.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_10017.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_10017.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_10017.listing_id AS listing + , bookings_source_src_10017.guest_id AS guest + , bookings_source_src_10017.host_id AS host + , bookings_source_src_10017.guest_id AS user + , bookings_source_src_10017.listing_id AS booking__listing + , bookings_source_src_10017.guest_id AS booking__guest + , bookings_source_src_10017.host_id AS booking__host + , bookings_source_src_10017.guest_id AS booking__user + FROM ***************************.fct_bookings bookings_source_src_10017 ) subq_0 ) subq_1 ) subq_2 @@ -237,60 +237,60 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'listings' SELECT - listings_src_10017.active_from AS window_start__day - , DATE_TRUNC('week', listings_src_10017.active_from) AS window_start__week - , DATE_TRUNC('month', listings_src_10017.active_from) AS window_start__month - , DATE_TRUNC('quarter', listings_src_10017.active_from) AS window_start__quarter - , DATE_TRUNC('year', listings_src_10017.active_from) AS window_start__year - , EXTRACT(year FROM listings_src_10017.active_from) AS window_start__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_from) AS window_start__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_from) AS window_start__extract_month - , EXTRACT(day FROM listings_src_10017.active_from) AS window_start__extract_day - , EXTRACT(dayofweekiso FROM listings_src_10017.active_from) AS window_start__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_from) AS window_start__extract_doy - , listings_src_10017.active_to AS window_end__day - , DATE_TRUNC('week', listings_src_10017.active_to) AS window_end__week - , DATE_TRUNC('month', listings_src_10017.active_to) AS window_end__month - , DATE_TRUNC('quarter', listings_src_10017.active_to) AS window_end__quarter - , DATE_TRUNC('year', listings_src_10017.active_to) AS window_end__year - , EXTRACT(year FROM listings_src_10017.active_to) AS window_end__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_to) AS window_end__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_to) AS window_end__extract_month - , EXTRACT(day FROM listings_src_10017.active_to) AS window_end__extract_day - , EXTRACT(dayofweekiso FROM listings_src_10017.active_to) AS window_end__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_to) AS window_end__extract_doy - , listings_src_10017.country - , listings_src_10017.is_lux - , listings_src_10017.capacity - , listings_src_10017.active_from AS listing__window_start__day - , DATE_TRUNC('week', listings_src_10017.active_from) AS listing__window_start__week - , DATE_TRUNC('month', listings_src_10017.active_from) AS listing__window_start__month - , DATE_TRUNC('quarter', listings_src_10017.active_from) AS listing__window_start__quarter - , DATE_TRUNC('year', listings_src_10017.active_from) AS listing__window_start__year - , EXTRACT(year FROM listings_src_10017.active_from) AS listing__window_start__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_from) AS listing__window_start__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_from) AS listing__window_start__extract_month - , EXTRACT(day FROM listings_src_10017.active_from) AS listing__window_start__extract_day - , EXTRACT(dayofweekiso FROM listings_src_10017.active_from) AS listing__window_start__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_from) AS listing__window_start__extract_doy - , listings_src_10017.active_to AS listing__window_end__day - , DATE_TRUNC('week', listings_src_10017.active_to) AS listing__window_end__week - , DATE_TRUNC('month', listings_src_10017.active_to) AS listing__window_end__month - , DATE_TRUNC('quarter', listings_src_10017.active_to) AS listing__window_end__quarter - , DATE_TRUNC('year', listings_src_10017.active_to) AS listing__window_end__year - , EXTRACT(year FROM listings_src_10017.active_to) AS listing__window_end__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_to) AS listing__window_end__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_to) AS listing__window_end__extract_month - , EXTRACT(day FROM listings_src_10017.active_to) AS listing__window_end__extract_day - , EXTRACT(dayofweekiso FROM listings_src_10017.active_to) AS listing__window_end__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_to) AS listing__window_end__extract_doy - , listings_src_10017.country AS listing__country - , listings_src_10017.is_lux AS listing__is_lux - , listings_src_10017.capacity AS listing__capacity - , listings_src_10017.listing_id AS listing - , listings_src_10017.user_id AS user - , listings_src_10017.user_id AS listing__user - FROM ***************************.dim_listings listings_src_10017 + listings_src_10019.active_from AS window_start__day + , DATE_TRUNC('week', listings_src_10019.active_from) AS window_start__week + , DATE_TRUNC('month', listings_src_10019.active_from) AS window_start__month + , DATE_TRUNC('quarter', listings_src_10019.active_from) AS window_start__quarter + , DATE_TRUNC('year', listings_src_10019.active_from) AS window_start__year + , EXTRACT(year FROM listings_src_10019.active_from) AS window_start__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_from) AS window_start__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_from) AS window_start__extract_month + , EXTRACT(day FROM listings_src_10019.active_from) AS window_start__extract_day + , EXTRACT(dayofweekiso FROM listings_src_10019.active_from) AS window_start__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_from) AS window_start__extract_doy + , listings_src_10019.active_to AS window_end__day + , DATE_TRUNC('week', listings_src_10019.active_to) AS window_end__week + , DATE_TRUNC('month', listings_src_10019.active_to) AS window_end__month + , DATE_TRUNC('quarter', listings_src_10019.active_to) AS window_end__quarter + , DATE_TRUNC('year', listings_src_10019.active_to) AS window_end__year + , EXTRACT(year FROM listings_src_10019.active_to) AS window_end__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_to) AS window_end__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_to) AS window_end__extract_month + , EXTRACT(day FROM listings_src_10019.active_to) AS window_end__extract_day + , EXTRACT(dayofweekiso FROM listings_src_10019.active_to) AS window_end__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_to) AS window_end__extract_doy + , listings_src_10019.country + , listings_src_10019.is_lux + , listings_src_10019.capacity + , listings_src_10019.active_from AS listing__window_start__day + , DATE_TRUNC('week', listings_src_10019.active_from) AS listing__window_start__week + , DATE_TRUNC('month', listings_src_10019.active_from) AS listing__window_start__month + , DATE_TRUNC('quarter', listings_src_10019.active_from) AS listing__window_start__quarter + , DATE_TRUNC('year', listings_src_10019.active_from) AS listing__window_start__year + , EXTRACT(year FROM listings_src_10019.active_from) AS listing__window_start__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_from) AS listing__window_start__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_from) AS listing__window_start__extract_month + , EXTRACT(day FROM listings_src_10019.active_from) AS listing__window_start__extract_day + , EXTRACT(dayofweekiso FROM listings_src_10019.active_from) AS listing__window_start__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_from) AS listing__window_start__extract_doy + , listings_src_10019.active_to AS listing__window_end__day + , DATE_TRUNC('week', listings_src_10019.active_to) AS listing__window_end__week + , DATE_TRUNC('month', listings_src_10019.active_to) AS listing__window_end__month + , DATE_TRUNC('quarter', listings_src_10019.active_to) AS listing__window_end__quarter + , DATE_TRUNC('year', listings_src_10019.active_to) AS listing__window_end__year + , EXTRACT(year FROM listings_src_10019.active_to) AS listing__window_end__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_to) AS listing__window_end__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_to) AS listing__window_end__extract_month + , EXTRACT(day FROM listings_src_10019.active_to) AS listing__window_end__extract_day + , EXTRACT(dayofweekiso FROM listings_src_10019.active_to) AS listing__window_end__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_to) AS listing__window_end__extract_doy + , listings_src_10019.country AS listing__country + , listings_src_10019.is_lux AS listing__is_lux + , listings_src_10019.capacity AS listing__capacity + , listings_src_10019.listing_id AS listing + , listings_src_10019.user_id AS user + , listings_src_10019.user_id AS listing__user + FROM ***************************.dim_listings listings_src_10019 ) subq_3 ) subq_4 ON diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_join_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_join_to_scd_dimension__plan0_optimized.sql index db1199fc2e..662445e5ef 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_join_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_join_to_scd_dimension__plan0_optimized.sql @@ -12,7 +12,7 @@ FROM ( -- ['bookings', 'listing__capacity', 'metric_time__day'] SELECT subq_12.metric_time__day AS metric_time__day - , listings_src_10017.capacity AS listing__capacity + , listings_src_10019.capacity AS listing__capacity , subq_12.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -23,21 +23,21 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_10015 + FROM ***************************.fct_bookings bookings_source_src_10017 ) subq_12 LEFT OUTER JOIN - ***************************.dim_listings listings_src_10017 + ***************************.dim_listings listings_src_10019 ON ( - subq_12.listing = listings_src_10017.listing_id + subq_12.listing = listings_src_10019.listing_id ) AND ( ( - subq_12.metric_time__day >= listings_src_10017.active_from + subq_12.metric_time__day >= listings_src_10019.active_from ) AND ( ( - subq_12.metric_time__day < listings_src_10017.active_to + subq_12.metric_time__day < listings_src_10019.active_to ) OR ( - listings_src_10017.active_to IS NULL + listings_src_10019.active_to IS NULL ) ) ) diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_local_dimension_using_local_entity__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_local_dimension_using_local_entity__plan0.sql index 58fecf6116..ae6a4e2dc5 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_local_dimension_using_local_entity__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_local_dimension_using_local_entity__plan0.sql @@ -87,62 +87,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_0 ) subq_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_local_dimension_using_local_entity__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_local_dimension_using_local_entity__plan0_optimized.sql index f7932552c3..2c5690447e 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_local_dimension_using_local_entity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_local_dimension_using_local_entity__plan0_optimized.sql @@ -11,7 +11,7 @@ FROM ( SELECT country AS listing__country_latest , 1 AS listings - FROM ***************************.dim_listings_latest listings_latest_src_10004 + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_6 GROUP BY listing__country_latest diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0.sql index df76282051..099528af8a 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0.sql @@ -328,62 +328,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_3 ) subq_4 ) subq_5 @@ -717,62 +717,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_15 ) subq_16 ) subq_17 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0_optimized.sql index 3c0c641be9..5581a37a67 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0_optimized.sql @@ -24,13 +24,13 @@ FROM ( -- ['average_booking_value', 'listing__is_lux_latest', 'metric_time__day'] SELECT DATE_TRUNC('day', bookings_source_src_10001.ds) AS metric_time__day - , listings_latest_src_10004.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest , bookings_source_src_10001.booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_10001 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - bookings_source_src_10001.listing_id = listings_latest_src_10004.listing_id + bookings_source_src_10001.listing_id = listings_latest_src_10005.listing_id ) subq_37 WHERE listing__is_lux_latest GROUP BY @@ -51,7 +51,7 @@ FROM ( -- ['bookings', 'listing__is_lux_latest', 'metric_time__day'] SELECT subq_44.metric_time__day AS metric_time__day - , listings_latest_src_10004.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest , subq_44.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -65,9 +65,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_44 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + ***************************.dim_listings_latest listings_latest_src_10005 ON - subq_44.listing = listings_latest_src_10004.listing_id + subq_44.listing = listings_latest_src_10005.listing_id ) subq_49 WHERE listing__is_lux_latest GROUP BY diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql index 11a93dd97b..b28d4d4781 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql @@ -304,62 +304,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_5 ) subq_6 ) subq_7 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql index bd5b5c24ee..1e16df6c0d 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql @@ -22,5 +22,5 @@ CROSS JOIN ( -- Compute Metrics via Expressions SELECT SUM(1) AS listings - FROM ***************************.dim_listings_latest listings_latest_src_10004 + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_20 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0.sql index f781a35ee5..f0c6568f00 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0.sql @@ -132,87 +132,87 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_10015.booking_value - , bookings_source_src_10015.guest_id AS bookers - , bookings_source_src_10015.booking_value AS average_booking_value - , bookings_source_src_10015.booking_value AS booking_payments - , bookings_source_src_10015.is_instant - , DATE_TRUNC('day', bookings_source_src_10015.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_10015.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_10015.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_10015.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_10015.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_10015.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_10015.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_10015.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_10015.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS paid_at__extract_doy - , bookings_source_src_10015.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_10015.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_10015.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_10015.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_10015.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_10015.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_10015.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_10015.listing_id AS listing - , bookings_source_src_10015.guest_id AS guest - , bookings_source_src_10015.host_id AS host - , bookings_source_src_10015.guest_id AS user - , bookings_source_src_10015.listing_id AS booking__listing - , bookings_source_src_10015.guest_id AS booking__guest - , bookings_source_src_10015.host_id AS booking__host - , bookings_source_src_10015.guest_id AS booking__user - FROM ***************************.fct_bookings bookings_source_src_10015 + , bookings_source_src_10017.booking_value + , bookings_source_src_10017.guest_id AS bookers + , bookings_source_src_10017.booking_value AS average_booking_value + , bookings_source_src_10017.booking_value AS booking_payments + , bookings_source_src_10017.is_instant + , DATE_TRUNC('day', bookings_source_src_10017.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_10017.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_10017.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_10017.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_10017.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_10017.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_10017.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_10017.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_10017.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_10017.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_10017.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_10017.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.paid_at) AS paid_at__extract_doy + , bookings_source_src_10017.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_10017.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_10017.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_10017.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_10017.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_10017.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_10017.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_10017.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_10017.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_10017.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_10017.listing_id AS listing + , bookings_source_src_10017.guest_id AS guest + , bookings_source_src_10017.host_id AS host + , bookings_source_src_10017.guest_id AS user + , bookings_source_src_10017.listing_id AS booking__listing + , bookings_source_src_10017.guest_id AS booking__guest + , bookings_source_src_10017.host_id AS booking__host + , bookings_source_src_10017.guest_id AS booking__user + FROM ***************************.fct_bookings bookings_source_src_10017 ) subq_0 ) subq_1 ) subq_2 @@ -295,60 +295,60 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'listings' SELECT - listings_src_10017.active_from AS window_start__day - , DATE_TRUNC('week', listings_src_10017.active_from) AS window_start__week - , DATE_TRUNC('month', listings_src_10017.active_from) AS window_start__month - , DATE_TRUNC('quarter', listings_src_10017.active_from) AS window_start__quarter - , DATE_TRUNC('year', listings_src_10017.active_from) AS window_start__year - , EXTRACT(year FROM listings_src_10017.active_from) AS window_start__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_from) AS window_start__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_from) AS window_start__extract_month - , EXTRACT(day FROM listings_src_10017.active_from) AS window_start__extract_day - , EXTRACT(dayofweekiso FROM listings_src_10017.active_from) AS window_start__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_from) AS window_start__extract_doy - , listings_src_10017.active_to AS window_end__day - , DATE_TRUNC('week', listings_src_10017.active_to) AS window_end__week - , DATE_TRUNC('month', listings_src_10017.active_to) AS window_end__month - , DATE_TRUNC('quarter', listings_src_10017.active_to) AS window_end__quarter - , DATE_TRUNC('year', listings_src_10017.active_to) AS window_end__year - , EXTRACT(year FROM listings_src_10017.active_to) AS window_end__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_to) AS window_end__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_to) AS window_end__extract_month - , EXTRACT(day FROM listings_src_10017.active_to) AS window_end__extract_day - , EXTRACT(dayofweekiso FROM listings_src_10017.active_to) AS window_end__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_to) AS window_end__extract_doy - , listings_src_10017.country - , listings_src_10017.is_lux - , listings_src_10017.capacity - , listings_src_10017.active_from AS listing__window_start__day - , DATE_TRUNC('week', listings_src_10017.active_from) AS listing__window_start__week - , DATE_TRUNC('month', listings_src_10017.active_from) AS listing__window_start__month - , DATE_TRUNC('quarter', listings_src_10017.active_from) AS listing__window_start__quarter - , DATE_TRUNC('year', listings_src_10017.active_from) AS listing__window_start__year - , EXTRACT(year FROM listings_src_10017.active_from) AS listing__window_start__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_from) AS listing__window_start__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_from) AS listing__window_start__extract_month - , EXTRACT(day FROM listings_src_10017.active_from) AS listing__window_start__extract_day - , EXTRACT(dayofweekiso FROM listings_src_10017.active_from) AS listing__window_start__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_from) AS listing__window_start__extract_doy - , listings_src_10017.active_to AS listing__window_end__day - , DATE_TRUNC('week', listings_src_10017.active_to) AS listing__window_end__week - , DATE_TRUNC('month', listings_src_10017.active_to) AS listing__window_end__month - , DATE_TRUNC('quarter', listings_src_10017.active_to) AS listing__window_end__quarter - , DATE_TRUNC('year', listings_src_10017.active_to) AS listing__window_end__year - , EXTRACT(year FROM listings_src_10017.active_to) AS listing__window_end__extract_year - , EXTRACT(quarter FROM listings_src_10017.active_to) AS listing__window_end__extract_quarter - , EXTRACT(month FROM listings_src_10017.active_to) AS listing__window_end__extract_month - , EXTRACT(day FROM listings_src_10017.active_to) AS listing__window_end__extract_day - , EXTRACT(dayofweekiso FROM listings_src_10017.active_to) AS listing__window_end__extract_dow - , EXTRACT(doy FROM listings_src_10017.active_to) AS listing__window_end__extract_doy - , listings_src_10017.country AS listing__country - , listings_src_10017.is_lux AS listing__is_lux - , listings_src_10017.capacity AS listing__capacity - , listings_src_10017.listing_id AS listing - , listings_src_10017.user_id AS user - , listings_src_10017.user_id AS listing__user - FROM ***************************.dim_listings listings_src_10017 + listings_src_10019.active_from AS window_start__day + , DATE_TRUNC('week', listings_src_10019.active_from) AS window_start__week + , DATE_TRUNC('month', listings_src_10019.active_from) AS window_start__month + , DATE_TRUNC('quarter', listings_src_10019.active_from) AS window_start__quarter + , DATE_TRUNC('year', listings_src_10019.active_from) AS window_start__year + , EXTRACT(year FROM listings_src_10019.active_from) AS window_start__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_from) AS window_start__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_from) AS window_start__extract_month + , EXTRACT(day FROM listings_src_10019.active_from) AS window_start__extract_day + , EXTRACT(dayofweekiso FROM listings_src_10019.active_from) AS window_start__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_from) AS window_start__extract_doy + , listings_src_10019.active_to AS window_end__day + , DATE_TRUNC('week', listings_src_10019.active_to) AS window_end__week + , DATE_TRUNC('month', listings_src_10019.active_to) AS window_end__month + , DATE_TRUNC('quarter', listings_src_10019.active_to) AS window_end__quarter + , DATE_TRUNC('year', listings_src_10019.active_to) AS window_end__year + , EXTRACT(year FROM listings_src_10019.active_to) AS window_end__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_to) AS window_end__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_to) AS window_end__extract_month + , EXTRACT(day FROM listings_src_10019.active_to) AS window_end__extract_day + , EXTRACT(dayofweekiso FROM listings_src_10019.active_to) AS window_end__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_to) AS window_end__extract_doy + , listings_src_10019.country + , listings_src_10019.is_lux + , listings_src_10019.capacity + , listings_src_10019.active_from AS listing__window_start__day + , DATE_TRUNC('week', listings_src_10019.active_from) AS listing__window_start__week + , DATE_TRUNC('month', listings_src_10019.active_from) AS listing__window_start__month + , DATE_TRUNC('quarter', listings_src_10019.active_from) AS listing__window_start__quarter + , DATE_TRUNC('year', listings_src_10019.active_from) AS listing__window_start__year + , EXTRACT(year FROM listings_src_10019.active_from) AS listing__window_start__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_from) AS listing__window_start__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_from) AS listing__window_start__extract_month + , EXTRACT(day FROM listings_src_10019.active_from) AS listing__window_start__extract_day + , EXTRACT(dayofweekiso FROM listings_src_10019.active_from) AS listing__window_start__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_from) AS listing__window_start__extract_doy + , listings_src_10019.active_to AS listing__window_end__day + , DATE_TRUNC('week', listings_src_10019.active_to) AS listing__window_end__week + , DATE_TRUNC('month', listings_src_10019.active_to) AS listing__window_end__month + , DATE_TRUNC('quarter', listings_src_10019.active_to) AS listing__window_end__quarter + , DATE_TRUNC('year', listings_src_10019.active_to) AS listing__window_end__year + , EXTRACT(year FROM listings_src_10019.active_to) AS listing__window_end__extract_year + , EXTRACT(quarter FROM listings_src_10019.active_to) AS listing__window_end__extract_quarter + , EXTRACT(month FROM listings_src_10019.active_to) AS listing__window_end__extract_month + , EXTRACT(day FROM listings_src_10019.active_to) AS listing__window_end__extract_day + , EXTRACT(dayofweekiso FROM listings_src_10019.active_to) AS listing__window_end__extract_dow + , EXTRACT(doy FROM listings_src_10019.active_to) AS listing__window_end__extract_doy + , listings_src_10019.country AS listing__country + , listings_src_10019.is_lux AS listing__is_lux + , listings_src_10019.capacity AS listing__capacity + , listings_src_10019.listing_id AS listing + , listings_src_10019.user_id AS user + , listings_src_10019.user_id AS listing__user + FROM ***************************.dim_listings listings_src_10019 ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: @@ -406,32 +406,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_10021.ds) AS ds__day - , DATE_TRUNC('week', users_latest_src_10021.ds) AS ds__week - , DATE_TRUNC('month', users_latest_src_10021.ds) AS ds__month - , DATE_TRUNC('quarter', users_latest_src_10021.ds) AS ds__quarter - , DATE_TRUNC('year', users_latest_src_10021.ds) AS ds__year - , EXTRACT(year FROM users_latest_src_10021.ds) AS ds__extract_year - , EXTRACT(quarter FROM users_latest_src_10021.ds) AS ds__extract_quarter - , EXTRACT(month FROM users_latest_src_10021.ds) AS ds__extract_month - , EXTRACT(day FROM users_latest_src_10021.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM users_latest_src_10021.ds) AS ds__extract_dow - , EXTRACT(doy FROM users_latest_src_10021.ds) AS ds__extract_doy - , users_latest_src_10021.home_state_latest - , DATE_TRUNC('day', users_latest_src_10021.ds) AS user__ds__day - , DATE_TRUNC('week', users_latest_src_10021.ds) AS user__ds__week - , DATE_TRUNC('month', users_latest_src_10021.ds) AS user__ds__month - , DATE_TRUNC('quarter', users_latest_src_10021.ds) AS user__ds__quarter - , DATE_TRUNC('year', users_latest_src_10021.ds) AS user__ds__year - , EXTRACT(year FROM users_latest_src_10021.ds) AS user__ds__extract_year - , EXTRACT(quarter FROM users_latest_src_10021.ds) AS user__ds__extract_quarter - , EXTRACT(month FROM users_latest_src_10021.ds) AS user__ds__extract_month - , EXTRACT(day FROM users_latest_src_10021.ds) AS user__ds__extract_day - , EXTRACT(dayofweekiso FROM users_latest_src_10021.ds) AS user__ds__extract_dow - , EXTRACT(doy FROM users_latest_src_10021.ds) AS user__ds__extract_doy - , users_latest_src_10021.home_state_latest AS user__home_state_latest - , users_latest_src_10021.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_10021 + DATE_TRUNC('day', users_latest_src_10023.ds) AS ds__day + , DATE_TRUNC('week', users_latest_src_10023.ds) AS ds__week + , DATE_TRUNC('month', users_latest_src_10023.ds) AS ds__month + , DATE_TRUNC('quarter', users_latest_src_10023.ds) AS ds__quarter + , DATE_TRUNC('year', users_latest_src_10023.ds) AS ds__year + , EXTRACT(year FROM users_latest_src_10023.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_latest_src_10023.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_latest_src_10023.ds) AS ds__extract_month + , EXTRACT(day FROM users_latest_src_10023.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM users_latest_src_10023.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_latest_src_10023.ds) AS ds__extract_doy + , users_latest_src_10023.home_state_latest + , DATE_TRUNC('day', users_latest_src_10023.ds) AS user__ds__day + , DATE_TRUNC('week', users_latest_src_10023.ds) AS user__ds__week + , DATE_TRUNC('month', users_latest_src_10023.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_latest_src_10023.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_latest_src_10023.ds) AS user__ds__year + , EXTRACT(year FROM users_latest_src_10023.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_latest_src_10023.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_latest_src_10023.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_latest_src_10023.ds) AS user__ds__extract_day + , EXTRACT(dayofweekiso FROM users_latest_src_10023.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_latest_src_10023.ds) AS user__ds__extract_doy + , users_latest_src_10023.home_state_latest AS user__home_state_latest + , users_latest_src_10023.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_10023 ) subq_4 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0_optimized.sql index aa2ad14d34..afba0439d0 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0_optimized.sql @@ -16,22 +16,22 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_10015 + FROM ***************************.fct_bookings bookings_source_src_10017 ) subq_13 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: -- ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] SELECT - listings_src_10017.active_from AS window_start__day - , listings_src_10017.active_to AS window_end__day - , listings_src_10017.listing_id AS listing - , users_latest_src_10021.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings listings_src_10017 + listings_src_10019.active_from AS window_start__day + , listings_src_10019.active_to AS window_end__day + , listings_src_10019.listing_id AS listing + , users_latest_src_10023.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings listings_src_10019 LEFT OUTER JOIN - ***************************.dim_users_latest users_latest_src_10021 + ***************************.dim_users_latest users_latest_src_10023 ON - listings_src_10017.user_id = users_latest_src_10021.user_id + listings_src_10019.user_id = users_latest_src_10023.user_id ) subq_18 ON ( diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0.sql index c3313c8a1a..ad14d87d2b 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0.sql @@ -132,87 +132,87 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_10015.booking_value - , bookings_source_src_10015.guest_id AS bookers - , bookings_source_src_10015.booking_value AS average_booking_value - , bookings_source_src_10015.booking_value AS booking_payments - , bookings_source_src_10015.is_instant - , DATE_TRUNC('day', bookings_source_src_10015.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_10015.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_10015.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_10015.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_10015.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_10015.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_10015.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_10015.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_10015.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS paid_at__extract_doy - , bookings_source_src_10015.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_10015.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_10015.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_10015.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_10015.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_10015.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_10015.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_10015.listing_id AS listing - , bookings_source_src_10015.guest_id AS guest - , bookings_source_src_10015.host_id AS host - , bookings_source_src_10015.guest_id AS user - , bookings_source_src_10015.listing_id AS booking__listing - , bookings_source_src_10015.guest_id AS booking__guest - , bookings_source_src_10015.host_id AS booking__host - , bookings_source_src_10015.guest_id AS booking__user - FROM ***************************.fct_bookings bookings_source_src_10015 + , bookings_source_src_10017.booking_value + , bookings_source_src_10017.guest_id AS bookers + , bookings_source_src_10017.booking_value AS average_booking_value + , bookings_source_src_10017.booking_value AS booking_payments + , bookings_source_src_10017.is_instant + , DATE_TRUNC('day', bookings_source_src_10017.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_10017.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_10017.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_10017.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_10017.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_10017.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_10017.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_10017.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_10017.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_10017.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_10017.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_10017.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.paid_at) AS paid_at__extract_doy + , bookings_source_src_10017.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_10017.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_10017.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_10017.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_10017.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_10017.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_10017.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_10017.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_10017.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_10017.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_10017.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_10017.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_10017.listing_id AS listing + , bookings_source_src_10017.guest_id AS guest + , bookings_source_src_10017.host_id AS host + , bookings_source_src_10017.guest_id AS user + , bookings_source_src_10017.listing_id AS booking__listing + , bookings_source_src_10017.guest_id AS booking__guest + , bookings_source_src_10017.host_id AS booking__host + , bookings_source_src_10017.guest_id AS booking__user + FROM ***************************.fct_bookings bookings_source_src_10017 ) subq_0 ) subq_1 ) subq_2 @@ -259,10 +259,10 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'lux_listing_mapping' SELECT - lux_listing_mapping_src_10018.listing_id AS listing - , lux_listing_mapping_src_10018.lux_listing_id AS lux_listing - , lux_listing_mapping_src_10018.lux_listing_id AS listing__lux_listing - FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_10018 + lux_listing_mapping_src_10020.listing_id AS listing + , lux_listing_mapping_src_10020.lux_listing_id AS lux_listing + , lux_listing_mapping_src_10020.lux_listing_id AS listing__lux_listing + FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_10020 ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: @@ -364,54 +364,54 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'lux_listings' SELECT - lux_listings_src_10019.valid_from AS window_start__day - , DATE_TRUNC('week', lux_listings_src_10019.valid_from) AS window_start__week - , DATE_TRUNC('month', lux_listings_src_10019.valid_from) AS window_start__month - , DATE_TRUNC('quarter', lux_listings_src_10019.valid_from) AS window_start__quarter - , DATE_TRUNC('year', lux_listings_src_10019.valid_from) AS window_start__year - , EXTRACT(year FROM lux_listings_src_10019.valid_from) AS window_start__extract_year - , EXTRACT(quarter FROM lux_listings_src_10019.valid_from) AS window_start__extract_quarter - , EXTRACT(month FROM lux_listings_src_10019.valid_from) AS window_start__extract_month - , EXTRACT(day FROM lux_listings_src_10019.valid_from) AS window_start__extract_day - , EXTRACT(dayofweekiso FROM lux_listings_src_10019.valid_from) AS window_start__extract_dow - , EXTRACT(doy FROM lux_listings_src_10019.valid_from) AS window_start__extract_doy - , lux_listings_src_10019.valid_to AS window_end__day - , DATE_TRUNC('week', lux_listings_src_10019.valid_to) AS window_end__week - , DATE_TRUNC('month', lux_listings_src_10019.valid_to) AS window_end__month - , DATE_TRUNC('quarter', lux_listings_src_10019.valid_to) AS window_end__quarter - , DATE_TRUNC('year', lux_listings_src_10019.valid_to) AS window_end__year - , EXTRACT(year FROM lux_listings_src_10019.valid_to) AS window_end__extract_year - , EXTRACT(quarter FROM lux_listings_src_10019.valid_to) AS window_end__extract_quarter - , EXTRACT(month FROM lux_listings_src_10019.valid_to) AS window_end__extract_month - , EXTRACT(day FROM lux_listings_src_10019.valid_to) AS window_end__extract_day - , EXTRACT(dayofweekiso FROM lux_listings_src_10019.valid_to) AS window_end__extract_dow - , EXTRACT(doy FROM lux_listings_src_10019.valid_to) AS window_end__extract_doy - , lux_listings_src_10019.is_confirmed_lux - , lux_listings_src_10019.valid_from AS lux_listing__window_start__day - , DATE_TRUNC('week', lux_listings_src_10019.valid_from) AS lux_listing__window_start__week - , DATE_TRUNC('month', lux_listings_src_10019.valid_from) AS lux_listing__window_start__month - , DATE_TRUNC('quarter', lux_listings_src_10019.valid_from) AS lux_listing__window_start__quarter - , DATE_TRUNC('year', lux_listings_src_10019.valid_from) AS lux_listing__window_start__year - , EXTRACT(year FROM lux_listings_src_10019.valid_from) AS lux_listing__window_start__extract_year - , EXTRACT(quarter FROM lux_listings_src_10019.valid_from) AS lux_listing__window_start__extract_quarter - , EXTRACT(month FROM lux_listings_src_10019.valid_from) AS lux_listing__window_start__extract_month - , EXTRACT(day FROM lux_listings_src_10019.valid_from) AS lux_listing__window_start__extract_day - , EXTRACT(dayofweekiso FROM lux_listings_src_10019.valid_from) AS lux_listing__window_start__extract_dow - , EXTRACT(doy FROM lux_listings_src_10019.valid_from) AS lux_listing__window_start__extract_doy - , lux_listings_src_10019.valid_to AS lux_listing__window_end__day - , DATE_TRUNC('week', lux_listings_src_10019.valid_to) AS lux_listing__window_end__week - , DATE_TRUNC('month', lux_listings_src_10019.valid_to) AS lux_listing__window_end__month - , DATE_TRUNC('quarter', lux_listings_src_10019.valid_to) AS lux_listing__window_end__quarter - , DATE_TRUNC('year', lux_listings_src_10019.valid_to) AS lux_listing__window_end__year - , EXTRACT(year FROM lux_listings_src_10019.valid_to) AS lux_listing__window_end__extract_year - , EXTRACT(quarter FROM lux_listings_src_10019.valid_to) AS lux_listing__window_end__extract_quarter - , EXTRACT(month FROM lux_listings_src_10019.valid_to) AS lux_listing__window_end__extract_month - , EXTRACT(day FROM lux_listings_src_10019.valid_to) AS lux_listing__window_end__extract_day - , EXTRACT(dayofweekiso FROM lux_listings_src_10019.valid_to) AS lux_listing__window_end__extract_dow - , EXTRACT(doy FROM lux_listings_src_10019.valid_to) AS lux_listing__window_end__extract_doy - , lux_listings_src_10019.is_confirmed_lux AS lux_listing__is_confirmed_lux - , lux_listings_src_10019.lux_listing_id AS lux_listing - FROM ***************************.dim_lux_listings lux_listings_src_10019 + lux_listings_src_10021.valid_from AS window_start__day + , DATE_TRUNC('week', lux_listings_src_10021.valid_from) AS window_start__week + , DATE_TRUNC('month', lux_listings_src_10021.valid_from) AS window_start__month + , DATE_TRUNC('quarter', lux_listings_src_10021.valid_from) AS window_start__quarter + , DATE_TRUNC('year', lux_listings_src_10021.valid_from) AS window_start__year + , EXTRACT(year FROM lux_listings_src_10021.valid_from) AS window_start__extract_year + , EXTRACT(quarter FROM lux_listings_src_10021.valid_from) AS window_start__extract_quarter + , EXTRACT(month FROM lux_listings_src_10021.valid_from) AS window_start__extract_month + , EXTRACT(day FROM lux_listings_src_10021.valid_from) AS window_start__extract_day + , EXTRACT(dayofweekiso FROM lux_listings_src_10021.valid_from) AS window_start__extract_dow + , EXTRACT(doy FROM lux_listings_src_10021.valid_from) AS window_start__extract_doy + , lux_listings_src_10021.valid_to AS window_end__day + , DATE_TRUNC('week', lux_listings_src_10021.valid_to) AS window_end__week + , DATE_TRUNC('month', lux_listings_src_10021.valid_to) AS window_end__month + , DATE_TRUNC('quarter', lux_listings_src_10021.valid_to) AS window_end__quarter + , DATE_TRUNC('year', lux_listings_src_10021.valid_to) AS window_end__year + , EXTRACT(year FROM lux_listings_src_10021.valid_to) AS window_end__extract_year + , EXTRACT(quarter FROM lux_listings_src_10021.valid_to) AS window_end__extract_quarter + , EXTRACT(month FROM lux_listings_src_10021.valid_to) AS window_end__extract_month + , EXTRACT(day FROM lux_listings_src_10021.valid_to) AS window_end__extract_day + , EXTRACT(dayofweekiso FROM lux_listings_src_10021.valid_to) AS window_end__extract_dow + , EXTRACT(doy FROM lux_listings_src_10021.valid_to) AS window_end__extract_doy + , lux_listings_src_10021.is_confirmed_lux + , lux_listings_src_10021.valid_from AS lux_listing__window_start__day + , DATE_TRUNC('week', lux_listings_src_10021.valid_from) AS lux_listing__window_start__week + , DATE_TRUNC('month', lux_listings_src_10021.valid_from) AS lux_listing__window_start__month + , DATE_TRUNC('quarter', lux_listings_src_10021.valid_from) AS lux_listing__window_start__quarter + , DATE_TRUNC('year', lux_listings_src_10021.valid_from) AS lux_listing__window_start__year + , EXTRACT(year FROM lux_listings_src_10021.valid_from) AS lux_listing__window_start__extract_year + , EXTRACT(quarter FROM lux_listings_src_10021.valid_from) AS lux_listing__window_start__extract_quarter + , EXTRACT(month FROM lux_listings_src_10021.valid_from) AS lux_listing__window_start__extract_month + , EXTRACT(day FROM lux_listings_src_10021.valid_from) AS lux_listing__window_start__extract_day + , EXTRACT(dayofweekiso FROM lux_listings_src_10021.valid_from) AS lux_listing__window_start__extract_dow + , EXTRACT(doy FROM lux_listings_src_10021.valid_from) AS lux_listing__window_start__extract_doy + , lux_listings_src_10021.valid_to AS lux_listing__window_end__day + , DATE_TRUNC('week', lux_listings_src_10021.valid_to) AS lux_listing__window_end__week + , DATE_TRUNC('month', lux_listings_src_10021.valid_to) AS lux_listing__window_end__month + , DATE_TRUNC('quarter', lux_listings_src_10021.valid_to) AS lux_listing__window_end__quarter + , DATE_TRUNC('year', lux_listings_src_10021.valid_to) AS lux_listing__window_end__year + , EXTRACT(year FROM lux_listings_src_10021.valid_to) AS lux_listing__window_end__extract_year + , EXTRACT(quarter FROM lux_listings_src_10021.valid_to) AS lux_listing__window_end__extract_quarter + , EXTRACT(month FROM lux_listings_src_10021.valid_to) AS lux_listing__window_end__extract_month + , EXTRACT(day FROM lux_listings_src_10021.valid_to) AS lux_listing__window_end__extract_day + , EXTRACT(dayofweekiso FROM lux_listings_src_10021.valid_to) AS lux_listing__window_end__extract_dow + , EXTRACT(doy FROM lux_listings_src_10021.valid_to) AS lux_listing__window_end__extract_doy + , lux_listings_src_10021.is_confirmed_lux AS lux_listing__is_confirmed_lux + , lux_listings_src_10021.lux_listing_id AS lux_listing + FROM ***************************.dim_lux_listings lux_listings_src_10021 ) subq_4 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0_optimized.sql index add7e259ab..16470814e6 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0_optimized.sql @@ -16,7 +16,7 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_10015 + FROM ***************************.fct_bookings bookings_source_src_10017 ) subq_13 LEFT OUTER JOIN ( -- Join Standard Outputs @@ -26,15 +26,15 @@ LEFT OUTER JOIN ( -- 'lux_listing__window_end__day', -- 'listing'] SELECT - lux_listings_src_10019.valid_from AS lux_listing__window_start__day - , lux_listings_src_10019.valid_to AS lux_listing__window_end__day - , lux_listing_mapping_src_10018.listing_id AS listing - , lux_listings_src_10019.is_confirmed_lux AS lux_listing__is_confirmed_lux - FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_10018 + lux_listings_src_10021.valid_from AS lux_listing__window_start__day + , lux_listings_src_10021.valid_to AS lux_listing__window_end__day + , lux_listing_mapping_src_10020.listing_id AS listing + , lux_listings_src_10021.is_confirmed_lux AS lux_listing__is_confirmed_lux + FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_10020 LEFT OUTER JOIN - ***************************.dim_lux_listings lux_listings_src_10019 + ***************************.dim_lux_listings lux_listings_src_10021 ON - lux_listing_mapping_src_10018.lux_listing_id = lux_listings_src_10019.lux_listing_id + lux_listing_mapping_src_10020.lux_listing_id = lux_listings_src_10021.lux_listing_id ) subq_18 ON ( diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0.sql index 39e32ead71..e6ab95bc3d 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0.sql @@ -93,55 +93,55 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'account_month_txns' SELECT - account_month_txns_src_10010.txn_count - , DATE_TRUNC('day', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', account_month_txns_src_10010.ds) AS ds__day - , DATE_TRUNC('week', account_month_txns_src_10010.ds) AS ds__week - , DATE_TRUNC('month', account_month_txns_src_10010.ds) AS ds__month - , DATE_TRUNC('quarter', account_month_txns_src_10010.ds) AS ds__quarter - , DATE_TRUNC('year', account_month_txns_src_10010.ds) AS ds__year - , EXTRACT(year FROM account_month_txns_src_10010.ds) AS ds__extract_year - , EXTRACT(quarter FROM account_month_txns_src_10010.ds) AS ds__extract_quarter - , EXTRACT(month FROM account_month_txns_src_10010.ds) AS ds__extract_month - , EXTRACT(day FROM account_month_txns_src_10010.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM account_month_txns_src_10010.ds) AS ds__extract_dow - , EXTRACT(doy FROM account_month_txns_src_10010.ds) AS ds__extract_doy - , account_month_txns_src_10010.account_month - , DATE_TRUNC('day', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__day - , DATE_TRUNC('week', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__week - , DATE_TRUNC('month', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__month - , DATE_TRUNC('quarter', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__quarter - , DATE_TRUNC('year', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__year - , EXTRACT(year FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_month - , EXTRACT(day FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , DATE_TRUNC('day', account_month_txns_src_10010.ds) AS account_id__ds__day - , DATE_TRUNC('week', account_month_txns_src_10010.ds) AS account_id__ds__week - , DATE_TRUNC('month', account_month_txns_src_10010.ds) AS account_id__ds__month - , DATE_TRUNC('quarter', account_month_txns_src_10010.ds) AS account_id__ds__quarter - , DATE_TRUNC('year', account_month_txns_src_10010.ds) AS account_id__ds__year - , EXTRACT(year FROM account_month_txns_src_10010.ds) AS account_id__ds__extract_year - , EXTRACT(quarter FROM account_month_txns_src_10010.ds) AS account_id__ds__extract_quarter - , EXTRACT(month FROM account_month_txns_src_10010.ds) AS account_id__ds__extract_month - , EXTRACT(day FROM account_month_txns_src_10010.ds) AS account_id__ds__extract_day - , EXTRACT(dayofweekiso FROM account_month_txns_src_10010.ds) AS account_id__ds__extract_dow - , EXTRACT(doy FROM account_month_txns_src_10010.ds) AS account_id__ds__extract_doy - , account_month_txns_src_10010.account_month AS account_id__account_month - , account_month_txns_src_10010.account_id - FROM ***************************.account_month_txns account_month_txns_src_10010 + account_month_txns_src_10012.txn_count + , DATE_TRUNC('day', account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM account_month_txns_src_10012.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', account_month_txns_src_10012.ds) AS ds__day + , DATE_TRUNC('week', account_month_txns_src_10012.ds) AS ds__week + , DATE_TRUNC('month', account_month_txns_src_10012.ds) AS ds__month + , DATE_TRUNC('quarter', account_month_txns_src_10012.ds) AS ds__quarter + , DATE_TRUNC('year', account_month_txns_src_10012.ds) AS ds__year + , EXTRACT(year FROM account_month_txns_src_10012.ds) AS ds__extract_year + , EXTRACT(quarter FROM account_month_txns_src_10012.ds) AS ds__extract_quarter + , EXTRACT(month FROM account_month_txns_src_10012.ds) AS ds__extract_month + , EXTRACT(day FROM account_month_txns_src_10012.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM account_month_txns_src_10012.ds) AS ds__extract_dow + , EXTRACT(doy FROM account_month_txns_src_10012.ds) AS ds__extract_doy + , account_month_txns_src_10012.account_month + , DATE_TRUNC('day', account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__day + , DATE_TRUNC('week', account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__week + , DATE_TRUNC('month', account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__month + , DATE_TRUNC('quarter', account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__quarter + , DATE_TRUNC('year', account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__year + , EXTRACT(year FROM account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__extract_month + , EXTRACT(day FROM account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM account_month_txns_src_10012.ds_partitioned) AS account_id__ds_partitioned__extract_doy + , DATE_TRUNC('day', account_month_txns_src_10012.ds) AS account_id__ds__day + , DATE_TRUNC('week', account_month_txns_src_10012.ds) AS account_id__ds__week + , DATE_TRUNC('month', account_month_txns_src_10012.ds) AS account_id__ds__month + , DATE_TRUNC('quarter', account_month_txns_src_10012.ds) AS account_id__ds__quarter + , DATE_TRUNC('year', account_month_txns_src_10012.ds) AS account_id__ds__year + , EXTRACT(year FROM account_month_txns_src_10012.ds) AS account_id__ds__extract_year + , EXTRACT(quarter FROM account_month_txns_src_10012.ds) AS account_id__ds__extract_quarter + , EXTRACT(month FROM account_month_txns_src_10012.ds) AS account_id__ds__extract_month + , EXTRACT(day FROM account_month_txns_src_10012.ds) AS account_id__ds__extract_day + , EXTRACT(dayofweekiso FROM account_month_txns_src_10012.ds) AS account_id__ds__extract_dow + , EXTRACT(doy FROM account_month_txns_src_10012.ds) AS account_id__ds__extract_doy + , account_month_txns_src_10012.account_month AS account_id__account_month + , account_month_txns_src_10012.account_id + FROM ***************************.account_month_txns account_month_txns_src_10012 ) subq_0 ) subq_1 ) subq_2 @@ -212,48 +212,48 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT - bridge_table_src_10011.extra_dim - , DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_doy - , bridge_table_src_10011.extra_dim AS account_id__extra_dim - , DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__day - , DATE_TRUNC('week', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__week - , DATE_TRUNC('month', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__month - , DATE_TRUNC('quarter', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__quarter - , DATE_TRUNC('year', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , bridge_table_src_10011.extra_dim AS bridge_account__extra_dim - , DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__day - , DATE_TRUNC('week', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__week - , DATE_TRUNC('month', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__month - , DATE_TRUNC('quarter', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__quarter - , DATE_TRUNC('year', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__extract_dow - , EXTRACT(doy FROM bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__extract_doy - , bridge_table_src_10011.account_id - , bridge_table_src_10011.customer_id - , bridge_table_src_10011.customer_id AS account_id__customer_id - , bridge_table_src_10011.account_id AS bridge_account__account_id - , bridge_table_src_10011.customer_id AS bridge_account__customer_id - FROM ***************************.bridge_table bridge_table_src_10011 + bridge_table_src_10013.extra_dim + , DATE_TRUNC('day', bridge_table_src_10013.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bridge_table_src_10013.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bridge_table_src_10013.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bridge_table_src_10013.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bridge_table_src_10013.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_10013.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_10013.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_10013.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_10013.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bridge_table_src_10013.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bridge_table_src_10013.ds_partitioned) AS ds_partitioned__extract_doy + , bridge_table_src_10013.extra_dim AS account_id__extra_dim + , DATE_TRUNC('day', bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__day + , DATE_TRUNC('week', bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__week + , DATE_TRUNC('month', bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__month + , DATE_TRUNC('quarter', bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__quarter + , DATE_TRUNC('year', bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM bridge_table_src_10013.ds_partitioned) AS account_id__ds_partitioned__extract_doy + , bridge_table_src_10013.extra_dim AS bridge_account__extra_dim + , DATE_TRUNC('day', bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__day + , DATE_TRUNC('week', bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__week + , DATE_TRUNC('month', bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__month + , DATE_TRUNC('quarter', bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__quarter + , DATE_TRUNC('year', bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__extract_dow + , EXTRACT(doy FROM bridge_table_src_10013.ds_partitioned) AS bridge_account__ds_partitioned__extract_doy + , bridge_table_src_10013.account_id + , bridge_table_src_10013.customer_id + , bridge_table_src_10013.customer_id AS account_id__customer_id + , bridge_table_src_10013.account_id AS bridge_account__account_id + , bridge_table_src_10013.customer_id AS bridge_account__customer_id + FROM ***************************.bridge_table bridge_table_src_10013 ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: @@ -315,34 +315,34 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'customer_table' SELECT - customer_table_src_10013.customer_name - , customer_table_src_10013.customer_atomic_weight - , DATE_TRUNC('day', customer_table_src_10013.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', customer_table_src_10013.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', customer_table_src_10013.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', customer_table_src_10013.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', customer_table_src_10013.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_doy - , customer_table_src_10013.customer_name AS customer_id__customer_name - , customer_table_src_10013.customer_atomic_weight AS customer_id__customer_atomic_weight - , DATE_TRUNC('day', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__day - , DATE_TRUNC('week', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__week - , DATE_TRUNC('month', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__month - , DATE_TRUNC('quarter', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__quarter - , DATE_TRUNC('year', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__year - , EXTRACT(year FROM customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__extract_month - , EXTRACT(day FROM customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__extract_doy - , customer_table_src_10013.customer_id - FROM ***************************.customer_table customer_table_src_10013 + customer_table_src_10015.customer_name + , customer_table_src_10015.customer_atomic_weight + , DATE_TRUNC('day', customer_table_src_10015.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', customer_table_src_10015.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', customer_table_src_10015.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', customer_table_src_10015.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', customer_table_src_10015.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM customer_table_src_10015.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM customer_table_src_10015.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM customer_table_src_10015.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM customer_table_src_10015.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM customer_table_src_10015.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM customer_table_src_10015.ds_partitioned) AS ds_partitioned__extract_doy + , customer_table_src_10015.customer_name AS customer_id__customer_name + , customer_table_src_10015.customer_atomic_weight AS customer_id__customer_atomic_weight + , DATE_TRUNC('day', customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__day + , DATE_TRUNC('week', customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__week + , DATE_TRUNC('month', customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__month + , DATE_TRUNC('quarter', customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__quarter + , DATE_TRUNC('year', customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__year + , EXTRACT(year FROM customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__extract_month + , EXTRACT(day FROM customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM customer_table_src_10015.ds_partitioned) AS customer_id__ds_partitioned__extract_doy + , customer_table_src_10015.customer_id + FROM ***************************.customer_table customer_table_src_10015 ) subq_4 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0_optimized.sql index 8a42052413..65d688b745 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0_optimized.sql @@ -5,31 +5,31 @@ -- Compute Metrics via Expressions SELECT subq_18.customer_id__customer_name AS account_id__customer_id__customer_name - , SUM(account_month_txns_src_10010.txn_count) AS txn_count -FROM ***************************.account_month_txns account_month_txns_src_10010 + , SUM(account_month_txns_src_10012.txn_count) AS txn_count +FROM ***************************.account_month_txns account_month_txns_src_10012 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: -- ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__day - , bridge_table_src_10011.account_id AS account_id - , customer_table_src_10013.customer_name AS customer_id__customer_name - FROM ***************************.bridge_table bridge_table_src_10011 + DATE_TRUNC('day', bridge_table_src_10013.ds_partitioned) AS ds_partitioned__day + , bridge_table_src_10013.account_id AS account_id + , customer_table_src_10015.customer_name AS customer_id__customer_name + FROM ***************************.bridge_table bridge_table_src_10013 LEFT OUTER JOIN - ***************************.customer_table customer_table_src_10013 + ***************************.customer_table customer_table_src_10015 ON ( - bridge_table_src_10011.customer_id = customer_table_src_10013.customer_id + bridge_table_src_10013.customer_id = customer_table_src_10015.customer_id ) AND ( - DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) = DATE_TRUNC('day', customer_table_src_10013.ds_partitioned) + DATE_TRUNC('day', bridge_table_src_10013.ds_partitioned) = DATE_TRUNC('day', customer_table_src_10015.ds_partitioned) ) ) subq_18 ON ( - account_month_txns_src_10010.account_id = subq_18.account_id + account_month_txns_src_10012.account_id = subq_18.account_id ) AND ( - DATE_TRUNC('day', account_month_txns_src_10010.ds_partitioned) = subq_18.ds_partitioned__day + DATE_TRUNC('day', account_month_txns_src_10012.ds_partitioned) = subq_18.ds_partitioned__day ) GROUP BY subq_18.customer_id__customer_name diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multiple_metrics_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multiple_metrics_no_dimensions__plan0.sql index ceda439945..dde7919953 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multiple_metrics_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multiple_metrics_no_dimensions__plan0.sql @@ -473,62 +473,62 @@ CROSS JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_10004.capacity AS largest_listing - , listings_latest_src_10004.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS created_at__extract_doy - , listings_latest_src_10004.country AS country_latest - , listings_latest_src_10004.is_lux AS is_lux_latest - , listings_latest_src_10004.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_10004.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__created_at__extract_doy - , listings_latest_src_10004.country AS listing__country_latest - , listings_latest_src_10004.is_lux AS listing__is_lux_latest - , listings_latest_src_10004.capacity AS listing__capacity_latest - , listings_latest_src_10004.listing_id AS listing - , listings_latest_src_10004.user_id AS user - , listings_latest_src_10004.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_10004 + , listings_latest_src_10005.capacity AS largest_listing + , listings_latest_src_10005.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS created_at__extract_doy + , listings_latest_src_10005.country AS country_latest + , listings_latest_src_10005.is_lux AS is_lux_latest + , listings_latest_src_10005.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_10005.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_10005.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_10005.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_10005.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_10005.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_10005.created_at) AS listing__created_at__extract_doy + , listings_latest_src_10005.country AS listing__country_latest + , listings_latest_src_10005.is_lux AS listing__is_lux_latest + , listings_latest_src_10005.capacity AS listing__capacity_latest + , listings_latest_src_10005.listing_id AS listing + , listings_latest_src_10005.user_id AS user + , listings_latest_src_10005.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_10005 ) subq_6 ) subq_7 WHERE subq_7.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multiple_metrics_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multiple_metrics_no_dimensions__plan0_optimized.sql index 631546edf7..5fdefdb6a7 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multiple_metrics_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multiple_metrics_no_dimensions__plan0_optimized.sql @@ -25,6 +25,6 @@ CROSS JOIN ( -- Compute Metrics via Expressions SELECT SUM(1) AS listings - FROM ***************************.dim_listings_latest listings_latest_src_10004 + FROM ***************************.dim_listings_latest listings_latest_src_10005 WHERE DATE_TRUNC('day', created_at) BETWEEN '2020-01-01' AND '2020-01-01' ) subq_23 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_partitioned_join__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_partitioned_join__plan0.sql index a2e11e9487..335defe73b 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_partitioned_join__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_partitioned_join__plan0.sql @@ -96,56 +96,56 @@ FROM ( -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , DATE_TRUNC('day', id_verifications_src_10003.ds) AS ds__day - , DATE_TRUNC('week', id_verifications_src_10003.ds) AS ds__week - , DATE_TRUNC('month', id_verifications_src_10003.ds) AS ds__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS ds__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds) AS ds__year - , EXTRACT(year FROM id_verifications_src_10003.ds) AS ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds) AS ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds) AS ds__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM id_verifications_src_10003.ds) AS ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds) AS ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_doy - , id_verifications_src_10003.verification_type - , DATE_TRUNC('day', id_verifications_src_10003.ds) AS verification__ds__day - , DATE_TRUNC('week', id_verifications_src_10003.ds) AS verification__ds__week - , DATE_TRUNC('month', id_verifications_src_10003.ds) AS verification__ds__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS verification__ds__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds) AS verification__ds__year - , EXTRACT(year FROM id_verifications_src_10003.ds) AS verification__ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds) AS verification__ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds) AS verification__ds__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds) AS verification__ds__extract_day - , EXTRACT(dayofweekiso FROM id_verifications_src_10003.ds) AS verification__ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds) AS verification__ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__extract_doy - , id_verifications_src_10003.verification_type AS verification__verification_type - , id_verifications_src_10003.verification_id AS verification - , id_verifications_src_10003.user_id AS user - , id_verifications_src_10003.user_id AS verification__user - FROM ***************************.fct_id_verifications id_verifications_src_10003 + , DATE_TRUNC('day', id_verifications_src_10004.ds) AS ds__day + , DATE_TRUNC('week', id_verifications_src_10004.ds) AS ds__week + , DATE_TRUNC('month', id_verifications_src_10004.ds) AS ds__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds) AS ds__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds) AS ds__year + , EXTRACT(year FROM id_verifications_src_10004.ds) AS ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds) AS ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds) AS ds__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM id_verifications_src_10004.ds) AS ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds) AS ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds_partitioned) AS ds_partitioned__extract_doy + , id_verifications_src_10004.verification_type + , DATE_TRUNC('day', id_verifications_src_10004.ds) AS verification__ds__day + , DATE_TRUNC('week', id_verifications_src_10004.ds) AS verification__ds__week + , DATE_TRUNC('month', id_verifications_src_10004.ds) AS verification__ds__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds) AS verification__ds__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds) AS verification__ds__year + , EXTRACT(year FROM id_verifications_src_10004.ds) AS verification__ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds) AS verification__ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds) AS verification__ds__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds) AS verification__ds__extract_day + , EXTRACT(dayofweekiso FROM id_verifications_src_10004.ds) AS verification__ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds) AS verification__ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_10004.ds_partitioned) AS verification__ds_partitioned__extract_doy + , id_verifications_src_10004.verification_type AS verification__verification_type + , id_verifications_src_10004.verification_id AS verification + , id_verifications_src_10004.user_id AS user + , id_verifications_src_10004.user_id AS verification__user + FROM ***************************.fct_id_verifications id_verifications_src_10004 ) subq_0 ) subq_1 ) subq_2 @@ -159,76 +159,76 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT - DATE_TRUNC('day', users_ds_source_src_10007.ds) AS ds__day - , DATE_TRUNC('week', users_ds_source_src_10007.ds) AS ds__week - , DATE_TRUNC('month', users_ds_source_src_10007.ds) AS ds__month - , DATE_TRUNC('quarter', users_ds_source_src_10007.ds) AS ds__quarter - , DATE_TRUNC('year', users_ds_source_src_10007.ds) AS ds__year - , EXTRACT(year FROM users_ds_source_src_10007.ds) AS ds__extract_year - , EXTRACT(quarter FROM users_ds_source_src_10007.ds) AS ds__extract_quarter - , EXTRACT(month FROM users_ds_source_src_10007.ds) AS ds__extract_month - , EXTRACT(day FROM users_ds_source_src_10007.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM users_ds_source_src_10007.ds) AS ds__extract_dow - , EXTRACT(doy FROM users_ds_source_src_10007.ds) AS ds__extract_doy - , DATE_TRUNC('day', users_ds_source_src_10007.created_at) AS created_at__day - , DATE_TRUNC('week', users_ds_source_src_10007.created_at) AS created_at__week - , DATE_TRUNC('month', users_ds_source_src_10007.created_at) AS created_at__month - , DATE_TRUNC('quarter', users_ds_source_src_10007.created_at) AS created_at__quarter - , DATE_TRUNC('year', users_ds_source_src_10007.created_at) AS created_at__year - , EXTRACT(year FROM users_ds_source_src_10007.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_10007.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_10007.created_at) AS created_at__extract_month - , EXTRACT(day FROM users_ds_source_src_10007.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM users_ds_source_src_10007.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_10007.created_at) AS created_at__extract_doy - , DATE_TRUNC('day', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_doy - , users_ds_source_src_10007.home_state - , DATE_TRUNC('day', users_ds_source_src_10007.ds) AS user__ds__day - , DATE_TRUNC('week', users_ds_source_src_10007.ds) AS user__ds__week - , DATE_TRUNC('month', users_ds_source_src_10007.ds) AS user__ds__month - , DATE_TRUNC('quarter', users_ds_source_src_10007.ds) AS user__ds__quarter - , DATE_TRUNC('year', users_ds_source_src_10007.ds) AS user__ds__year - , EXTRACT(year FROM users_ds_source_src_10007.ds) AS user__ds__extract_year - , EXTRACT(quarter FROM users_ds_source_src_10007.ds) AS user__ds__extract_quarter - , EXTRACT(month FROM users_ds_source_src_10007.ds) AS user__ds__extract_month - , EXTRACT(day FROM users_ds_source_src_10007.ds) AS user__ds__extract_day - , EXTRACT(dayofweekiso FROM users_ds_source_src_10007.ds) AS user__ds__extract_dow - , EXTRACT(doy FROM users_ds_source_src_10007.ds) AS user__ds__extract_doy - , DATE_TRUNC('day', users_ds_source_src_10007.created_at) AS user__created_at__day - , DATE_TRUNC('week', users_ds_source_src_10007.created_at) AS user__created_at__week - , DATE_TRUNC('month', users_ds_source_src_10007.created_at) AS user__created_at__month - , DATE_TRUNC('quarter', users_ds_source_src_10007.created_at) AS user__created_at__quarter - , DATE_TRUNC('year', users_ds_source_src_10007.created_at) AS user__created_at__year - , EXTRACT(year FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_month - , EXTRACT(day FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_day - , EXTRACT(dayofweekiso FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_doy - , DATE_TRUNC('day', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__day - , DATE_TRUNC('week', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__week - , DATE_TRUNC('month', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__month - , DATE_TRUNC('quarter', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__quarter - , DATE_TRUNC('year', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__year - , EXTRACT(year FROM users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__extract_year - , EXTRACT(quarter FROM users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__extract_quarter - , EXTRACT(month FROM users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__extract_month - , EXTRACT(day FROM users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__extract_dow - , EXTRACT(doy FROM users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__extract_doy - , users_ds_source_src_10007.home_state AS user__home_state - , users_ds_source_src_10007.user_id AS user - FROM ***************************.dim_users users_ds_source_src_10007 + DATE_TRUNC('day', users_ds_source_src_10008.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_10008.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_10008.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_10008.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_10008.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_10008.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_10008.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_10008.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_10008.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_10008.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_10008.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_10008.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_10008.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_10008.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_10008.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_10008.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_10008.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_10008.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_10008.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_10008.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_10008.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_10008.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_10008.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_10008.home_state + , DATE_TRUNC('day', users_ds_source_src_10008.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_10008.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_10008.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_10008.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_10008.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_10008.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_10008.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_10008.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_10008.ds) AS user__ds__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_10008.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_10008.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_10008.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_10008.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_10008.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_10008.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_10008.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_10008.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_10008.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_10008.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_10008.created_at) AS user__created_at__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_10008.created_at) AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_10008.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_10008.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_10008.home_state AS user__home_state + , users_ds_source_src_10008.user_id AS user + FROM ***************************.dim_users users_ds_source_src_10008 ) subq_3 ) subq_4 ON diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_partitioned_join__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_partitioned_join__plan0_optimized.sql index c15982d861..b52d743037 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_partitioned_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_partitioned_join__plan0_optimized.sql @@ -4,7 +4,7 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - users_ds_source_src_10007.home_state AS user__home_state + users_ds_source_src_10008.home_state AS user__home_state , SUM(subq_10.identity_verifications) AS identity_verifications FROM ( -- Read Elements From Semantic Model 'id_verifications' @@ -15,15 +15,15 @@ FROM ( DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , user_id AS user , 1 AS identity_verifications - FROM ***************************.fct_id_verifications id_verifications_src_10003 + FROM ***************************.fct_id_verifications id_verifications_src_10004 ) subq_10 LEFT OUTER JOIN - ***************************.dim_users users_ds_source_src_10007 + ***************************.dim_users users_ds_source_src_10008 ON ( - subq_10.user = users_ds_source_src_10007.user_id + subq_10.user = users_ds_source_src_10008.user_id ) AND ( - subq_10.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_10007.ds_partitioned) + subq_10.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_10008.ds_partitioned) ) GROUP BY - users_ds_source_src_10007.home_state + users_ds_source_src_10008.home_state diff --git a/metricflow/test/snapshots/test_semantic_model_container.py/dict/test_get_names__result0.txt b/metricflow/test/snapshots/test_semantic_model_container.py/dict/test_get_names__result0.txt index 306ae39392..e58aa63d8c 100644 --- a/metricflow/test/snapshots/test_semantic_model_container.py/dict/test_get_names__result0.txt +++ b/metricflow/test/snapshots/test_semantic_model_container.py/dict/test_get_names__result0.txt @@ -11,6 +11,7 @@ 'is_instant', 'is_lux_latest', 'paid_at', + 'referrer_id', 'verification_type'], 'measure_references': ['account_balance', 'approximate_continuous_booking_value_p99', @@ -21,6 +22,8 @@ 'booking_value', 'booking_value_p99', 'bookings', + 'buyers', + 'buys', 'current_account_balance_by_user', 'discrete_booking_value_p99', 'identity_verifications', @@ -34,11 +37,15 @@ 'smallest_listing', 'total_account_balance_first_day', 'txn_revenue', - 'views'], + 'views', + 'visitors', + 'visits'], 'entity_references': ['company', 'guest', 'host', 'listing', 'lux_listing', + 'session', + 'session_id', 'user', 'verification']} diff --git a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_metrics_from_1_semantic_model__dfp_0.xml b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_metrics_from_1_semantic_model__dfp_0.xml index 99061839c1..8c15f6c100 100644 --- a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_metrics_from_1_semantic_model__dfp_0.xml +++ b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_metrics_from_1_semantic_model__dfp_0.xml @@ -79,7 +79,7 @@ - + @@ -96,12 +96,12 @@ - + - + @@ -185,7 +185,7 @@ - + @@ -202,12 +202,12 @@ - + - + diff --git a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_metrics_from_2_semantic_models__dfp_0.xml b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_metrics_from_2_semantic_models__dfp_0.xml index ac854dcf01..eb282a7ae1 100644 --- a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_metrics_from_2_semantic_models__dfp_0.xml +++ b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_metrics_from_2_semantic_models__dfp_0.xml @@ -43,7 +43,7 @@ - + @@ -84,12 +84,12 @@ - + - + diff --git a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_ratio_metrics_from_1_semantic_model__dfp_0.xml b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_ratio_metrics_from_1_semantic_model__dfp_0.xml index bae10c6770..f56adf466a 100644 --- a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_ratio_metrics_from_1_semantic_model__dfp_0.xml +++ b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_ratio_metrics_from_1_semantic_model__dfp_0.xml @@ -56,7 +56,7 @@ - + @@ -102,7 +102,7 @@ - + @@ -163,7 +163,7 @@ - + @@ -209,7 +209,7 @@ - + diff --git a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_3_metrics_from_2_semantic_models__dfp_0.xml b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_3_metrics_from_2_semantic_models__dfp_0.xml index 1cdf1a7158..06452739cf 100644 --- a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_3_metrics_from_2_semantic_models__dfp_0.xml +++ b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_3_metrics_from_2_semantic_models__dfp_0.xml @@ -43,7 +43,7 @@ - + @@ -89,7 +89,7 @@ - + @@ -130,12 +130,12 @@ - + - + diff --git a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_constrained_metric_not_combined__dfp_0.xml b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_constrained_metric_not_combined__dfp_0.xml index ebe9cffd88..7fbed745e6 100644 --- a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_constrained_metric_not_combined__dfp_0.xml +++ b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_constrained_metric_not_combined__dfp_0.xml @@ -43,7 +43,7 @@ - + @@ -125,7 +125,7 @@ - + diff --git a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_derived_metric__dfp_0.xml b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_derived_metric__dfp_0.xml index a21a712cc5..4f4bb2ceca 100644 --- a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_derived_metric__dfp_0.xml +++ b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_derived_metric__dfp_0.xml @@ -53,7 +53,7 @@ - + @@ -99,7 +99,7 @@ - + diff --git a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_derived_metric_with_non_derived_metric__dfp_0.xml b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_derived_metric_with_non_derived_metric__dfp_0.xml index 74496bd131..ddf458aec1 100644 --- a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_derived_metric_with_non_derived_metric__dfp_0.xml +++ b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_derived_metric_with_non_derived_metric__dfp_0.xml @@ -43,7 +43,7 @@ - + @@ -102,7 +102,7 @@ - + @@ -148,7 +148,7 @@ - + diff --git a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_nested_derived_metric__dfp_0.xml b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_nested_derived_metric__dfp_0.xml index 391d0b7ccd..bb79619637 100644 --- a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_nested_derived_metric__dfp_0.xml +++ b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_nested_derived_metric__dfp_0.xml @@ -66,7 +66,7 @@ - + @@ -112,7 +112,7 @@ - + @@ -160,7 +160,7 @@ - + @@ -206,7 +206,7 @@ - + From d14eed6842eba8eff7f29ea423e9a8ff069edc5d Mon Sep 17 00:00:00 2001 From: Will Deng Date: Sat, 16 Dec 2023 03:27:01 -0500 Subject: [PATCH 14/14] update frame clause to default as redshift requires it --- metricflow/sql/render/expr_renderer.py | 1 + .../test_cases/itest_conversion_metric.yaml | 34 +++++++++---------- metricflow/test/sql/test_sql_expr_render.py | 2 +- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/metricflow/sql/render/expr_renderer.py b/metricflow/sql/render/expr_renderer.py index 29fac9b1a1..b9bf939a98 100644 --- a/metricflow/sql/render/expr_renderer.py +++ b/metricflow/sql/render/expr_renderer.py @@ -367,6 +367,7 @@ def visit_window_function_expr(self, node: SqlWindowFunctionExpression) -> SqlEx for rendered_result, x in order_by_args_rendered.items() ] ) + + " ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING" ) if order_by_args_rendered else "" diff --git a/metricflow/test/integration/test_cases/itest_conversion_metric.yaml b/metricflow/test/integration/test_cases/itest_conversion_metric.yaml index 085a37a777..5f9b39ccf8 100644 --- a/metricflow/test/integration/test_cases/itest_conversion_metric.yaml +++ b/metricflow/test/integration/test_cases/itest_conversion_metric.yaml @@ -25,9 +25,9 @@ integration_test: b.ds AS metric_time, SUM(b.buys) AS buys FROM ( SELECT DISTINCT - first_value(v.ds) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC) AS ds - , first_value(v.user_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC) AS user_id - , first_value(v.referrer_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC) AS referrer_id + first_value(v.ds) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds + , first_value(v.user_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user_id + , first_value(v.referrer_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS referrer_id , buy_source.uuid , 1 AS buys FROM {{ source_schema }}.fct_visits v @@ -65,8 +65,8 @@ integration_test: SUM(b.buys) AS buys FROM ( SELECT DISTINCT - first_value(v.user_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC) AS user_id - , first_value(v.referrer_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC) AS referrer_id + first_value(v.user_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user_id + , first_value(v.referrer_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS referrer_id , buy_source.uuid , 1 AS buys FROM {{ source_schema }}.fct_visits v @@ -105,9 +105,9 @@ integration_test: b.ds AS metric_time, SUM(b.buys) AS buys FROM ( SELECT DISTINCT - first_value(v.ds) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC) AS ds - , first_value(v.user_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC) AS user_id - , first_value(v.referrer_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC) AS referrer_id + first_value(v.ds) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds + , first_value(v.user_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user_id + , first_value(v.referrer_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS referrer_id , buy_source.uuid , 1 AS buys FROM {{ source_schema }}.fct_visits v @@ -149,9 +149,9 @@ integration_test: referrer_id AS referrer_id, SUM(b.buys) AS buys FROM ( SELECT DISTINCT - first_value(v.ds) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC) AS ds - , first_value(v.user_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC) AS user_id - , first_value(v.referrer_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC) AS referrer_id + first_value(v.ds) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds + , first_value(v.user_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user_id + , first_value(v.referrer_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id ORDER BY v.ds DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS referrer_id , buy_source.uuid , 1 AS buys FROM {{ source_schema }}.fct_visits v @@ -284,9 +284,9 @@ integration_test: b.ds AS metric_time, SUM(b.buys) AS buys FROM ( SELECT DISTINCT - first_value(v.ds) OVER (PARTITION BY buy_source.ds, buy_source.user_id, buy_source.session_id ORDER BY v.ds DESC) AS ds - , first_value(v.user_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id, buy_source.session_id ORDER BY v.ds DESC) AS user_id - , first_value(v.referrer_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id, buy_source.session_id ORDER BY v.ds DESC) AS referrer_id + first_value(v.ds) OVER (PARTITION BY buy_source.ds, buy_source.user_id, buy_source.session_id ORDER BY v.ds DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds + , first_value(v.user_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id, buy_source.session_id ORDER BY v.ds DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user_id + , first_value(v.referrer_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id, buy_source.session_id ORDER BY v.ds DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS referrer_id , buy_source.uuid , 1 AS buys FROM {{ source_schema }}.fct_visits v @@ -331,9 +331,9 @@ integration_test: b.ds AS metric_time, referrer_id AS referrer_id, SUM(b.buys) AS buys FROM ( SELECT DISTINCT - first_value(v.ds) OVER (PARTITION BY buy_source.ds, buy_source.user_id, buy_source.session_id ORDER BY v.ds DESC) AS ds - , first_value(v.user_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id, buy_source.session_id ORDER BY v.ds DESC) AS user_id - , first_value(v.referrer_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id, buy_source.session_id ORDER BY v.ds DESC) AS referrer_id + first_value(v.ds) OVER (PARTITION BY buy_source.ds, buy_source.user_id, buy_source.session_id ORDER BY v.ds DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds + , first_value(v.user_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id, buy_source.session_id ORDER BY v.ds DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user_id + , first_value(v.referrer_id) OVER (PARTITION BY buy_source.ds, buy_source.user_id, buy_source.session_id ORDER BY v.ds DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS referrer_id , buy_source.uuid , 1 AS buys FROM {{ source_schema }}.fct_visits v diff --git a/metricflow/test/sql/test_sql_expr_render.py b/metricflow/test/sql/test_sql_expr_render.py index c883313a4d..9278c88862 100644 --- a/metricflow/test/sql/test_sql_expr_render.py +++ b/metricflow/test/sql/test_sql_expr_render.py @@ -277,5 +277,5 @@ def test_window_function_expr(default_expr_renderer: DefaultSqlExpressionRendere ).sql assert ( actual - == "first_value(a.col0) OVER (PARTITION BY b.col0, b.col1 ORDER BY a.col0 DESC NULLS FIRST, b.col0 ASC NULLS LAST)" + == "first_value(a.col0) OVER (PARTITION BY b.col0, b.col1 ORDER BY a.col0 DESC NULLS FIRST, b.col0 ASC NULLS LAST ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)" )