diff --git a/metricflow/dataflow/builder/dataflow_plan_builder.py b/metricflow/dataflow/builder/dataflow_plan_builder.py index b9ce2f842b..39f987120f 100644 --- a/metricflow/dataflow/builder/dataflow_plan_builder.py +++ b/metricflow/dataflow/builder/dataflow_plan_builder.py @@ -896,7 +896,14 @@ def _find_dataflow_recipe( node_data_set_resolver=self._node_data_set_resolver, ) - if predicate_pushdown_state.has_pushdown_potential: + if predicate_pushdown_state.has_pushdown_potential and default_join_type is not SqlJoinType.FULL_OUTER: + # TODO: encapsulate join type and distinct values state and eventually move this to a DataflowPlanOptimizer + # This works today because all of our subsequent join configuration operations preserve the join type + # as-is, or else switch it to a CROSS JOIN or INNER JOIN type, both of which are safe for predicate + # pushdown. However, there is currently no way to enforce that invariant, so we will need to move + # to a model where we evaluate the join nodes themselves and decide on whether or not to push down + # the predicate. This will be much more straightforward once we finish encapsulating our existing + # time range constraint pushdown controls into this mechanism. candidate_nodes_for_left_side_of_join = list( node_processor.apply_matching_filter_predicates( source_nodes=candidate_nodes_for_left_side_of_join, @@ -904,15 +911,6 @@ def _find_dataflow_recipe( metric_time_dimension_reference=self._metric_time_dimension_reference, ) ) - candidate_nodes_for_right_side_of_join = list( - node_processor.apply_matching_filter_predicates( - source_nodes=candidate_nodes_for_right_side_of_join, - predicate_pushdown_state=PredicatePushdownState.without_time_range_constraint( - original_pushdown_state=predicate_pushdown_state - ), - metric_time_dimension_reference=self._metric_time_dimension_reference, - ) - ) candidate_nodes_for_right_side_of_join = node_processor.remove_unnecessary_nodes( desired_linkable_specs=linkable_specs, diff --git a/metricflow/plan_conversion/node_processor.py b/metricflow/plan_conversion/node_processor.py index 240e537d58..71958a341a 100644 --- a/metricflow/plan_conversion/node_processor.py +++ b/metricflow/plan_conversion/node_processor.py @@ -1,7 +1,6 @@ from __future__ import annotations import dataclasses -import itertools import logging from enum import Enum from typing import Dict, FrozenSet, List, Optional, Sequence, Set @@ -355,11 +354,7 @@ def _add_where_constraint( """Processes where filter specs and evaluates their fitness for pushdown against the provided node set.""" eligible_filter_specs_by_model: Dict[SemanticModelReference, Sequence[WhereFilterSpec]] = {} for spec in where_filter_specs: - semantic_models = set( - itertools.chain.from_iterable( - [element.derived_from_semantic_models for element in spec.linkable_elements] - ) - ) + semantic_models = set(element.semantic_model_origin for element in spec.linkable_elements) invalid_element_types = [ element for element in spec.linkable_elements if element.element_type not in enabled_element_types ] diff --git a/tests_metricflow/query_rendering/test_predicate_pushdown_rendering.py b/tests_metricflow/query_rendering/test_predicate_pushdown_rendering.py index a7d4eb19bc..0018541dfc 100644 --- a/tests_metricflow/query_rendering/test_predicate_pushdown_rendering.py +++ b/tests_metricflow/query_rendering/test_predicate_pushdown_rendering.py @@ -51,8 +51,8 @@ def test_multiple_categorical_dimension_pushdown( ) -> None: """Tests rendering a query where we expect predicate pushdown for more than one categorical dimension.""" parsed_query = query_parser.parse_and_validate_query( - metric_names=("bookings",), - group_by_names=("booking__is_instant",), + metric_names=("listings",), + group_by_names=("user__home_state_latest",), where_constraint=PydanticWhereFilter( where_sql_template="{{ Dimension('listing__is_lux_latest') }} OR {{ Dimension('listing__capacity_latest') }} > 4", ), @@ -69,37 +69,7 @@ def test_multiple_categorical_dimension_pushdown( @pytest.mark.sql_engine_snapshot -def test_multiple_different_filters_on_same_joined_categorical_dimension( - request: FixtureRequest, - mf_test_configuration: MetricFlowTestConfiguration, - dataflow_plan_builder: DataflowPlanBuilder, - query_parser: MetricFlowQueryParser, - dataflow_to_sql_converter: DataflowToSqlQueryPlanConverter, - sql_client: SqlClient, -) -> None: - """Tests rendering a query where multiple filters against the same joined dimension need to be an effective OR. - - This can be an issue where a derived metric takes in two filters that refer to the same joined-in categorical - dimension. If these filters are disjoint the predicate pushdown needs to ensure that all matching rows are - returned, so we cannot simply push one filter or the other down, nor can we push them down as an AND - they - must be an OR, since all relevant rows need to be returned to the requesting metrics. - """ - parsed_query = query_parser.parse_and_validate_query( - metric_names=("regional_starting_balance_ratios",), - ) - dataflow_plan = dataflow_plan_builder.build_plan(parsed_query.query_spec) - - convert_and_check( - request=request, - mf_test_configuration=mf_test_configuration, - dataflow_to_sql_converter=dataflow_to_sql_converter, - sql_client=sql_client, - node=dataflow_plan.sink_node, - ) - - -@pytest.mark.sql_engine_snapshot -def test_multiple_different_filters_on_same_measure_source_categorical_dimension( +def test_different_filters_on_same_measure_source_categorical_dimension( request: FixtureRequest, mf_test_configuration: MetricFlowTestConfiguration, dataflow_plan_builder: DataflowPlanBuilder, @@ -113,6 +83,9 @@ def test_multiple_different_filters_on_same_measure_source_categorical_dimension measure source. If these filters are disjoint the predicate pushdown needs to ensure that all matching rows are returned, so we cannot simply push one filter or the other down, nor can we push them down as an AND - they must be an OR, since all relevant rows need to be returned to the requesting metrics. + + The metric listed here has one input that filters on bookings__is_instant and another that does not, which means + the source input for the latter input must NOT have the filter applied to it. """ parsed_query = query_parser.parse_and_validate_query( metric_names=("instant_booking_fraction_of_max_value",), diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_dimensions_with_time_constraint__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_dimensions_with_time_constraint__dfp_0.xml index c83d58ff9a..4c8b4fd14c 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_dimensions_with_time_constraint__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_dimensions_with_time_constraint__dfp_0.xml @@ -11,7 +11,7 @@ - + diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_distinct_values_plan__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_distinct_values_plan__dfp_0.xml index e988b9cdda..11c468ba3d 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_distinct_values_plan__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_distinct_values_plan__dfp_0.xml @@ -25,7 +25,7 @@ - + @@ -53,42 +53,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_distinct_values_plan_with_join__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_distinct_values_plan_with_join__dfp_0.xml index 110cc9e5a4..3cc61d8fca 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_distinct_values_plan_with_join__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_distinct_values_plan_with_join__dfp_0.xml @@ -30,7 +30,7 @@ - + @@ -67,42 +67,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_measure_constraint_with_reused_measure_plan__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_measure_constraint_with_reused_measure_plan__dfp_0.xml index e5c9d9b3b8..df25ec54f9 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_measure_constraint_with_reused_measure_plan__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_measure_constraint_with_reused_measure_plan__dfp_0.xml @@ -58,7 +58,7 @@ - + @@ -117,7 +117,7 @@ - + diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimension_with_joined_where_constraint__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimension_with_joined_where_constraint__plan0.sql index 9b9dc5ff09..ed1028fb88 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimension_with_joined_where_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimension_with_joined_where_constraint__plan0.sql @@ -1,253 +1,192 @@ -- Pass Only Elements: ['user__home_state_latest',] SELECT - subq_7.user__home_state_latest + subq_4.user__home_state_latest FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.created_at__day - , subq_6.created_at__week - , subq_6.created_at__month - , subq_6.created_at__quarter - , subq_6.created_at__year - , subq_6.created_at__extract_year - , subq_6.created_at__extract_quarter - , subq_6.created_at__extract_month - , subq_6.created_at__extract_day - , subq_6.created_at__extract_dow - , subq_6.created_at__extract_doy - , subq_6.listing__ds__day - , subq_6.listing__ds__week - , subq_6.listing__ds__month - , subq_6.listing__ds__quarter - , subq_6.listing__ds__year - , subq_6.listing__ds__extract_year - , subq_6.listing__ds__extract_quarter - , subq_6.listing__ds__extract_month - , subq_6.listing__ds__extract_day - , subq_6.listing__ds__extract_dow - , subq_6.listing__ds__extract_doy - , subq_6.listing__created_at__day - , subq_6.listing__created_at__week - , subq_6.listing__created_at__month - , subq_6.listing__created_at__quarter - , subq_6.listing__created_at__year - , subq_6.listing__created_at__extract_year - , subq_6.listing__created_at__extract_quarter - , subq_6.listing__created_at__extract_month - , subq_6.listing__created_at__extract_day - , subq_6.listing__created_at__extract_dow - , subq_6.listing__created_at__extract_doy - , subq_6.listing - , subq_6.user - , subq_6.listing__user - , subq_6.country_latest - , subq_6.is_lux_latest - , subq_6.capacity_latest - , subq_6.listing__country_latest - , subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.user__home_state_latest - , subq_6.listings - , subq_6.largest_listing - , subq_6.smallest_listing + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.created_at__day + , subq_3.created_at__week + , subq_3.created_at__month + , subq_3.created_at__quarter + , subq_3.created_at__year + , subq_3.created_at__extract_year + , subq_3.created_at__extract_quarter + , subq_3.created_at__extract_month + , subq_3.created_at__extract_day + , subq_3.created_at__extract_dow + , subq_3.created_at__extract_doy + , subq_3.listing__ds__day + , subq_3.listing__ds__week + , subq_3.listing__ds__month + , subq_3.listing__ds__quarter + , subq_3.listing__ds__year + , subq_3.listing__ds__extract_year + , subq_3.listing__ds__extract_quarter + , subq_3.listing__ds__extract_month + , subq_3.listing__ds__extract_day + , subq_3.listing__ds__extract_dow + , subq_3.listing__ds__extract_doy + , subq_3.listing__created_at__day + , subq_3.listing__created_at__week + , subq_3.listing__created_at__month + , subq_3.listing__created_at__quarter + , subq_3.listing__created_at__year + , subq_3.listing__created_at__extract_year + , subq_3.listing__created_at__extract_quarter + , subq_3.listing__created_at__extract_month + , subq_3.listing__created_at__extract_day + , subq_3.listing__created_at__extract_dow + , subq_3.listing__created_at__extract_doy + , subq_3.listing + , subq_3.user + , subq_3.listing__user + , subq_3.country_latest + , subq_3.is_lux_latest + , subq_3.capacity_latest + , subq_3.listing__country_latest + , subq_3.listing__is_lux_latest + , subq_3.listing__capacity_latest + , subq_3.user__home_state_latest + , subq_3.listings + , subq_3.largest_listing + , subq_3.smallest_listing FROM ( -- Join Standard Outputs SELECT - subq_3.ds__day AS ds__day - , subq_3.ds__week AS ds__week - , subq_3.ds__month AS ds__month - , subq_3.ds__quarter AS ds__quarter - , subq_3.ds__year AS ds__year - , subq_3.ds__extract_year AS ds__extract_year - , subq_3.ds__extract_quarter AS ds__extract_quarter - , subq_3.ds__extract_month AS ds__extract_month - , subq_3.ds__extract_day AS ds__extract_day - , subq_3.ds__extract_dow AS ds__extract_dow - , subq_3.ds__extract_doy AS ds__extract_doy - , subq_3.created_at__day AS created_at__day - , subq_3.created_at__week AS created_at__week - , subq_3.created_at__month AS created_at__month - , subq_3.created_at__quarter AS created_at__quarter - , subq_3.created_at__year AS created_at__year - , subq_3.created_at__extract_year AS created_at__extract_year - , subq_3.created_at__extract_quarter AS created_at__extract_quarter - , subq_3.created_at__extract_month AS created_at__extract_month - , subq_3.created_at__extract_day AS created_at__extract_day - , subq_3.created_at__extract_dow AS created_at__extract_dow - , subq_3.created_at__extract_doy AS created_at__extract_doy - , subq_3.listing__ds__day AS listing__ds__day - , subq_3.listing__ds__week AS listing__ds__week - , subq_3.listing__ds__month AS listing__ds__month - , subq_3.listing__ds__quarter AS listing__ds__quarter - , subq_3.listing__ds__year AS listing__ds__year - , subq_3.listing__ds__extract_year AS listing__ds__extract_year - , subq_3.listing__ds__extract_quarter AS listing__ds__extract_quarter - , subq_3.listing__ds__extract_month AS listing__ds__extract_month - , subq_3.listing__ds__extract_day AS listing__ds__extract_day - , subq_3.listing__ds__extract_dow AS listing__ds__extract_dow - , subq_3.listing__ds__extract_doy AS listing__ds__extract_doy - , subq_3.listing__created_at__day AS listing__created_at__day - , subq_3.listing__created_at__week AS listing__created_at__week - , subq_3.listing__created_at__month AS listing__created_at__month - , subq_3.listing__created_at__quarter AS listing__created_at__quarter - , subq_3.listing__created_at__year AS listing__created_at__year - , subq_3.listing__created_at__extract_year AS listing__created_at__extract_year - , subq_3.listing__created_at__extract_quarter AS listing__created_at__extract_quarter - , subq_3.listing__created_at__extract_month AS listing__created_at__extract_month - , subq_3.listing__created_at__extract_day AS listing__created_at__extract_day - , subq_3.listing__created_at__extract_dow AS listing__created_at__extract_dow - , subq_3.listing__created_at__extract_doy AS listing__created_at__extract_doy - , subq_3.listing AS listing - , subq_3.user AS user - , subq_3.listing__user AS listing__user - , subq_3.country_latest AS country_latest - , subq_3.is_lux_latest AS is_lux_latest - , subq_3.capacity_latest AS capacity_latest - , subq_3.listing__country_latest AS listing__country_latest - , subq_3.listing__is_lux_latest AS listing__is_lux_latest - , subq_3.listing__capacity_latest AS listing__capacity_latest - , subq_5.home_state_latest AS user__home_state_latest - , subq_3.listings AS listings - , subq_3.largest_listing AS largest_listing - , subq_3.smallest_listing AS smallest_listing + subq_0.ds__day AS ds__day + , subq_0.ds__week AS ds__week + , subq_0.ds__month AS ds__month + , subq_0.ds__quarter AS ds__quarter + , subq_0.ds__year AS ds__year + , subq_0.ds__extract_year AS ds__extract_year + , subq_0.ds__extract_quarter AS ds__extract_quarter + , subq_0.ds__extract_month AS ds__extract_month + , subq_0.ds__extract_day AS ds__extract_day + , subq_0.ds__extract_dow AS ds__extract_dow + , subq_0.ds__extract_doy AS ds__extract_doy + , subq_0.created_at__day AS created_at__day + , subq_0.created_at__week AS created_at__week + , subq_0.created_at__month AS created_at__month + , subq_0.created_at__quarter AS created_at__quarter + , subq_0.created_at__year AS created_at__year + , subq_0.created_at__extract_year AS created_at__extract_year + , subq_0.created_at__extract_quarter AS created_at__extract_quarter + , subq_0.created_at__extract_month AS created_at__extract_month + , subq_0.created_at__extract_day AS created_at__extract_day + , subq_0.created_at__extract_dow AS created_at__extract_dow + , subq_0.created_at__extract_doy AS created_at__extract_doy + , subq_0.listing__ds__day AS listing__ds__day + , subq_0.listing__ds__week AS listing__ds__week + , subq_0.listing__ds__month AS listing__ds__month + , subq_0.listing__ds__quarter AS listing__ds__quarter + , subq_0.listing__ds__year AS listing__ds__year + , subq_0.listing__ds__extract_year AS listing__ds__extract_year + , subq_0.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_0.listing__ds__extract_month AS listing__ds__extract_month + , subq_0.listing__ds__extract_day AS listing__ds__extract_day + , subq_0.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_0.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_0.listing__created_at__day AS listing__created_at__day + , subq_0.listing__created_at__week AS listing__created_at__week + , subq_0.listing__created_at__month AS listing__created_at__month + , subq_0.listing__created_at__quarter AS listing__created_at__quarter + , subq_0.listing__created_at__year AS listing__created_at__year + , subq_0.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_0.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_0.listing AS listing + , subq_0.user AS user + , subq_0.listing__user AS listing__user + , subq_0.country_latest AS country_latest + , subq_0.is_lux_latest AS is_lux_latest + , subq_0.capacity_latest AS capacity_latest + , subq_0.listing__country_latest AS listing__country_latest + , subq_0.listing__is_lux_latest AS listing__is_lux_latest + , subq_0.listing__capacity_latest AS listing__capacity_latest + , subq_2.home_state_latest AS user__home_state_latest + , subq_0.listings AS listings + , subq_0.largest_listing AS largest_listing + , subq_0.smallest_listing AS smallest_listing FROM ( - -- Constrain Output with WHERE + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_2.ds__day - , subq_2.ds__week - , subq_2.ds__month - , subq_2.ds__quarter - , subq_2.ds__year - , subq_2.ds__extract_year - , subq_2.ds__extract_quarter - , subq_2.ds__extract_month - , subq_2.ds__extract_day - , subq_2.ds__extract_dow - , subq_2.ds__extract_doy - , subq_2.created_at__day - , subq_2.created_at__week - , subq_2.created_at__month - , subq_2.created_at__quarter - , subq_2.created_at__year - , subq_2.created_at__extract_year - , subq_2.created_at__extract_quarter - , subq_2.created_at__extract_month - , subq_2.created_at__extract_day - , subq_2.created_at__extract_dow - , subq_2.created_at__extract_doy - , subq_2.listing__ds__day - , subq_2.listing__ds__week - , subq_2.listing__ds__month - , subq_2.listing__ds__quarter - , subq_2.listing__ds__year - , subq_2.listing__ds__extract_year - , subq_2.listing__ds__extract_quarter - , subq_2.listing__ds__extract_month - , subq_2.listing__ds__extract_day - , subq_2.listing__ds__extract_dow - , subq_2.listing__ds__extract_doy - , subq_2.listing__created_at__day - , subq_2.listing__created_at__week - , subq_2.listing__created_at__month - , subq_2.listing__created_at__quarter - , subq_2.listing__created_at__year - , subq_2.listing__created_at__extract_year - , subq_2.listing__created_at__extract_quarter - , subq_2.listing__created_at__extract_month - , subq_2.listing__created_at__extract_day - , subq_2.listing__created_at__extract_dow - , subq_2.listing__created_at__extract_doy - , subq_2.listing - , subq_2.user - , subq_2.listing__user - , subq_2.country_latest - , subq_2.is_lux_latest - , subq_2.capacity_latest - , subq_2.listing__country_latest - , subq_2.listing__is_lux_latest - , subq_2.listing__capacity_latest - , subq_2.listings - , subq_2.largest_listing - , subq_2.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_2 - WHERE listing__country_latest = 'us' - ) subq_3 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_4.user - , subq_4.home_state_latest + subq_1.user + , subq_1.home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT @@ -277,12 +216,12 @@ FROM ( , users_latest_src_28000.home_state_latest AS user__home_state_latest , users_latest_src_28000.user_id AS user FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_4 - ) subq_5 + ) subq_1 + ) subq_2 ON - subq_3.user = subq_5.user - ) subq_6 + subq_0.user = subq_2.user + ) subq_3 WHERE listing__country_latest = 'us' -) subq_7 +) subq_4 GROUP BY - subq_7.user__home_state_latest + subq_4.user__home_state_latest diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimension_with_joined_where_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimension_with_joined_where_constraint__plan0_optimized.sql index f2ac976dac..c4e57d3c86 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimension_with_joined_where_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimension_with_joined_where_constraint__plan0_optimized.sql @@ -5,27 +5,14 @@ SELECT FROM ( -- Join Standard Outputs SELECT - subq_9.listing__country_latest AS listing__country_latest + listings_latest_src_28000.country AS listing__country_latest , users_latest_src_28000.home_state_latest AS user__home_state_latest - FROM ( - -- Constrain Output with WHERE - SELECT - subq_8.user - , listing__country_latest - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - country AS listing__country_latest - , user_id AS user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_8 - WHERE listing__country_latest = 'us' - ) subq_9 + FROM ***************************.dim_listings_latest listings_latest_src_28000 FULL OUTER JOIN ***************************.dim_users_latest users_latest_src_28000 ON - subq_9.user = users_latest_src_28000.user_id -) subq_12 + listings_latest_src_28000.user_id = users_latest_src_28000.user_id +) subq_8 WHERE listing__country_latest = 'us' GROUP BY user__home_state_latest diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_dimension_with_joined_where_constraint__plan0.xml b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_dimension_with_joined_where_constraint__plan0.xml index a3e6bbb6dc..a25452a9ea 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_dimension_with_joined_where_constraint__plan0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_dimension_with_joined_where_constraint__plan0.xml @@ -1,977 +1,668 @@ - + - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + - - - - - - - + + + + + + + diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_filters__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_filters__plan0.sql index a54923e15b..c4c3c5c749 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_filters__plan0.sql @@ -8,248 +8,248 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_30.average_booking_value) AS average_booking_value - , MAX(subq_43.bookings) AS bookings - , MAX(subq_51.booking_value) AS booking_value + MAX(subq_18.average_booking_value) AS average_booking_value + , MAX(subq_31.bookings) AS bookings + , MAX(subq_39.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_29.average_booking_value + subq_17.average_booking_value FROM ( -- Aggregate Measures SELECT - AVG(subq_28.average_booking_value) AS average_booking_value + AVG(subq_16.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value',] SELECT - subq_27.average_booking_value + subq_15.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_26.booking__is_instant - , subq_26.listing__is_lux_latest - , subq_26.average_booking_value + subq_14.booking__is_instant + , subq_14.listing__is_lux_latest + , subq_14.average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_25.booking__is_instant - , subq_25.listing__is_lux_latest - , subq_25.average_booking_value + subq_13.booking__is_instant + , subq_13.listing__is_lux_latest + , subq_13.average_booking_value FROM ( -- Join Standard Outputs SELECT - subq_21.listing AS listing - , subq_21.booking__is_instant AS booking__is_instant - , subq_24.is_lux_latest AS listing__is_lux_latest - , subq_21.average_booking_value AS average_booking_value + subq_9.listing AS listing + , subq_9.booking__is_instant AS booking__is_instant + , subq_12.is_lux_latest AS listing__is_lux_latest + , subq_9.average_booking_value AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'listing'] SELECT - subq_20.listing - , subq_20.booking__is_instant - , subq_20.average_booking_value + subq_8.listing + , subq_8.booking__is_instant + , subq_8.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_19.ds__day - , subq_19.ds__week - , subq_19.ds__month - , subq_19.ds__quarter - , subq_19.ds__year - , subq_19.ds__extract_year - , subq_19.ds__extract_quarter - , subq_19.ds__extract_month - , subq_19.ds__extract_day - , subq_19.ds__extract_dow - , subq_19.ds__extract_doy - , subq_19.ds_partitioned__day - , subq_19.ds_partitioned__week - , subq_19.ds_partitioned__month - , subq_19.ds_partitioned__quarter - , subq_19.ds_partitioned__year - , subq_19.ds_partitioned__extract_year - , subq_19.ds_partitioned__extract_quarter - , subq_19.ds_partitioned__extract_month - , subq_19.ds_partitioned__extract_day - , subq_19.ds_partitioned__extract_dow - , subq_19.ds_partitioned__extract_doy - , subq_19.paid_at__day - , subq_19.paid_at__week - , subq_19.paid_at__month - , subq_19.paid_at__quarter - , subq_19.paid_at__year - , subq_19.paid_at__extract_year - , subq_19.paid_at__extract_quarter - , subq_19.paid_at__extract_month - , subq_19.paid_at__extract_day - , subq_19.paid_at__extract_dow - , subq_19.paid_at__extract_doy - , subq_19.booking__ds__day - , subq_19.booking__ds__week - , subq_19.booking__ds__month - , subq_19.booking__ds__quarter - , subq_19.booking__ds__year - , subq_19.booking__ds__extract_year - , subq_19.booking__ds__extract_quarter - , subq_19.booking__ds__extract_month - , subq_19.booking__ds__extract_day - , subq_19.booking__ds__extract_dow - , subq_19.booking__ds__extract_doy - , subq_19.booking__ds_partitioned__day - , subq_19.booking__ds_partitioned__week - , subq_19.booking__ds_partitioned__month - , subq_19.booking__ds_partitioned__quarter - , subq_19.booking__ds_partitioned__year - , subq_19.booking__ds_partitioned__extract_year - , subq_19.booking__ds_partitioned__extract_quarter - , subq_19.booking__ds_partitioned__extract_month - , subq_19.booking__ds_partitioned__extract_day - , subq_19.booking__ds_partitioned__extract_dow - , subq_19.booking__ds_partitioned__extract_doy - , subq_19.booking__paid_at__day - , subq_19.booking__paid_at__week - , subq_19.booking__paid_at__month - , subq_19.booking__paid_at__quarter - , subq_19.booking__paid_at__year - , subq_19.booking__paid_at__extract_year - , subq_19.booking__paid_at__extract_quarter - , subq_19.booking__paid_at__extract_month - , subq_19.booking__paid_at__extract_day - , subq_19.booking__paid_at__extract_dow - , subq_19.booking__paid_at__extract_doy - , subq_19.metric_time__day - , subq_19.metric_time__week - , subq_19.metric_time__month - , subq_19.metric_time__quarter - , subq_19.metric_time__year - , subq_19.metric_time__extract_year - , subq_19.metric_time__extract_quarter - , subq_19.metric_time__extract_month - , subq_19.metric_time__extract_day - , subq_19.metric_time__extract_dow - , subq_19.metric_time__extract_doy - , subq_19.listing - , subq_19.guest - , subq_19.host - , subq_19.booking__listing - , subq_19.booking__guest - , subq_19.booking__host - , subq_19.is_instant - , subq_19.booking__is_instant - , subq_19.bookings - , subq_19.instant_bookings - , subq_19.booking_value - , subq_19.max_booking_value - , subq_19.min_booking_value - , subq_19.bookers - , subq_19.average_booking_value - , subq_19.referred_bookings - , subq_19.median_booking_value - , subq_19.booking_value_p99 - , subq_19.discrete_booking_value_p99 - , subq_19.approximate_continuous_booking_value_p99 - , subq_19.approximate_discrete_booking_value_p99 + 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.ds_partitioned__day + , subq_7.ds_partitioned__week + , subq_7.ds_partitioned__month + , subq_7.ds_partitioned__quarter + , subq_7.ds_partitioned__year + , subq_7.ds_partitioned__extract_year + , subq_7.ds_partitioned__extract_quarter + , subq_7.ds_partitioned__extract_month + , subq_7.ds_partitioned__extract_day + , subq_7.ds_partitioned__extract_dow + , subq_7.ds_partitioned__extract_doy + , subq_7.paid_at__day + , subq_7.paid_at__week + , subq_7.paid_at__month + , subq_7.paid_at__quarter + , subq_7.paid_at__year + , subq_7.paid_at__extract_year + , subq_7.paid_at__extract_quarter + , subq_7.paid_at__extract_month + , subq_7.paid_at__extract_day + , subq_7.paid_at__extract_dow + , subq_7.paid_at__extract_doy + , subq_7.booking__ds__day + , subq_7.booking__ds__week + , subq_7.booking__ds__month + , subq_7.booking__ds__quarter + , subq_7.booking__ds__year + , subq_7.booking__ds__extract_year + , subq_7.booking__ds__extract_quarter + , subq_7.booking__ds__extract_month + , subq_7.booking__ds__extract_day + , subq_7.booking__ds__extract_dow + , subq_7.booking__ds__extract_doy + , subq_7.booking__ds_partitioned__day + , subq_7.booking__ds_partitioned__week + , subq_7.booking__ds_partitioned__month + , subq_7.booking__ds_partitioned__quarter + , subq_7.booking__ds_partitioned__year + , subq_7.booking__ds_partitioned__extract_year + , subq_7.booking__ds_partitioned__extract_quarter + , subq_7.booking__ds_partitioned__extract_month + , subq_7.booking__ds_partitioned__extract_day + , subq_7.booking__ds_partitioned__extract_dow + , subq_7.booking__ds_partitioned__extract_doy + , subq_7.booking__paid_at__day + , subq_7.booking__paid_at__week + , subq_7.booking__paid_at__month + , subq_7.booking__paid_at__quarter + , subq_7.booking__paid_at__year + , subq_7.booking__paid_at__extract_year + , subq_7.booking__paid_at__extract_quarter + , subq_7.booking__paid_at__extract_month + , subq_7.booking__paid_at__extract_day + , subq_7.booking__paid_at__extract_dow + , subq_7.booking__paid_at__extract_doy + , subq_7.metric_time__day + , subq_7.metric_time__week + , subq_7.metric_time__month + , subq_7.metric_time__quarter + , subq_7.metric_time__year + , subq_7.metric_time__extract_year + , subq_7.metric_time__extract_quarter + , subq_7.metric_time__extract_month + , subq_7.metric_time__extract_day + , subq_7.metric_time__extract_dow + , subq_7.metric_time__extract_doy + , subq_7.listing + , subq_7.guest + , subq_7.host + , subq_7.booking__listing + , subq_7.booking__guest + , subq_7.booking__host + , subq_7.is_instant + , subq_7.booking__is_instant + , subq_7.bookings + , subq_7.instant_bookings + , subq_7.booking_value + , subq_7.max_booking_value + , subq_7.min_booking_value + , subq_7.bookers + , subq_7.average_booking_value + , subq_7.referred_bookings + , subq_7.median_booking_value + , subq_7.booking_value_p99 + , subq_7.discrete_booking_value_p99 + , subq_7.approximate_continuous_booking_value_p99 + , subq_7.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_18.ds__day - , subq_18.ds__week - , subq_18.ds__month - , subq_18.ds__quarter - , subq_18.ds__year - , subq_18.ds__extract_year - , subq_18.ds__extract_quarter - , subq_18.ds__extract_month - , subq_18.ds__extract_day - , subq_18.ds__extract_dow - , subq_18.ds__extract_doy - , subq_18.ds_partitioned__day - , subq_18.ds_partitioned__week - , subq_18.ds_partitioned__month - , subq_18.ds_partitioned__quarter - , subq_18.ds_partitioned__year - , subq_18.ds_partitioned__extract_year - , subq_18.ds_partitioned__extract_quarter - , subq_18.ds_partitioned__extract_month - , subq_18.ds_partitioned__extract_day - , subq_18.ds_partitioned__extract_dow - , subq_18.ds_partitioned__extract_doy - , subq_18.paid_at__day - , subq_18.paid_at__week - , subq_18.paid_at__month - , subq_18.paid_at__quarter - , subq_18.paid_at__year - , subq_18.paid_at__extract_year - , subq_18.paid_at__extract_quarter - , subq_18.paid_at__extract_month - , subq_18.paid_at__extract_day - , subq_18.paid_at__extract_dow - , subq_18.paid_at__extract_doy - , subq_18.booking__ds__day - , subq_18.booking__ds__week - , subq_18.booking__ds__month - , subq_18.booking__ds__quarter - , subq_18.booking__ds__year - , subq_18.booking__ds__extract_year - , subq_18.booking__ds__extract_quarter - , subq_18.booking__ds__extract_month - , subq_18.booking__ds__extract_day - , subq_18.booking__ds__extract_dow - , subq_18.booking__ds__extract_doy - , subq_18.booking__ds_partitioned__day - , subq_18.booking__ds_partitioned__week - , subq_18.booking__ds_partitioned__month - , subq_18.booking__ds_partitioned__quarter - , subq_18.booking__ds_partitioned__year - , subq_18.booking__ds_partitioned__extract_year - , subq_18.booking__ds_partitioned__extract_quarter - , subq_18.booking__ds_partitioned__extract_month - , subq_18.booking__ds_partitioned__extract_day - , subq_18.booking__ds_partitioned__extract_dow - , subq_18.booking__ds_partitioned__extract_doy - , subq_18.booking__paid_at__day - , subq_18.booking__paid_at__week - , subq_18.booking__paid_at__month - , subq_18.booking__paid_at__quarter - , subq_18.booking__paid_at__year - , subq_18.booking__paid_at__extract_year - , subq_18.booking__paid_at__extract_quarter - , subq_18.booking__paid_at__extract_month - , subq_18.booking__paid_at__extract_day - , subq_18.booking__paid_at__extract_dow - , subq_18.booking__paid_at__extract_doy - , subq_18.ds__day AS metric_time__day - , subq_18.ds__week AS metric_time__week - , subq_18.ds__month AS metric_time__month - , subq_18.ds__quarter AS metric_time__quarter - , subq_18.ds__year AS metric_time__year - , subq_18.ds__extract_year AS metric_time__extract_year - , subq_18.ds__extract_quarter AS metric_time__extract_quarter - , subq_18.ds__extract_month AS metric_time__extract_month - , subq_18.ds__extract_day AS metric_time__extract_day - , subq_18.ds__extract_dow AS metric_time__extract_dow - , subq_18.ds__extract_doy AS metric_time__extract_doy - , subq_18.listing - , subq_18.guest - , subq_18.host - , subq_18.booking__listing - , subq_18.booking__guest - , subq_18.booking__host - , subq_18.is_instant - , subq_18.booking__is_instant - , subq_18.bookings - , subq_18.instant_bookings - , subq_18.booking_value - , subq_18.max_booking_value - , subq_18.min_booking_value - , subq_18.bookers - , subq_18.average_booking_value - , subq_18.referred_bookings - , subq_18.median_booking_value - , subq_18.booking_value_p99 - , subq_18.discrete_booking_value_p99 - , subq_18.approximate_continuous_booking_value_p99 - , subq_18.approximate_discrete_booking_value_p99 + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.ds_partitioned__day + , subq_6.ds_partitioned__week + , subq_6.ds_partitioned__month + , subq_6.ds_partitioned__quarter + , subq_6.ds_partitioned__year + , subq_6.ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy + , subq_6.paid_at__day + , subq_6.paid_at__week + , subq_6.paid_at__month + , subq_6.paid_at__quarter + , subq_6.paid_at__year + , subq_6.paid_at__extract_year + , subq_6.paid_at__extract_quarter + , subq_6.paid_at__extract_month + , subq_6.paid_at__extract_day + , subq_6.paid_at__extract_dow + , subq_6.paid_at__extract_doy + , subq_6.booking__ds__day + , subq_6.booking__ds__week + , subq_6.booking__ds__month + , subq_6.booking__ds__quarter + , subq_6.booking__ds__year + , subq_6.booking__ds__extract_year + , subq_6.booking__ds__extract_quarter + , subq_6.booking__ds__extract_month + , subq_6.booking__ds__extract_day + , subq_6.booking__ds__extract_dow + , subq_6.booking__ds__extract_doy + , subq_6.booking__ds_partitioned__day + , subq_6.booking__ds_partitioned__week + , subq_6.booking__ds_partitioned__month + , subq_6.booking__ds_partitioned__quarter + , subq_6.booking__ds_partitioned__year + , subq_6.booking__ds_partitioned__extract_year + , subq_6.booking__ds_partitioned__extract_quarter + , subq_6.booking__ds_partitioned__extract_month + , subq_6.booking__ds_partitioned__extract_day + , subq_6.booking__ds_partitioned__extract_dow + , subq_6.booking__ds_partitioned__extract_doy + , subq_6.booking__paid_at__day + , subq_6.booking__paid_at__week + , subq_6.booking__paid_at__month + , subq_6.booking__paid_at__quarter + , subq_6.booking__paid_at__year + , subq_6.booking__paid_at__extract_year + , subq_6.booking__paid_at__extract_quarter + , subq_6.booking__paid_at__extract_month + , subq_6.booking__paid_at__extract_day + , subq_6.booking__paid_at__extract_dow + , subq_6.booking__paid_at__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.listing + , subq_6.guest + , subq_6.host + , subq_6.booking__listing + , subq_6.booking__guest + , subq_6.booking__host + , subq_6.is_instant + , subq_6.booking__is_instant + , subq_6.bookings + , subq_6.instant_bookings + , subq_6.booking_value + , subq_6.max_booking_value + , subq_6.min_booking_value + , subq_6.bookers + , subq_6.average_booking_value + , subq_6.referred_bookings + , subq_6.median_booking_value + , subq_6.booking_value_p99 + , subq_6.discrete_booking_value_p99 + , subq_6.approximate_continuous_booking_value_p99 + , subq_6.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -342,86 +342,86 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_18 - ) subq_19 + ) subq_6 + ) subq_7 WHERE booking__is_instant - ) subq_20 - ) subq_21 + ) subq_8 + ) subq_9 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_23.listing - , subq_23.is_lux_latest + subq_11.listing + , subq_11.is_lux_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_22.ds__day - , subq_22.ds__week - , subq_22.ds__month - , subq_22.ds__quarter - , subq_22.ds__year - , subq_22.ds__extract_year - , subq_22.ds__extract_quarter - , subq_22.ds__extract_month - , subq_22.ds__extract_day - , subq_22.ds__extract_dow - , subq_22.ds__extract_doy - , subq_22.created_at__day - , subq_22.created_at__week - , subq_22.created_at__month - , subq_22.created_at__quarter - , subq_22.created_at__year - , subq_22.created_at__extract_year - , subq_22.created_at__extract_quarter - , subq_22.created_at__extract_month - , subq_22.created_at__extract_day - , subq_22.created_at__extract_dow - , subq_22.created_at__extract_doy - , subq_22.listing__ds__day - , subq_22.listing__ds__week - , subq_22.listing__ds__month - , subq_22.listing__ds__quarter - , subq_22.listing__ds__year - , subq_22.listing__ds__extract_year - , subq_22.listing__ds__extract_quarter - , subq_22.listing__ds__extract_month - , subq_22.listing__ds__extract_day - , subq_22.listing__ds__extract_dow - , subq_22.listing__ds__extract_doy - , subq_22.listing__created_at__day - , subq_22.listing__created_at__week - , subq_22.listing__created_at__month - , subq_22.listing__created_at__quarter - , subq_22.listing__created_at__year - , subq_22.listing__created_at__extract_year - , subq_22.listing__created_at__extract_quarter - , subq_22.listing__created_at__extract_month - , subq_22.listing__created_at__extract_day - , subq_22.listing__created_at__extract_dow - , subq_22.listing__created_at__extract_doy - , subq_22.ds__day AS metric_time__day - , subq_22.ds__week AS metric_time__week - , subq_22.ds__month AS metric_time__month - , subq_22.ds__quarter AS metric_time__quarter - , subq_22.ds__year AS metric_time__year - , subq_22.ds__extract_year AS metric_time__extract_year - , subq_22.ds__extract_quarter AS metric_time__extract_quarter - , subq_22.ds__extract_month AS metric_time__extract_month - , subq_22.ds__extract_day AS metric_time__extract_day - , subq_22.ds__extract_dow AS metric_time__extract_dow - , subq_22.ds__extract_doy AS metric_time__extract_doy - , subq_22.listing - , subq_22.user - , subq_22.listing__user - , subq_22.country_latest - , subq_22.is_lux_latest - , subq_22.capacity_latest - , subq_22.listing__country_latest - , subq_22.listing__is_lux_latest - , subq_22.listing__capacity_latest - , subq_22.listings - , subq_22.largest_listing - , subq_22.smallest_listing + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.created_at__day + , subq_10.created_at__week + , subq_10.created_at__month + , subq_10.created_at__quarter + , subq_10.created_at__year + , subq_10.created_at__extract_year + , subq_10.created_at__extract_quarter + , subq_10.created_at__extract_month + , subq_10.created_at__extract_day + , subq_10.created_at__extract_dow + , subq_10.created_at__extract_doy + , subq_10.listing__ds__day + , subq_10.listing__ds__week + , subq_10.listing__ds__month + , subq_10.listing__ds__quarter + , subq_10.listing__ds__year + , subq_10.listing__ds__extract_year + , subq_10.listing__ds__extract_quarter + , subq_10.listing__ds__extract_month + , subq_10.listing__ds__extract_day + , subq_10.listing__ds__extract_dow + , subq_10.listing__ds__extract_doy + , subq_10.listing__created_at__day + , subq_10.listing__created_at__week + , subq_10.listing__created_at__month + , subq_10.listing__created_at__quarter + , subq_10.listing__created_at__year + , subq_10.listing__created_at__extract_year + , subq_10.listing__created_at__extract_quarter + , subq_10.listing__created_at__extract_month + , subq_10.listing__created_at__extract_day + , subq_10.listing__created_at__extract_dow + , subq_10.listing__created_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.user + , subq_10.listing__user + , subq_10.country_latest + , subq_10.is_lux_latest + , subq_10.capacity_latest + , subq_10.listing__country_latest + , subq_10.listing__is_lux_latest + , subq_10.listing__capacity_latest + , subq_10.listings + , subq_10.largest_listing + , subq_10.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -482,257 +482,257 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_22 - ) subq_23 - ) subq_24 + ) subq_10 + ) subq_11 + ) subq_12 ON - subq_21.listing = subq_24.listing - ) subq_25 - ) subq_26 + subq_9.listing = subq_12.listing + ) subq_13 + ) subq_14 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_27 - ) subq_28 - ) subq_29 - ) subq_30 + ) subq_15 + ) subq_16 + ) subq_17 + ) subq_18 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_42.bookings + subq_30.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_41.bookings) AS bookings + SUM(subq_29.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_40.bookings + subq_28.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_39.booking__is_instant - , subq_39.listing__is_lux_latest - , subq_39.bookings + subq_27.booking__is_instant + , subq_27.listing__is_lux_latest + , subq_27.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_38.booking__is_instant - , subq_38.listing__is_lux_latest - , subq_38.bookings + subq_26.booking__is_instant + , subq_26.listing__is_lux_latest + , subq_26.bookings FROM ( -- Join Standard Outputs SELECT - subq_34.listing AS listing - , subq_34.booking__is_instant AS booking__is_instant - , subq_37.is_lux_latest AS listing__is_lux_latest - , subq_34.bookings AS bookings + subq_22.listing AS listing + , subq_22.booking__is_instant AS booking__is_instant + , subq_25.is_lux_latest AS listing__is_lux_latest + , subq_22.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_33.listing - , subq_33.booking__is_instant - , subq_33.bookings + subq_21.listing + , subq_21.booking__is_instant + , subq_21.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_32.ds__day - , subq_32.ds__week - , subq_32.ds__month - , subq_32.ds__quarter - , subq_32.ds__year - , subq_32.ds__extract_year - , subq_32.ds__extract_quarter - , subq_32.ds__extract_month - , subq_32.ds__extract_day - , subq_32.ds__extract_dow - , subq_32.ds__extract_doy - , subq_32.ds_partitioned__day - , subq_32.ds_partitioned__week - , subq_32.ds_partitioned__month - , subq_32.ds_partitioned__quarter - , subq_32.ds_partitioned__year - , subq_32.ds_partitioned__extract_year - , subq_32.ds_partitioned__extract_quarter - , subq_32.ds_partitioned__extract_month - , subq_32.ds_partitioned__extract_day - , subq_32.ds_partitioned__extract_dow - , subq_32.ds_partitioned__extract_doy - , subq_32.paid_at__day - , subq_32.paid_at__week - , subq_32.paid_at__month - , subq_32.paid_at__quarter - , subq_32.paid_at__year - , subq_32.paid_at__extract_year - , subq_32.paid_at__extract_quarter - , subq_32.paid_at__extract_month - , subq_32.paid_at__extract_day - , subq_32.paid_at__extract_dow - , subq_32.paid_at__extract_doy - , subq_32.booking__ds__day - , subq_32.booking__ds__week - , subq_32.booking__ds__month - , subq_32.booking__ds__quarter - , subq_32.booking__ds__year - , subq_32.booking__ds__extract_year - , subq_32.booking__ds__extract_quarter - , subq_32.booking__ds__extract_month - , subq_32.booking__ds__extract_day - , subq_32.booking__ds__extract_dow - , subq_32.booking__ds__extract_doy - , subq_32.booking__ds_partitioned__day - , subq_32.booking__ds_partitioned__week - , subq_32.booking__ds_partitioned__month - , subq_32.booking__ds_partitioned__quarter - , subq_32.booking__ds_partitioned__year - , subq_32.booking__ds_partitioned__extract_year - , subq_32.booking__ds_partitioned__extract_quarter - , subq_32.booking__ds_partitioned__extract_month - , subq_32.booking__ds_partitioned__extract_day - , subq_32.booking__ds_partitioned__extract_dow - , subq_32.booking__ds_partitioned__extract_doy - , subq_32.booking__paid_at__day - , subq_32.booking__paid_at__week - , subq_32.booking__paid_at__month - , subq_32.booking__paid_at__quarter - , subq_32.booking__paid_at__year - , subq_32.booking__paid_at__extract_year - , subq_32.booking__paid_at__extract_quarter - , subq_32.booking__paid_at__extract_month - , subq_32.booking__paid_at__extract_day - , subq_32.booking__paid_at__extract_dow - , subq_32.booking__paid_at__extract_doy - , subq_32.metric_time__day - , subq_32.metric_time__week - , subq_32.metric_time__month - , subq_32.metric_time__quarter - , subq_32.metric_time__year - , subq_32.metric_time__extract_year - , subq_32.metric_time__extract_quarter - , subq_32.metric_time__extract_month - , subq_32.metric_time__extract_day - , subq_32.metric_time__extract_dow - , subq_32.metric_time__extract_doy - , subq_32.listing - , subq_32.guest - , subq_32.host - , subq_32.booking__listing - , subq_32.booking__guest - , subq_32.booking__host - , subq_32.is_instant - , subq_32.booking__is_instant - , subq_32.bookings - , subq_32.instant_bookings - , subq_32.booking_value - , subq_32.max_booking_value - , subq_32.min_booking_value - , subq_32.bookers - , subq_32.average_booking_value - , subq_32.referred_bookings - , subq_32.median_booking_value - , subq_32.booking_value_p99 - , subq_32.discrete_booking_value_p99 - , subq_32.approximate_continuous_booking_value_p99 - , subq_32.approximate_discrete_booking_value_p99 + subq_20.ds__day + , subq_20.ds__week + , subq_20.ds__month + , subq_20.ds__quarter + , subq_20.ds__year + , subq_20.ds__extract_year + , subq_20.ds__extract_quarter + , subq_20.ds__extract_month + , subq_20.ds__extract_day + , subq_20.ds__extract_dow + , subq_20.ds__extract_doy + , subq_20.ds_partitioned__day + , subq_20.ds_partitioned__week + , subq_20.ds_partitioned__month + , subq_20.ds_partitioned__quarter + , subq_20.ds_partitioned__year + , subq_20.ds_partitioned__extract_year + , subq_20.ds_partitioned__extract_quarter + , subq_20.ds_partitioned__extract_month + , subq_20.ds_partitioned__extract_day + , subq_20.ds_partitioned__extract_dow + , subq_20.ds_partitioned__extract_doy + , subq_20.paid_at__day + , subq_20.paid_at__week + , subq_20.paid_at__month + , subq_20.paid_at__quarter + , subq_20.paid_at__year + , subq_20.paid_at__extract_year + , subq_20.paid_at__extract_quarter + , subq_20.paid_at__extract_month + , subq_20.paid_at__extract_day + , subq_20.paid_at__extract_dow + , subq_20.paid_at__extract_doy + , subq_20.booking__ds__day + , subq_20.booking__ds__week + , subq_20.booking__ds__month + , subq_20.booking__ds__quarter + , subq_20.booking__ds__year + , subq_20.booking__ds__extract_year + , subq_20.booking__ds__extract_quarter + , subq_20.booking__ds__extract_month + , subq_20.booking__ds__extract_day + , subq_20.booking__ds__extract_dow + , subq_20.booking__ds__extract_doy + , subq_20.booking__ds_partitioned__day + , subq_20.booking__ds_partitioned__week + , subq_20.booking__ds_partitioned__month + , subq_20.booking__ds_partitioned__quarter + , subq_20.booking__ds_partitioned__year + , subq_20.booking__ds_partitioned__extract_year + , subq_20.booking__ds_partitioned__extract_quarter + , subq_20.booking__ds_partitioned__extract_month + , subq_20.booking__ds_partitioned__extract_day + , subq_20.booking__ds_partitioned__extract_dow + , subq_20.booking__ds_partitioned__extract_doy + , subq_20.booking__paid_at__day + , subq_20.booking__paid_at__week + , subq_20.booking__paid_at__month + , subq_20.booking__paid_at__quarter + , subq_20.booking__paid_at__year + , subq_20.booking__paid_at__extract_year + , subq_20.booking__paid_at__extract_quarter + , subq_20.booking__paid_at__extract_month + , subq_20.booking__paid_at__extract_day + , subq_20.booking__paid_at__extract_dow + , subq_20.booking__paid_at__extract_doy + , subq_20.metric_time__day + , subq_20.metric_time__week + , subq_20.metric_time__month + , subq_20.metric_time__quarter + , subq_20.metric_time__year + , subq_20.metric_time__extract_year + , subq_20.metric_time__extract_quarter + , subq_20.metric_time__extract_month + , subq_20.metric_time__extract_day + , subq_20.metric_time__extract_dow + , subq_20.metric_time__extract_doy + , subq_20.listing + , subq_20.guest + , subq_20.host + , subq_20.booking__listing + , subq_20.booking__guest + , subq_20.booking__host + , subq_20.is_instant + , subq_20.booking__is_instant + , subq_20.bookings + , subq_20.instant_bookings + , subq_20.booking_value + , subq_20.max_booking_value + , subq_20.min_booking_value + , subq_20.bookers + , subq_20.average_booking_value + , subq_20.referred_bookings + , subq_20.median_booking_value + , subq_20.booking_value_p99 + , subq_20.discrete_booking_value_p99 + , subq_20.approximate_continuous_booking_value_p99 + , subq_20.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_31.ds__day - , subq_31.ds__week - , subq_31.ds__month - , subq_31.ds__quarter - , subq_31.ds__year - , subq_31.ds__extract_year - , subq_31.ds__extract_quarter - , subq_31.ds__extract_month - , subq_31.ds__extract_day - , subq_31.ds__extract_dow - , subq_31.ds__extract_doy - , subq_31.ds_partitioned__day - , subq_31.ds_partitioned__week - , subq_31.ds_partitioned__month - , subq_31.ds_partitioned__quarter - , subq_31.ds_partitioned__year - , subq_31.ds_partitioned__extract_year - , subq_31.ds_partitioned__extract_quarter - , subq_31.ds_partitioned__extract_month - , subq_31.ds_partitioned__extract_day - , subq_31.ds_partitioned__extract_dow - , subq_31.ds_partitioned__extract_doy - , subq_31.paid_at__day - , subq_31.paid_at__week - , subq_31.paid_at__month - , subq_31.paid_at__quarter - , subq_31.paid_at__year - , subq_31.paid_at__extract_year - , subq_31.paid_at__extract_quarter - , subq_31.paid_at__extract_month - , subq_31.paid_at__extract_day - , subq_31.paid_at__extract_dow - , subq_31.paid_at__extract_doy - , subq_31.booking__ds__day - , subq_31.booking__ds__week - , subq_31.booking__ds__month - , subq_31.booking__ds__quarter - , subq_31.booking__ds__year - , subq_31.booking__ds__extract_year - , subq_31.booking__ds__extract_quarter - , subq_31.booking__ds__extract_month - , subq_31.booking__ds__extract_day - , subq_31.booking__ds__extract_dow - , subq_31.booking__ds__extract_doy - , subq_31.booking__ds_partitioned__day - , subq_31.booking__ds_partitioned__week - , subq_31.booking__ds_partitioned__month - , subq_31.booking__ds_partitioned__quarter - , subq_31.booking__ds_partitioned__year - , subq_31.booking__ds_partitioned__extract_year - , subq_31.booking__ds_partitioned__extract_quarter - , subq_31.booking__ds_partitioned__extract_month - , subq_31.booking__ds_partitioned__extract_day - , subq_31.booking__ds_partitioned__extract_dow - , subq_31.booking__ds_partitioned__extract_doy - , subq_31.booking__paid_at__day - , subq_31.booking__paid_at__week - , subq_31.booking__paid_at__month - , subq_31.booking__paid_at__quarter - , subq_31.booking__paid_at__year - , subq_31.booking__paid_at__extract_year - , subq_31.booking__paid_at__extract_quarter - , subq_31.booking__paid_at__extract_month - , subq_31.booking__paid_at__extract_day - , subq_31.booking__paid_at__extract_dow - , subq_31.booking__paid_at__extract_doy - , subq_31.ds__day AS metric_time__day - , subq_31.ds__week AS metric_time__week - , subq_31.ds__month AS metric_time__month - , subq_31.ds__quarter AS metric_time__quarter - , subq_31.ds__year AS metric_time__year - , subq_31.ds__extract_year AS metric_time__extract_year - , subq_31.ds__extract_quarter AS metric_time__extract_quarter - , subq_31.ds__extract_month AS metric_time__extract_month - , subq_31.ds__extract_day AS metric_time__extract_day - , subq_31.ds__extract_dow AS metric_time__extract_dow - , subq_31.ds__extract_doy AS metric_time__extract_doy - , subq_31.listing - , subq_31.guest - , subq_31.host - , subq_31.booking__listing - , subq_31.booking__guest - , subq_31.booking__host - , subq_31.is_instant - , subq_31.booking__is_instant - , subq_31.bookings - , subq_31.instant_bookings - , subq_31.booking_value - , subq_31.max_booking_value - , subq_31.min_booking_value - , subq_31.bookers - , subq_31.average_booking_value - , subq_31.referred_bookings - , subq_31.median_booking_value - , subq_31.booking_value_p99 - , subq_31.discrete_booking_value_p99 - , subq_31.approximate_continuous_booking_value_p99 - , subq_31.approximate_discrete_booking_value_p99 + subq_19.ds__day + , subq_19.ds__week + , subq_19.ds__month + , subq_19.ds__quarter + , subq_19.ds__year + , subq_19.ds__extract_year + , subq_19.ds__extract_quarter + , subq_19.ds__extract_month + , subq_19.ds__extract_day + , subq_19.ds__extract_dow + , subq_19.ds__extract_doy + , subq_19.ds_partitioned__day + , subq_19.ds_partitioned__week + , subq_19.ds_partitioned__month + , subq_19.ds_partitioned__quarter + , subq_19.ds_partitioned__year + , subq_19.ds_partitioned__extract_year + , subq_19.ds_partitioned__extract_quarter + , subq_19.ds_partitioned__extract_month + , subq_19.ds_partitioned__extract_day + , subq_19.ds_partitioned__extract_dow + , subq_19.ds_partitioned__extract_doy + , subq_19.paid_at__day + , subq_19.paid_at__week + , subq_19.paid_at__month + , subq_19.paid_at__quarter + , subq_19.paid_at__year + , subq_19.paid_at__extract_year + , subq_19.paid_at__extract_quarter + , subq_19.paid_at__extract_month + , subq_19.paid_at__extract_day + , subq_19.paid_at__extract_dow + , subq_19.paid_at__extract_doy + , subq_19.booking__ds__day + , subq_19.booking__ds__week + , subq_19.booking__ds__month + , subq_19.booking__ds__quarter + , subq_19.booking__ds__year + , subq_19.booking__ds__extract_year + , subq_19.booking__ds__extract_quarter + , subq_19.booking__ds__extract_month + , subq_19.booking__ds__extract_day + , subq_19.booking__ds__extract_dow + , subq_19.booking__ds__extract_doy + , subq_19.booking__ds_partitioned__day + , subq_19.booking__ds_partitioned__week + , subq_19.booking__ds_partitioned__month + , subq_19.booking__ds_partitioned__quarter + , subq_19.booking__ds_partitioned__year + , subq_19.booking__ds_partitioned__extract_year + , subq_19.booking__ds_partitioned__extract_quarter + , subq_19.booking__ds_partitioned__extract_month + , subq_19.booking__ds_partitioned__extract_day + , subq_19.booking__ds_partitioned__extract_dow + , subq_19.booking__ds_partitioned__extract_doy + , subq_19.booking__paid_at__day + , subq_19.booking__paid_at__week + , subq_19.booking__paid_at__month + , subq_19.booking__paid_at__quarter + , subq_19.booking__paid_at__year + , subq_19.booking__paid_at__extract_year + , subq_19.booking__paid_at__extract_quarter + , subq_19.booking__paid_at__extract_month + , subq_19.booking__paid_at__extract_day + , subq_19.booking__paid_at__extract_dow + , subq_19.booking__paid_at__extract_doy + , subq_19.ds__day AS metric_time__day + , subq_19.ds__week AS metric_time__week + , subq_19.ds__month AS metric_time__month + , subq_19.ds__quarter AS metric_time__quarter + , subq_19.ds__year AS metric_time__year + , subq_19.ds__extract_year AS metric_time__extract_year + , subq_19.ds__extract_quarter AS metric_time__extract_quarter + , subq_19.ds__extract_month AS metric_time__extract_month + , subq_19.ds__extract_day AS metric_time__extract_day + , subq_19.ds__extract_dow AS metric_time__extract_dow + , subq_19.ds__extract_doy AS metric_time__extract_doy + , subq_19.listing + , subq_19.guest + , subq_19.host + , subq_19.booking__listing + , subq_19.booking__guest + , subq_19.booking__host + , subq_19.is_instant + , subq_19.booking__is_instant + , subq_19.bookings + , subq_19.instant_bookings + , subq_19.booking_value + , subq_19.max_booking_value + , subq_19.min_booking_value + , subq_19.bookers + , subq_19.average_booking_value + , subq_19.referred_bookings + , subq_19.median_booking_value + , subq_19.booking_value_p99 + , subq_19.discrete_booking_value_p99 + , subq_19.approximate_continuous_booking_value_p99 + , subq_19.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -825,86 +825,86 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_31 - ) subq_32 + ) subq_19 + ) subq_20 WHERE booking__is_instant - ) subq_33 - ) subq_34 + ) subq_21 + ) subq_22 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_36.listing - , subq_36.is_lux_latest + subq_24.listing + , subq_24.is_lux_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_35.ds__day - , subq_35.ds__week - , subq_35.ds__month - , subq_35.ds__quarter - , subq_35.ds__year - , subq_35.ds__extract_year - , subq_35.ds__extract_quarter - , subq_35.ds__extract_month - , subq_35.ds__extract_day - , subq_35.ds__extract_dow - , subq_35.ds__extract_doy - , subq_35.created_at__day - , subq_35.created_at__week - , subq_35.created_at__month - , subq_35.created_at__quarter - , subq_35.created_at__year - , subq_35.created_at__extract_year - , subq_35.created_at__extract_quarter - , subq_35.created_at__extract_month - , subq_35.created_at__extract_day - , subq_35.created_at__extract_dow - , subq_35.created_at__extract_doy - , subq_35.listing__ds__day - , subq_35.listing__ds__week - , subq_35.listing__ds__month - , subq_35.listing__ds__quarter - , subq_35.listing__ds__year - , subq_35.listing__ds__extract_year - , subq_35.listing__ds__extract_quarter - , subq_35.listing__ds__extract_month - , subq_35.listing__ds__extract_day - , subq_35.listing__ds__extract_dow - , subq_35.listing__ds__extract_doy - , subq_35.listing__created_at__day - , subq_35.listing__created_at__week - , subq_35.listing__created_at__month - , subq_35.listing__created_at__quarter - , subq_35.listing__created_at__year - , subq_35.listing__created_at__extract_year - , subq_35.listing__created_at__extract_quarter - , subq_35.listing__created_at__extract_month - , subq_35.listing__created_at__extract_day - , subq_35.listing__created_at__extract_dow - , subq_35.listing__created_at__extract_doy - , subq_35.ds__day AS metric_time__day - , subq_35.ds__week AS metric_time__week - , subq_35.ds__month AS metric_time__month - , subq_35.ds__quarter AS metric_time__quarter - , subq_35.ds__year AS metric_time__year - , subq_35.ds__extract_year AS metric_time__extract_year - , subq_35.ds__extract_quarter AS metric_time__extract_quarter - , subq_35.ds__extract_month AS metric_time__extract_month - , subq_35.ds__extract_day AS metric_time__extract_day - , subq_35.ds__extract_dow AS metric_time__extract_dow - , subq_35.ds__extract_doy AS metric_time__extract_doy - , subq_35.listing - , subq_35.user - , subq_35.listing__user - , subq_35.country_latest - , subq_35.is_lux_latest - , subq_35.capacity_latest - , subq_35.listing__country_latest - , subq_35.listing__is_lux_latest - , subq_35.listing__capacity_latest - , subq_35.listings - , subq_35.largest_listing - , subq_35.smallest_listing + subq_23.ds__day + , subq_23.ds__week + , subq_23.ds__month + , subq_23.ds__quarter + , subq_23.ds__year + , subq_23.ds__extract_year + , subq_23.ds__extract_quarter + , subq_23.ds__extract_month + , subq_23.ds__extract_day + , subq_23.ds__extract_dow + , subq_23.ds__extract_doy + , subq_23.created_at__day + , subq_23.created_at__week + , subq_23.created_at__month + , subq_23.created_at__quarter + , subq_23.created_at__year + , subq_23.created_at__extract_year + , subq_23.created_at__extract_quarter + , subq_23.created_at__extract_month + , subq_23.created_at__extract_day + , subq_23.created_at__extract_dow + , subq_23.created_at__extract_doy + , subq_23.listing__ds__day + , subq_23.listing__ds__week + , subq_23.listing__ds__month + , subq_23.listing__ds__quarter + , subq_23.listing__ds__year + , subq_23.listing__ds__extract_year + , subq_23.listing__ds__extract_quarter + , subq_23.listing__ds__extract_month + , subq_23.listing__ds__extract_day + , subq_23.listing__ds__extract_dow + , subq_23.listing__ds__extract_doy + , subq_23.listing__created_at__day + , subq_23.listing__created_at__week + , subq_23.listing__created_at__month + , subq_23.listing__created_at__quarter + , subq_23.listing__created_at__year + , subq_23.listing__created_at__extract_year + , subq_23.listing__created_at__extract_quarter + , subq_23.listing__created_at__extract_month + , subq_23.listing__created_at__extract_day + , subq_23.listing__created_at__extract_dow + , subq_23.listing__created_at__extract_doy + , subq_23.ds__day AS metric_time__day + , subq_23.ds__week AS metric_time__week + , subq_23.ds__month AS metric_time__month + , subq_23.ds__quarter AS metric_time__quarter + , subq_23.ds__year AS metric_time__year + , subq_23.ds__extract_year AS metric_time__extract_year + , subq_23.ds__extract_quarter AS metric_time__extract_quarter + , subq_23.ds__extract_month AS metric_time__extract_month + , subq_23.ds__extract_day AS metric_time__extract_day + , subq_23.ds__extract_dow AS metric_time__extract_dow + , subq_23.ds__extract_doy AS metric_time__extract_doy + , subq_23.listing + , subq_23.user + , subq_23.listing__user + , subq_23.country_latest + , subq_23.is_lux_latest + , subq_23.capacity_latest + , subq_23.listing__country_latest + , subq_23.listing__is_lux_latest + , subq_23.listing__capacity_latest + , subq_23.listings + , subq_23.largest_listing + , subq_23.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -965,242 +965,242 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_35 - ) subq_36 - ) subq_37 + ) subq_23 + ) subq_24 + ) subq_25 ON - subq_34.listing = subq_37.listing - ) subq_38 - ) subq_39 + subq_22.listing = subq_25.listing + ) subq_26 + ) subq_27 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_40 - ) subq_41 - ) subq_42 - ) subq_43 + ) subq_28 + ) subq_29 + ) subq_30 + ) subq_31 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_50.booking_value + subq_38.booking_value FROM ( -- Aggregate Measures SELECT - SUM(subq_49.booking_value) AS booking_value + SUM(subq_37.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value',] SELECT - subq_48.booking_value + subq_36.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_47.booking__is_instant - , subq_47.booking_value + subq_35.booking__is_instant + , subq_35.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant'] SELECT - subq_46.booking__is_instant - , subq_46.booking_value + subq_34.booking__is_instant + , subq_34.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_45.ds__day - , subq_45.ds__week - , subq_45.ds__month - , subq_45.ds__quarter - , subq_45.ds__year - , subq_45.ds__extract_year - , subq_45.ds__extract_quarter - , subq_45.ds__extract_month - , subq_45.ds__extract_day - , subq_45.ds__extract_dow - , subq_45.ds__extract_doy - , subq_45.ds_partitioned__day - , subq_45.ds_partitioned__week - , subq_45.ds_partitioned__month - , subq_45.ds_partitioned__quarter - , subq_45.ds_partitioned__year - , subq_45.ds_partitioned__extract_year - , subq_45.ds_partitioned__extract_quarter - , subq_45.ds_partitioned__extract_month - , subq_45.ds_partitioned__extract_day - , subq_45.ds_partitioned__extract_dow - , subq_45.ds_partitioned__extract_doy - , subq_45.paid_at__day - , subq_45.paid_at__week - , subq_45.paid_at__month - , subq_45.paid_at__quarter - , subq_45.paid_at__year - , subq_45.paid_at__extract_year - , subq_45.paid_at__extract_quarter - , subq_45.paid_at__extract_month - , subq_45.paid_at__extract_day - , subq_45.paid_at__extract_dow - , subq_45.paid_at__extract_doy - , subq_45.booking__ds__day - , subq_45.booking__ds__week - , subq_45.booking__ds__month - , subq_45.booking__ds__quarter - , subq_45.booking__ds__year - , subq_45.booking__ds__extract_year - , subq_45.booking__ds__extract_quarter - , subq_45.booking__ds__extract_month - , subq_45.booking__ds__extract_day - , subq_45.booking__ds__extract_dow - , subq_45.booking__ds__extract_doy - , subq_45.booking__ds_partitioned__day - , subq_45.booking__ds_partitioned__week - , subq_45.booking__ds_partitioned__month - , subq_45.booking__ds_partitioned__quarter - , subq_45.booking__ds_partitioned__year - , subq_45.booking__ds_partitioned__extract_year - , subq_45.booking__ds_partitioned__extract_quarter - , subq_45.booking__ds_partitioned__extract_month - , subq_45.booking__ds_partitioned__extract_day - , subq_45.booking__ds_partitioned__extract_dow - , subq_45.booking__ds_partitioned__extract_doy - , subq_45.booking__paid_at__day - , subq_45.booking__paid_at__week - , subq_45.booking__paid_at__month - , subq_45.booking__paid_at__quarter - , subq_45.booking__paid_at__year - , subq_45.booking__paid_at__extract_year - , subq_45.booking__paid_at__extract_quarter - , subq_45.booking__paid_at__extract_month - , subq_45.booking__paid_at__extract_day - , subq_45.booking__paid_at__extract_dow - , subq_45.booking__paid_at__extract_doy - , subq_45.metric_time__day - , subq_45.metric_time__week - , subq_45.metric_time__month - , subq_45.metric_time__quarter - , subq_45.metric_time__year - , subq_45.metric_time__extract_year - , subq_45.metric_time__extract_quarter - , subq_45.metric_time__extract_month - , subq_45.metric_time__extract_day - , subq_45.metric_time__extract_dow - , subq_45.metric_time__extract_doy - , subq_45.listing - , subq_45.guest - , subq_45.host - , subq_45.booking__listing - , subq_45.booking__guest - , subq_45.booking__host - , subq_45.is_instant - , subq_45.booking__is_instant - , subq_45.bookings - , subq_45.instant_bookings - , subq_45.booking_value - , subq_45.max_booking_value - , subq_45.min_booking_value - , subq_45.bookers - , subq_45.average_booking_value - , subq_45.referred_bookings - , subq_45.median_booking_value - , subq_45.booking_value_p99 - , subq_45.discrete_booking_value_p99 - , subq_45.approximate_continuous_booking_value_p99 - , subq_45.approximate_discrete_booking_value_p99 + subq_33.ds__day + , subq_33.ds__week + , subq_33.ds__month + , subq_33.ds__quarter + , subq_33.ds__year + , subq_33.ds__extract_year + , subq_33.ds__extract_quarter + , subq_33.ds__extract_month + , subq_33.ds__extract_day + , subq_33.ds__extract_dow + , subq_33.ds__extract_doy + , subq_33.ds_partitioned__day + , subq_33.ds_partitioned__week + , subq_33.ds_partitioned__month + , subq_33.ds_partitioned__quarter + , subq_33.ds_partitioned__year + , subq_33.ds_partitioned__extract_year + , subq_33.ds_partitioned__extract_quarter + , subq_33.ds_partitioned__extract_month + , subq_33.ds_partitioned__extract_day + , subq_33.ds_partitioned__extract_dow + , subq_33.ds_partitioned__extract_doy + , subq_33.paid_at__day + , subq_33.paid_at__week + , subq_33.paid_at__month + , subq_33.paid_at__quarter + , subq_33.paid_at__year + , subq_33.paid_at__extract_year + , subq_33.paid_at__extract_quarter + , subq_33.paid_at__extract_month + , subq_33.paid_at__extract_day + , subq_33.paid_at__extract_dow + , subq_33.paid_at__extract_doy + , subq_33.booking__ds__day + , subq_33.booking__ds__week + , subq_33.booking__ds__month + , subq_33.booking__ds__quarter + , subq_33.booking__ds__year + , subq_33.booking__ds__extract_year + , subq_33.booking__ds__extract_quarter + , subq_33.booking__ds__extract_month + , subq_33.booking__ds__extract_day + , subq_33.booking__ds__extract_dow + , subq_33.booking__ds__extract_doy + , subq_33.booking__ds_partitioned__day + , subq_33.booking__ds_partitioned__week + , subq_33.booking__ds_partitioned__month + , subq_33.booking__ds_partitioned__quarter + , subq_33.booking__ds_partitioned__year + , subq_33.booking__ds_partitioned__extract_year + , subq_33.booking__ds_partitioned__extract_quarter + , subq_33.booking__ds_partitioned__extract_month + , subq_33.booking__ds_partitioned__extract_day + , subq_33.booking__ds_partitioned__extract_dow + , subq_33.booking__ds_partitioned__extract_doy + , subq_33.booking__paid_at__day + , subq_33.booking__paid_at__week + , subq_33.booking__paid_at__month + , subq_33.booking__paid_at__quarter + , subq_33.booking__paid_at__year + , subq_33.booking__paid_at__extract_year + , subq_33.booking__paid_at__extract_quarter + , subq_33.booking__paid_at__extract_month + , subq_33.booking__paid_at__extract_day + , subq_33.booking__paid_at__extract_dow + , subq_33.booking__paid_at__extract_doy + , subq_33.metric_time__day + , subq_33.metric_time__week + , subq_33.metric_time__month + , subq_33.metric_time__quarter + , subq_33.metric_time__year + , subq_33.metric_time__extract_year + , subq_33.metric_time__extract_quarter + , subq_33.metric_time__extract_month + , subq_33.metric_time__extract_day + , subq_33.metric_time__extract_dow + , subq_33.metric_time__extract_doy + , subq_33.listing + , subq_33.guest + , subq_33.host + , subq_33.booking__listing + , subq_33.booking__guest + , subq_33.booking__host + , subq_33.is_instant + , subq_33.booking__is_instant + , subq_33.bookings + , subq_33.instant_bookings + , subq_33.booking_value + , subq_33.max_booking_value + , subq_33.min_booking_value + , subq_33.bookers + , subq_33.average_booking_value + , subq_33.referred_bookings + , subq_33.median_booking_value + , subq_33.booking_value_p99 + , subq_33.discrete_booking_value_p99 + , subq_33.approximate_continuous_booking_value_p99 + , subq_33.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_44.ds__day - , subq_44.ds__week - , subq_44.ds__month - , subq_44.ds__quarter - , subq_44.ds__year - , subq_44.ds__extract_year - , subq_44.ds__extract_quarter - , subq_44.ds__extract_month - , subq_44.ds__extract_day - , subq_44.ds__extract_dow - , subq_44.ds__extract_doy - , subq_44.ds_partitioned__day - , subq_44.ds_partitioned__week - , subq_44.ds_partitioned__month - , subq_44.ds_partitioned__quarter - , subq_44.ds_partitioned__year - , subq_44.ds_partitioned__extract_year - , subq_44.ds_partitioned__extract_quarter - , subq_44.ds_partitioned__extract_month - , subq_44.ds_partitioned__extract_day - , subq_44.ds_partitioned__extract_dow - , subq_44.ds_partitioned__extract_doy - , subq_44.paid_at__day - , subq_44.paid_at__week - , subq_44.paid_at__month - , subq_44.paid_at__quarter - , subq_44.paid_at__year - , subq_44.paid_at__extract_year - , subq_44.paid_at__extract_quarter - , subq_44.paid_at__extract_month - , subq_44.paid_at__extract_day - , subq_44.paid_at__extract_dow - , subq_44.paid_at__extract_doy - , subq_44.booking__ds__day - , subq_44.booking__ds__week - , subq_44.booking__ds__month - , subq_44.booking__ds__quarter - , subq_44.booking__ds__year - , subq_44.booking__ds__extract_year - , subq_44.booking__ds__extract_quarter - , subq_44.booking__ds__extract_month - , subq_44.booking__ds__extract_day - , subq_44.booking__ds__extract_dow - , subq_44.booking__ds__extract_doy - , subq_44.booking__ds_partitioned__day - , subq_44.booking__ds_partitioned__week - , subq_44.booking__ds_partitioned__month - , subq_44.booking__ds_partitioned__quarter - , subq_44.booking__ds_partitioned__year - , subq_44.booking__ds_partitioned__extract_year - , subq_44.booking__ds_partitioned__extract_quarter - , subq_44.booking__ds_partitioned__extract_month - , subq_44.booking__ds_partitioned__extract_day - , subq_44.booking__ds_partitioned__extract_dow - , subq_44.booking__ds_partitioned__extract_doy - , subq_44.booking__paid_at__day - , subq_44.booking__paid_at__week - , subq_44.booking__paid_at__month - , subq_44.booking__paid_at__quarter - , subq_44.booking__paid_at__year - , subq_44.booking__paid_at__extract_year - , subq_44.booking__paid_at__extract_quarter - , subq_44.booking__paid_at__extract_month - , subq_44.booking__paid_at__extract_day - , subq_44.booking__paid_at__extract_dow - , subq_44.booking__paid_at__extract_doy - , subq_44.ds__day AS metric_time__day - , subq_44.ds__week AS metric_time__week - , subq_44.ds__month AS metric_time__month - , subq_44.ds__quarter AS metric_time__quarter - , subq_44.ds__year AS metric_time__year - , subq_44.ds__extract_year AS metric_time__extract_year - , subq_44.ds__extract_quarter AS metric_time__extract_quarter - , subq_44.ds__extract_month AS metric_time__extract_month - , subq_44.ds__extract_day AS metric_time__extract_day - , subq_44.ds__extract_dow AS metric_time__extract_dow - , subq_44.ds__extract_doy AS metric_time__extract_doy - , subq_44.listing - , subq_44.guest - , subq_44.host - , subq_44.booking__listing - , subq_44.booking__guest - , subq_44.booking__host - , subq_44.is_instant - , subq_44.booking__is_instant - , subq_44.bookings - , subq_44.instant_bookings - , subq_44.booking_value - , subq_44.max_booking_value - , subq_44.min_booking_value - , subq_44.bookers - , subq_44.average_booking_value - , subq_44.referred_bookings - , subq_44.median_booking_value - , subq_44.booking_value_p99 - , subq_44.discrete_booking_value_p99 - , subq_44.approximate_continuous_booking_value_p99 - , subq_44.approximate_discrete_booking_value_p99 + subq_32.ds__day + , subq_32.ds__week + , subq_32.ds__month + , subq_32.ds__quarter + , subq_32.ds__year + , subq_32.ds__extract_year + , subq_32.ds__extract_quarter + , subq_32.ds__extract_month + , subq_32.ds__extract_day + , subq_32.ds__extract_dow + , subq_32.ds__extract_doy + , subq_32.ds_partitioned__day + , subq_32.ds_partitioned__week + , subq_32.ds_partitioned__month + , subq_32.ds_partitioned__quarter + , subq_32.ds_partitioned__year + , subq_32.ds_partitioned__extract_year + , subq_32.ds_partitioned__extract_quarter + , subq_32.ds_partitioned__extract_month + , subq_32.ds_partitioned__extract_day + , subq_32.ds_partitioned__extract_dow + , subq_32.ds_partitioned__extract_doy + , subq_32.paid_at__day + , subq_32.paid_at__week + , subq_32.paid_at__month + , subq_32.paid_at__quarter + , subq_32.paid_at__year + , subq_32.paid_at__extract_year + , subq_32.paid_at__extract_quarter + , subq_32.paid_at__extract_month + , subq_32.paid_at__extract_day + , subq_32.paid_at__extract_dow + , subq_32.paid_at__extract_doy + , subq_32.booking__ds__day + , subq_32.booking__ds__week + , subq_32.booking__ds__month + , subq_32.booking__ds__quarter + , subq_32.booking__ds__year + , subq_32.booking__ds__extract_year + , subq_32.booking__ds__extract_quarter + , subq_32.booking__ds__extract_month + , subq_32.booking__ds__extract_day + , subq_32.booking__ds__extract_dow + , subq_32.booking__ds__extract_doy + , subq_32.booking__ds_partitioned__day + , subq_32.booking__ds_partitioned__week + , subq_32.booking__ds_partitioned__month + , subq_32.booking__ds_partitioned__quarter + , subq_32.booking__ds_partitioned__year + , subq_32.booking__ds_partitioned__extract_year + , subq_32.booking__ds_partitioned__extract_quarter + , subq_32.booking__ds_partitioned__extract_month + , subq_32.booking__ds_partitioned__extract_day + , subq_32.booking__ds_partitioned__extract_dow + , subq_32.booking__ds_partitioned__extract_doy + , subq_32.booking__paid_at__day + , subq_32.booking__paid_at__week + , subq_32.booking__paid_at__month + , subq_32.booking__paid_at__quarter + , subq_32.booking__paid_at__year + , subq_32.booking__paid_at__extract_year + , subq_32.booking__paid_at__extract_quarter + , subq_32.booking__paid_at__extract_month + , subq_32.booking__paid_at__extract_day + , subq_32.booking__paid_at__extract_dow + , subq_32.booking__paid_at__extract_doy + , subq_32.ds__day AS metric_time__day + , subq_32.ds__week AS metric_time__week + , subq_32.ds__month AS metric_time__month + , subq_32.ds__quarter AS metric_time__quarter + , subq_32.ds__year AS metric_time__year + , subq_32.ds__extract_year AS metric_time__extract_year + , subq_32.ds__extract_quarter AS metric_time__extract_quarter + , subq_32.ds__extract_month AS metric_time__extract_month + , subq_32.ds__extract_day AS metric_time__extract_day + , subq_32.ds__extract_dow AS metric_time__extract_dow + , subq_32.ds__extract_doy AS metric_time__extract_doy + , subq_32.listing + , subq_32.guest + , subq_32.host + , subq_32.booking__listing + , subq_32.booking__guest + , subq_32.booking__host + , subq_32.is_instant + , subq_32.booking__is_instant + , subq_32.bookings + , subq_32.instant_bookings + , subq_32.booking_value + , subq_32.max_booking_value + , subq_32.min_booking_value + , subq_32.bookers + , subq_32.average_booking_value + , subq_32.referred_bookings + , subq_32.median_booking_value + , subq_32.booking_value_p99 + , subq_32.discrete_booking_value_p99 + , subq_32.approximate_continuous_booking_value_p99 + , subq_32.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -1293,15 +1293,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_44 - ) subq_45 + ) subq_32 + ) subq_33 WHERE booking__is_instant - ) subq_46 - ) subq_47 + ) subq_34 + ) subq_35 WHERE booking__is_instant - ) subq_48 - ) subq_49 - ) subq_50 - ) subq_51 - ) subq_52 -) subq_53 + ) subq_36 + ) subq_37 + ) subq_38 + ) subq_39 + ) subq_40 +) subq_41 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_filters__plan0_optimized.sql index a0fdc735bd..60a09b752b 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_filters__plan0_optimized.sql @@ -8,9 +8,9 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_66.average_booking_value) AS average_booking_value - , MAX(subq_79.bookings) AS bookings - , MAX(subq_87.booking_value) AS booking_value + MAX(subq_54.average_booking_value) AS average_booking_value + , MAX(subq_67.bookings) AS bookings + , MAX(subq_75.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value',] @@ -22,9 +22,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_57.booking__is_instant AS booking__is_instant + subq_45.booking__is_instant AS booking__is_instant , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_57.average_booking_value AS average_booking_value + , subq_45.average_booking_value AS average_booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'listing'] @@ -40,16 +40,16 @@ FROM ( , is_instant AS booking__is_instant , booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_55 + ) subq_43 WHERE booking__is_instant - ) subq_57 + ) subq_45 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_57.listing = listings_latest_src_28000.listing_id - ) subq_62 + subq_45.listing = listings_latest_src_28000.listing_id + ) subq_50 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_66 + ) subq_54 CROSS JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings',] @@ -61,9 +61,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_70.booking__is_instant AS booking__is_instant + subq_58.booking__is_instant AS booking__is_instant , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_70.bookings AS bookings + , subq_58.bookings AS bookings FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] @@ -79,16 +79,16 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_68 + ) subq_56 WHERE booking__is_instant - ) subq_70 + ) subq_58 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_70.listing = listings_latest_src_28000.listing_id - ) subq_75 + subq_58.listing = listings_latest_src_28000.listing_id + ) subq_63 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_79 + ) subq_67 CROSS JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value',] @@ -109,10 +109,10 @@ FROM ( is_instant AS booking__is_instant , booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_81 + ) subq_69 WHERE booking__is_instant - ) subq_83 + ) subq_71 WHERE booking__is_instant - ) subq_87 - ) subq_88 -) subq_89 + ) subq_75 + ) subq_76 +) subq_77 diff --git a/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimension_values_with_a_join_and_a_filter__plan0.sql b/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimension_values_with_a_join_and_a_filter__plan0.sql index 77721d6e67..d736ad0d03 100644 --- a/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimension_values_with_a_join_and_a_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimension_values_with_a_join_and_a_filter__plan0.sql @@ -1,127 +1,127 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest'] SELECT - subq_7.listing__is_lux_latest - , subq_7.user__home_state_latest + subq_4.listing__is_lux_latest + , subq_4.user__home_state_latest FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.created_at__day - , subq_6.created_at__week - , subq_6.created_at__month - , subq_6.created_at__quarter - , subq_6.created_at__year - , subq_6.created_at__extract_year - , subq_6.created_at__extract_quarter - , subq_6.created_at__extract_month - , subq_6.created_at__extract_day - , subq_6.created_at__extract_dow - , subq_6.created_at__extract_doy - , subq_6.listing__ds__day - , subq_6.listing__ds__week - , subq_6.listing__ds__month - , subq_6.listing__ds__quarter - , subq_6.listing__ds__year - , subq_6.listing__ds__extract_year - , subq_6.listing__ds__extract_quarter - , subq_6.listing__ds__extract_month - , subq_6.listing__ds__extract_day - , subq_6.listing__ds__extract_dow - , subq_6.listing__ds__extract_doy - , subq_6.listing__created_at__day - , subq_6.listing__created_at__week - , subq_6.listing__created_at__month - , subq_6.listing__created_at__quarter - , subq_6.listing__created_at__year - , subq_6.listing__created_at__extract_year - , subq_6.listing__created_at__extract_quarter - , subq_6.listing__created_at__extract_month - , subq_6.listing__created_at__extract_day - , subq_6.listing__created_at__extract_dow - , subq_6.listing__created_at__extract_doy - , subq_6.listing - , subq_6.user - , subq_6.listing__user - , subq_6.country_latest - , subq_6.is_lux_latest - , subq_6.capacity_latest - , subq_6.listing__country_latest - , subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.user__home_state_latest - , subq_6.listings - , subq_6.largest_listing - , subq_6.smallest_listing + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.created_at__day + , subq_3.created_at__week + , subq_3.created_at__month + , subq_3.created_at__quarter + , subq_3.created_at__year + , subq_3.created_at__extract_year + , subq_3.created_at__extract_quarter + , subq_3.created_at__extract_month + , subq_3.created_at__extract_day + , subq_3.created_at__extract_dow + , subq_3.created_at__extract_doy + , subq_3.listing__ds__day + , subq_3.listing__ds__week + , subq_3.listing__ds__month + , subq_3.listing__ds__quarter + , subq_3.listing__ds__year + , subq_3.listing__ds__extract_year + , subq_3.listing__ds__extract_quarter + , subq_3.listing__ds__extract_month + , subq_3.listing__ds__extract_day + , subq_3.listing__ds__extract_dow + , subq_3.listing__ds__extract_doy + , subq_3.listing__created_at__day + , subq_3.listing__created_at__week + , subq_3.listing__created_at__month + , subq_3.listing__created_at__quarter + , subq_3.listing__created_at__year + , subq_3.listing__created_at__extract_year + , subq_3.listing__created_at__extract_quarter + , subq_3.listing__created_at__extract_month + , subq_3.listing__created_at__extract_day + , subq_3.listing__created_at__extract_dow + , subq_3.listing__created_at__extract_doy + , subq_3.listing + , subq_3.user + , subq_3.listing__user + , subq_3.country_latest + , subq_3.is_lux_latest + , subq_3.capacity_latest + , subq_3.listing__country_latest + , subq_3.listing__is_lux_latest + , subq_3.listing__capacity_latest + , subq_3.user__home_state_latest + , subq_3.listings + , subq_3.largest_listing + , subq_3.smallest_listing FROM ( -- Join Standard Outputs SELECT - subq_2.ds__day AS ds__day - , subq_2.ds__week AS ds__week - , subq_2.ds__month AS ds__month - , subq_2.ds__quarter AS ds__quarter - , subq_2.ds__year AS ds__year - , subq_2.ds__extract_year AS ds__extract_year - , subq_2.ds__extract_quarter AS ds__extract_quarter - , subq_2.ds__extract_month AS ds__extract_month - , subq_2.ds__extract_day AS ds__extract_day - , subq_2.ds__extract_dow AS ds__extract_dow - , subq_2.ds__extract_doy AS ds__extract_doy - , subq_2.created_at__day AS created_at__day - , subq_2.created_at__week AS created_at__week - , subq_2.created_at__month AS created_at__month - , subq_2.created_at__quarter AS created_at__quarter - , subq_2.created_at__year AS created_at__year - , subq_2.created_at__extract_year AS created_at__extract_year - , subq_2.created_at__extract_quarter AS created_at__extract_quarter - , subq_2.created_at__extract_month AS created_at__extract_month - , subq_2.created_at__extract_day AS created_at__extract_day - , subq_2.created_at__extract_dow AS created_at__extract_dow - , subq_2.created_at__extract_doy AS created_at__extract_doy - , subq_2.listing__ds__day AS listing__ds__day - , subq_2.listing__ds__week AS listing__ds__week - , subq_2.listing__ds__month AS listing__ds__month - , subq_2.listing__ds__quarter AS listing__ds__quarter - , subq_2.listing__ds__year AS listing__ds__year - , subq_2.listing__ds__extract_year AS listing__ds__extract_year - , subq_2.listing__ds__extract_quarter AS listing__ds__extract_quarter - , subq_2.listing__ds__extract_month AS listing__ds__extract_month - , subq_2.listing__ds__extract_day AS listing__ds__extract_day - , subq_2.listing__ds__extract_dow AS listing__ds__extract_dow - , subq_2.listing__ds__extract_doy AS listing__ds__extract_doy - , subq_2.listing__created_at__day AS listing__created_at__day - , subq_2.listing__created_at__week AS listing__created_at__week - , subq_2.listing__created_at__month AS listing__created_at__month - , subq_2.listing__created_at__quarter AS listing__created_at__quarter - , subq_2.listing__created_at__year AS listing__created_at__year - , subq_2.listing__created_at__extract_year AS listing__created_at__extract_year - , subq_2.listing__created_at__extract_quarter AS listing__created_at__extract_quarter - , subq_2.listing__created_at__extract_month AS listing__created_at__extract_month - , subq_2.listing__created_at__extract_day AS listing__created_at__extract_day - , subq_2.listing__created_at__extract_dow AS listing__created_at__extract_dow - , subq_2.listing__created_at__extract_doy AS listing__created_at__extract_doy - , subq_2.listing AS listing - , subq_2.user AS user - , subq_2.listing__user AS listing__user - , subq_2.country_latest AS country_latest - , subq_2.is_lux_latest AS is_lux_latest - , subq_2.capacity_latest AS capacity_latest - , subq_2.listing__country_latest AS listing__country_latest - , subq_2.listing__is_lux_latest AS listing__is_lux_latest - , subq_2.listing__capacity_latest AS listing__capacity_latest - , subq_5.home_state_latest AS user__home_state_latest - , subq_2.listings AS listings - , subq_2.largest_listing AS largest_listing - , subq_2.smallest_listing AS smallest_listing + subq_0.ds__day AS ds__day + , subq_0.ds__week AS ds__week + , subq_0.ds__month AS ds__month + , subq_0.ds__quarter AS ds__quarter + , subq_0.ds__year AS ds__year + , subq_0.ds__extract_year AS ds__extract_year + , subq_0.ds__extract_quarter AS ds__extract_quarter + , subq_0.ds__extract_month AS ds__extract_month + , subq_0.ds__extract_day AS ds__extract_day + , subq_0.ds__extract_dow AS ds__extract_dow + , subq_0.ds__extract_doy AS ds__extract_doy + , subq_0.created_at__day AS created_at__day + , subq_0.created_at__week AS created_at__week + , subq_0.created_at__month AS created_at__month + , subq_0.created_at__quarter AS created_at__quarter + , subq_0.created_at__year AS created_at__year + , subq_0.created_at__extract_year AS created_at__extract_year + , subq_0.created_at__extract_quarter AS created_at__extract_quarter + , subq_0.created_at__extract_month AS created_at__extract_month + , subq_0.created_at__extract_day AS created_at__extract_day + , subq_0.created_at__extract_dow AS created_at__extract_dow + , subq_0.created_at__extract_doy AS created_at__extract_doy + , subq_0.listing__ds__day AS listing__ds__day + , subq_0.listing__ds__week AS listing__ds__week + , subq_0.listing__ds__month AS listing__ds__month + , subq_0.listing__ds__quarter AS listing__ds__quarter + , subq_0.listing__ds__year AS listing__ds__year + , subq_0.listing__ds__extract_year AS listing__ds__extract_year + , subq_0.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_0.listing__ds__extract_month AS listing__ds__extract_month + , subq_0.listing__ds__extract_day AS listing__ds__extract_day + , subq_0.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_0.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_0.listing__created_at__day AS listing__created_at__day + , subq_0.listing__created_at__week AS listing__created_at__week + , subq_0.listing__created_at__month AS listing__created_at__month + , subq_0.listing__created_at__quarter AS listing__created_at__quarter + , subq_0.listing__created_at__year AS listing__created_at__year + , subq_0.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_0.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_0.listing AS listing + , subq_0.user AS user + , subq_0.listing__user AS listing__user + , subq_0.country_latest AS country_latest + , subq_0.is_lux_latest AS is_lux_latest + , subq_0.capacity_latest AS capacity_latest + , subq_0.listing__country_latest AS listing__country_latest + , subq_0.listing__is_lux_latest AS listing__is_lux_latest + , subq_0.listing__capacity_latest AS listing__capacity_latest + , subq_2.home_state_latest AS user__home_state_latest + , subq_0.listings AS listings + , subq_0.largest_listing AS largest_listing + , subq_0.smallest_listing AS smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -182,78 +182,48 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_2 + ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_4.user - , subq_4.home_state_latest + subq_1.user + , subq_1.home_state_latest FROM ( - -- Constrain Output with WHERE + -- Read Elements From Semantic Model 'users_latest' SELECT - subq_3.ds_latest__day - , subq_3.ds_latest__week - , subq_3.ds_latest__month - , subq_3.ds_latest__quarter - , subq_3.ds_latest__year - , subq_3.ds_latest__extract_year - , subq_3.ds_latest__extract_quarter - , subq_3.ds_latest__extract_month - , subq_3.ds_latest__extract_day - , subq_3.ds_latest__extract_dow - , subq_3.ds_latest__extract_doy - , subq_3.user__ds_latest__day - , subq_3.user__ds_latest__week - , subq_3.user__ds_latest__month - , subq_3.user__ds_latest__quarter - , subq_3.user__ds_latest__year - , subq_3.user__ds_latest__extract_year - , subq_3.user__ds_latest__extract_quarter - , subq_3.user__ds_latest__extract_month - , subq_3.user__ds_latest__extract_day - , subq_3.user__ds_latest__extract_dow - , subq_3.user__ds_latest__extract_doy - , subq_3.user - , subq_3.home_state_latest - , subq_3.user__home_state_latest - FROM ( - -- Read Elements From Semantic Model 'users_latest' - SELECT - DATE_TRUNC('day', users_latest_src_28000.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28000.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28000.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28000.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28000.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28000.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28000.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28000.ds) AS ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_28000.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28000.ds) AS ds_latest__extract_doy - , users_latest_src_28000.home_state_latest - , DATE_TRUNC('day', users_latest_src_28000.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28000.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28000.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28000.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28000.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28000.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28000.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28000.ds) AS user__ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_28000.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28000.ds) AS user__ds_latest__extract_doy - , users_latest_src_28000.home_state_latest AS user__home_state_latest - , users_latest_src_28000.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_3 - WHERE user__home_state_latest = 'us' - ) subq_4 - ) subq_5 + DATE_TRUNC('day', users_latest_src_28000.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_28000.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_28000.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_28000.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_28000.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_28000.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_28000.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_28000.ds) AS ds_latest__extract_day + , EXTRACT(isodow FROM users_latest_src_28000.ds) AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_28000.ds) AS ds_latest__extract_doy + , users_latest_src_28000.home_state_latest + , DATE_TRUNC('day', users_latest_src_28000.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_28000.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_28000.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_28000.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_28000.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_28000.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_28000.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_28000.ds) AS user__ds_latest__extract_day + , EXTRACT(isodow FROM users_latest_src_28000.ds) AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_28000.ds) AS user__ds_latest__extract_doy + , users_latest_src_28000.home_state_latest AS user__home_state_latest + , users_latest_src_28000.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_28000 + ) subq_1 + ) subq_2 ON - subq_2.user = subq_5.user - ) subq_6 + subq_0.user = subq_2.user + ) subq_3 WHERE user__home_state_latest = 'us' -) subq_7 +) subq_4 GROUP BY - subq_7.listing__is_lux_latest - , subq_7.user__home_state_latest + subq_4.listing__is_lux_latest + , subq_4.user__home_state_latest diff --git a/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql index c77b46c217..e54eaffeb6 100644 --- a/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql @@ -7,27 +7,13 @@ FROM ( -- Join Standard Outputs SELECT listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_11.home_state_latest AS user__home_state_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest FROM ***************************.dim_listings_latest listings_latest_src_28000 - FULL OUTER JOIN ( - -- Constrain Output with WHERE - -- Pass Only Elements: ['home_state_latest', 'user'] - SELECT - subq_9.user - , home_state_latest - FROM ( - -- Read Elements From Semantic Model 'users_latest' - SELECT - home_state_latest - , home_state_latest AS user__home_state_latest - , user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_9 - WHERE user__home_state_latest = 'us' - ) subq_11 + FULL OUTER JOIN + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28000.user_id = subq_11.user -) subq_12 + listings_latest_src_28000.user_id = users_latest_src_28000.user_id +) subq_8 WHERE user__home_state_latest = 'us' GROUP BY listing__is_lux_latest diff --git a/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/test_dimension_values_with_a_join_and_a_filter__plan0.xml b/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/test_dimension_values_with_a_join_and_a_filter__plan0.xml index de0e529736..ff2c1449de 100644 --- a/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/test_dimension_values_with_a_join_and_a_filter__plan0.xml +++ b/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/test_dimension_values_with_a_join_and_a_filter__plan0.xml @@ -1,428 +1,418 @@ - + - + - - + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - + + - + - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - - - - - - - - - - + + + + + + + + + + - - + + @@ -670,281 +660,149 @@ - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/DuckDB/test_inner_query_single_hop__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/DuckDB/test_inner_query_single_hop__plan0.sql index 795a470587..7e727a5e96 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/DuckDB/test_inner_query_single_hop__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/DuckDB/test_inner_query_single_hop__plan0.sql @@ -1,76 +1,76 @@ -- Compute Metrics via Expressions SELECT - subq_27.third_hop_count + subq_25.third_hop_count FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_26.third_hop_count) AS third_hop_count + COUNT(DISTINCT subq_24.third_hop_count) AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count',] SELECT - subq_25.third_hop_count + subq_23.third_hop_count FROM ( -- Constrain Output with WHERE SELECT - subq_24.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_24.third_hop_count + subq_22.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_22.third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers'] SELECT - subq_23.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_23.third_hop_count + subq_21.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_21.third_hop_count FROM ( -- Join Standard Outputs SELECT - subq_13.customer_third_hop_id AS customer_third_hop_id - , subq_22.customer_id__customer_third_hop_id AS customer_third_hop_id__customer_id__customer_third_hop_id - , subq_22.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_13.third_hop_count AS third_hop_count + subq_11.customer_third_hop_id AS customer_third_hop_id + , subq_20.customer_id__customer_third_hop_id AS customer_third_hop_id__customer_id__customer_third_hop_id + , subq_20.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_11.third_hop_count AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id'] SELECT - subq_12.customer_third_hop_id - , subq_12.third_hop_count + subq_10.customer_third_hop_id + , subq_10.third_hop_count FROM ( -- Metric Time Dimension 'third_hop_ds' SELECT - subq_11.third_hop_ds__day - , subq_11.third_hop_ds__week - , subq_11.third_hop_ds__month - , subq_11.third_hop_ds__quarter - , subq_11.third_hop_ds__year - , subq_11.third_hop_ds__extract_year - , subq_11.third_hop_ds__extract_quarter - , subq_11.third_hop_ds__extract_month - , subq_11.third_hop_ds__extract_day - , subq_11.third_hop_ds__extract_dow - , subq_11.third_hop_ds__extract_doy - , subq_11.customer_third_hop_id__third_hop_ds__day - , subq_11.customer_third_hop_id__third_hop_ds__week - , subq_11.customer_third_hop_id__third_hop_ds__month - , subq_11.customer_third_hop_id__third_hop_ds__quarter - , subq_11.customer_third_hop_id__third_hop_ds__year - , subq_11.customer_third_hop_id__third_hop_ds__extract_year - , subq_11.customer_third_hop_id__third_hop_ds__extract_quarter - , subq_11.customer_third_hop_id__third_hop_ds__extract_month - , subq_11.customer_third_hop_id__third_hop_ds__extract_day - , subq_11.customer_third_hop_id__third_hop_ds__extract_dow - , subq_11.customer_third_hop_id__third_hop_ds__extract_doy - , subq_11.third_hop_ds__day AS metric_time__day - , subq_11.third_hop_ds__week AS metric_time__week - , subq_11.third_hop_ds__month AS metric_time__month - , subq_11.third_hop_ds__quarter AS metric_time__quarter - , subq_11.third_hop_ds__year AS metric_time__year - , subq_11.third_hop_ds__extract_year AS metric_time__extract_year - , subq_11.third_hop_ds__extract_quarter AS metric_time__extract_quarter - , subq_11.third_hop_ds__extract_month AS metric_time__extract_month - , subq_11.third_hop_ds__extract_day AS metric_time__extract_day - , subq_11.third_hop_ds__extract_dow AS metric_time__extract_dow - , subq_11.third_hop_ds__extract_doy AS metric_time__extract_doy - , subq_11.customer_third_hop_id - , subq_11.value - , subq_11.customer_third_hop_id__value - , subq_11.third_hop_count + subq_9.third_hop_ds__day + , subq_9.third_hop_ds__week + , subq_9.third_hop_ds__month + , subq_9.third_hop_ds__quarter + , subq_9.third_hop_ds__year + , subq_9.third_hop_ds__extract_year + , subq_9.third_hop_ds__extract_quarter + , subq_9.third_hop_ds__extract_month + , subq_9.third_hop_ds__extract_day + , subq_9.third_hop_ds__extract_dow + , subq_9.third_hop_ds__extract_doy + , subq_9.customer_third_hop_id__third_hop_ds__day + , subq_9.customer_third_hop_id__third_hop_ds__week + , subq_9.customer_third_hop_id__third_hop_ds__month + , subq_9.customer_third_hop_id__third_hop_ds__quarter + , subq_9.customer_third_hop_id__third_hop_ds__year + , subq_9.customer_third_hop_id__third_hop_ds__extract_year + , subq_9.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_9.customer_third_hop_id__third_hop_ds__extract_month + , subq_9.customer_third_hop_id__third_hop_ds__extract_day + , subq_9.customer_third_hop_id__third_hop_ds__extract_dow + , subq_9.customer_third_hop_id__third_hop_ds__extract_doy + , subq_9.third_hop_ds__day AS metric_time__day + , subq_9.third_hop_ds__week AS metric_time__week + , subq_9.third_hop_ds__month AS metric_time__month + , subq_9.third_hop_ds__quarter AS metric_time__quarter + , subq_9.third_hop_ds__year AS metric_time__year + , subq_9.third_hop_ds__extract_year AS metric_time__extract_year + , subq_9.third_hop_ds__extract_quarter AS metric_time__extract_quarter + , subq_9.third_hop_ds__extract_month AS metric_time__extract_month + , subq_9.third_hop_ds__extract_day AS metric_time__extract_day + , subq_9.third_hop_ds__extract_dow AS metric_time__extract_dow + , subq_9.third_hop_ds__extract_doy AS metric_time__extract_doy + , subq_9.customer_third_hop_id + , subq_9.value + , subq_9.customer_third_hop_id__value + , subq_9.third_hop_count FROM ( -- Read Elements From Semantic Model 'third_hop_table' SELECT @@ -101,151 +101,151 @@ FROM ( , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_doy , third_hop_table_src_22000.customer_third_hop_id FROM ***************************.third_hop_table third_hop_table_src_22000 - ) subq_11 - ) subq_12 - ) subq_13 + ) subq_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['customer_id__customer_third_hop_id', 'customer_id__customer_third_hop_id__paraguayan_customers'] SELECT - subq_21.customer_id__customer_third_hop_id - , subq_21.customer_id__customer_third_hop_id__paraguayan_customers + subq_19.customer_id__customer_third_hop_id + , subq_19.customer_id__customer_third_hop_id__paraguayan_customers FROM ( -- Compute Metrics via Expressions SELECT - subq_20.customer_id__customer_third_hop_id - , subq_20.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers + subq_18.customer_id__customer_third_hop_id + , subq_18.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers FROM ( -- Aggregate Measures SELECT - subq_19.customer_id__customer_third_hop_id - , SUM(subq_19.customers_with_other_data) AS customers_with_other_data + subq_17.customer_id__customer_third_hop_id + , SUM(subq_17.customers_with_other_data) AS customers_with_other_data FROM ( -- Pass Only Elements: ['customers_with_other_data', 'customer_id__customer_third_hop_id'] SELECT - subq_18.customer_id__customer_third_hop_id - , subq_18.customers_with_other_data + subq_16.customer_id__customer_third_hop_id + , subq_16.customers_with_other_data FROM ( -- Constrain Output with WHERE SELECT - subq_17.customer_id__customer_third_hop_id - , subq_17.customer_id__country - , subq_17.customers_with_other_data + subq_15.customer_id__customer_third_hop_id + , subq_15.customer_id__country + , subq_15.customers_with_other_data FROM ( -- Pass Only Elements: ['customers_with_other_data', 'customer_id__country', 'customer_id__customer_third_hop_id'] SELECT - subq_16.customer_id__customer_third_hop_id - , subq_16.customer_id__country - , subq_16.customers_with_other_data + subq_14.customer_id__customer_third_hop_id + , subq_14.customer_id__country + , subq_14.customers_with_other_data FROM ( -- Constrain Output with WHERE SELECT - subq_15.acquired_ds__day - , subq_15.acquired_ds__week - , subq_15.acquired_ds__month - , subq_15.acquired_ds__quarter - , subq_15.acquired_ds__year - , subq_15.acquired_ds__extract_year - , subq_15.acquired_ds__extract_quarter - , subq_15.acquired_ds__extract_month - , subq_15.acquired_ds__extract_day - , subq_15.acquired_ds__extract_dow - , subq_15.acquired_ds__extract_doy - , subq_15.customer_id__acquired_ds__day - , subq_15.customer_id__acquired_ds__week - , subq_15.customer_id__acquired_ds__month - , subq_15.customer_id__acquired_ds__quarter - , subq_15.customer_id__acquired_ds__year - , subq_15.customer_id__acquired_ds__extract_year - , subq_15.customer_id__acquired_ds__extract_quarter - , subq_15.customer_id__acquired_ds__extract_month - , subq_15.customer_id__acquired_ds__extract_day - , subq_15.customer_id__acquired_ds__extract_dow - , subq_15.customer_id__acquired_ds__extract_doy - , subq_15.customer_third_hop_id__acquired_ds__day - , subq_15.customer_third_hop_id__acquired_ds__week - , subq_15.customer_third_hop_id__acquired_ds__month - , subq_15.customer_third_hop_id__acquired_ds__quarter - , subq_15.customer_third_hop_id__acquired_ds__year - , subq_15.customer_third_hop_id__acquired_ds__extract_year - , subq_15.customer_third_hop_id__acquired_ds__extract_quarter - , subq_15.customer_third_hop_id__acquired_ds__extract_month - , subq_15.customer_third_hop_id__acquired_ds__extract_day - , subq_15.customer_third_hop_id__acquired_ds__extract_dow - , subq_15.customer_third_hop_id__acquired_ds__extract_doy - , subq_15.metric_time__day - , subq_15.metric_time__week - , subq_15.metric_time__month - , subq_15.metric_time__quarter - , subq_15.metric_time__year - , subq_15.metric_time__extract_year - , subq_15.metric_time__extract_quarter - , subq_15.metric_time__extract_month - , subq_15.metric_time__extract_day - , subq_15.metric_time__extract_dow - , subq_15.metric_time__extract_doy - , subq_15.customer_id - , subq_15.customer_third_hop_id - , subq_15.customer_id__customer_third_hop_id - , subq_15.customer_third_hop_id__customer_id - , subq_15.country - , subq_15.customer_id__country - , subq_15.customer_third_hop_id__country - , subq_15.customers_with_other_data + subq_13.acquired_ds__day + , subq_13.acquired_ds__week + , subq_13.acquired_ds__month + , subq_13.acquired_ds__quarter + , subq_13.acquired_ds__year + , subq_13.acquired_ds__extract_year + , subq_13.acquired_ds__extract_quarter + , subq_13.acquired_ds__extract_month + , subq_13.acquired_ds__extract_day + , subq_13.acquired_ds__extract_dow + , subq_13.acquired_ds__extract_doy + , subq_13.customer_id__acquired_ds__day + , subq_13.customer_id__acquired_ds__week + , subq_13.customer_id__acquired_ds__month + , subq_13.customer_id__acquired_ds__quarter + , subq_13.customer_id__acquired_ds__year + , subq_13.customer_id__acquired_ds__extract_year + , subq_13.customer_id__acquired_ds__extract_quarter + , subq_13.customer_id__acquired_ds__extract_month + , subq_13.customer_id__acquired_ds__extract_day + , subq_13.customer_id__acquired_ds__extract_dow + , subq_13.customer_id__acquired_ds__extract_doy + , subq_13.customer_third_hop_id__acquired_ds__day + , subq_13.customer_third_hop_id__acquired_ds__week + , subq_13.customer_third_hop_id__acquired_ds__month + , subq_13.customer_third_hop_id__acquired_ds__quarter + , subq_13.customer_third_hop_id__acquired_ds__year + , subq_13.customer_third_hop_id__acquired_ds__extract_year + , subq_13.customer_third_hop_id__acquired_ds__extract_quarter + , subq_13.customer_third_hop_id__acquired_ds__extract_month + , subq_13.customer_third_hop_id__acquired_ds__extract_day + , subq_13.customer_third_hop_id__acquired_ds__extract_dow + , subq_13.customer_third_hop_id__acquired_ds__extract_doy + , subq_13.metric_time__day + , subq_13.metric_time__week + , subq_13.metric_time__month + , subq_13.metric_time__quarter + , subq_13.metric_time__year + , subq_13.metric_time__extract_year + , subq_13.metric_time__extract_quarter + , subq_13.metric_time__extract_month + , subq_13.metric_time__extract_day + , subq_13.metric_time__extract_dow + , subq_13.metric_time__extract_doy + , subq_13.customer_id + , subq_13.customer_third_hop_id + , subq_13.customer_id__customer_third_hop_id + , subq_13.customer_third_hop_id__customer_id + , subq_13.country + , subq_13.customer_id__country + , subq_13.customer_third_hop_id__country + , subq_13.customers_with_other_data FROM ( -- Metric Time Dimension 'acquired_ds' SELECT - subq_14.acquired_ds__day - , subq_14.acquired_ds__week - , subq_14.acquired_ds__month - , subq_14.acquired_ds__quarter - , subq_14.acquired_ds__year - , subq_14.acquired_ds__extract_year - , subq_14.acquired_ds__extract_quarter - , subq_14.acquired_ds__extract_month - , subq_14.acquired_ds__extract_day - , subq_14.acquired_ds__extract_dow - , subq_14.acquired_ds__extract_doy - , subq_14.customer_id__acquired_ds__day - , subq_14.customer_id__acquired_ds__week - , subq_14.customer_id__acquired_ds__month - , subq_14.customer_id__acquired_ds__quarter - , subq_14.customer_id__acquired_ds__year - , subq_14.customer_id__acquired_ds__extract_year - , subq_14.customer_id__acquired_ds__extract_quarter - , subq_14.customer_id__acquired_ds__extract_month - , subq_14.customer_id__acquired_ds__extract_day - , subq_14.customer_id__acquired_ds__extract_dow - , subq_14.customer_id__acquired_ds__extract_doy - , subq_14.customer_third_hop_id__acquired_ds__day - , subq_14.customer_third_hop_id__acquired_ds__week - , subq_14.customer_third_hop_id__acquired_ds__month - , subq_14.customer_third_hop_id__acquired_ds__quarter - , subq_14.customer_third_hop_id__acquired_ds__year - , subq_14.customer_third_hop_id__acquired_ds__extract_year - , subq_14.customer_third_hop_id__acquired_ds__extract_quarter - , subq_14.customer_third_hop_id__acquired_ds__extract_month - , subq_14.customer_third_hop_id__acquired_ds__extract_day - , subq_14.customer_third_hop_id__acquired_ds__extract_dow - , subq_14.customer_third_hop_id__acquired_ds__extract_doy - , subq_14.acquired_ds__day AS metric_time__day - , subq_14.acquired_ds__week AS metric_time__week - , subq_14.acquired_ds__month AS metric_time__month - , subq_14.acquired_ds__quarter AS metric_time__quarter - , subq_14.acquired_ds__year AS metric_time__year - , subq_14.acquired_ds__extract_year AS metric_time__extract_year - , subq_14.acquired_ds__extract_quarter AS metric_time__extract_quarter - , subq_14.acquired_ds__extract_month AS metric_time__extract_month - , subq_14.acquired_ds__extract_day AS metric_time__extract_day - , subq_14.acquired_ds__extract_dow AS metric_time__extract_dow - , subq_14.acquired_ds__extract_doy AS metric_time__extract_doy - , subq_14.customer_id - , subq_14.customer_third_hop_id - , subq_14.customer_id__customer_third_hop_id - , subq_14.customer_third_hop_id__customer_id - , subq_14.country - , subq_14.customer_id__country - , subq_14.customer_third_hop_id__country - , subq_14.customers_with_other_data + subq_12.acquired_ds__day + , subq_12.acquired_ds__week + , subq_12.acquired_ds__month + , subq_12.acquired_ds__quarter + , subq_12.acquired_ds__year + , subq_12.acquired_ds__extract_year + , subq_12.acquired_ds__extract_quarter + , subq_12.acquired_ds__extract_month + , subq_12.acquired_ds__extract_day + , subq_12.acquired_ds__extract_dow + , subq_12.acquired_ds__extract_doy + , subq_12.customer_id__acquired_ds__day + , subq_12.customer_id__acquired_ds__week + , subq_12.customer_id__acquired_ds__month + , subq_12.customer_id__acquired_ds__quarter + , subq_12.customer_id__acquired_ds__year + , subq_12.customer_id__acquired_ds__extract_year + , subq_12.customer_id__acquired_ds__extract_quarter + , subq_12.customer_id__acquired_ds__extract_month + , subq_12.customer_id__acquired_ds__extract_day + , subq_12.customer_id__acquired_ds__extract_dow + , subq_12.customer_id__acquired_ds__extract_doy + , subq_12.customer_third_hop_id__acquired_ds__day + , subq_12.customer_third_hop_id__acquired_ds__week + , subq_12.customer_third_hop_id__acquired_ds__month + , subq_12.customer_third_hop_id__acquired_ds__quarter + , subq_12.customer_third_hop_id__acquired_ds__year + , subq_12.customer_third_hop_id__acquired_ds__extract_year + , subq_12.customer_third_hop_id__acquired_ds__extract_quarter + , subq_12.customer_third_hop_id__acquired_ds__extract_month + , subq_12.customer_third_hop_id__acquired_ds__extract_day + , subq_12.customer_third_hop_id__acquired_ds__extract_dow + , subq_12.customer_third_hop_id__acquired_ds__extract_doy + , subq_12.acquired_ds__day AS metric_time__day + , subq_12.acquired_ds__week AS metric_time__week + , subq_12.acquired_ds__month AS metric_time__month + , subq_12.acquired_ds__quarter AS metric_time__quarter + , subq_12.acquired_ds__year AS metric_time__year + , subq_12.acquired_ds__extract_year AS metric_time__extract_year + , subq_12.acquired_ds__extract_quarter AS metric_time__extract_quarter + , subq_12.acquired_ds__extract_month AS metric_time__extract_month + , subq_12.acquired_ds__extract_day AS metric_time__extract_day + , subq_12.acquired_ds__extract_dow AS metric_time__extract_dow + , subq_12.acquired_ds__extract_doy AS metric_time__extract_doy + , subq_12.customer_id + , subq_12.customer_third_hop_id + , subq_12.customer_id__customer_third_hop_id + , subq_12.customer_third_hop_id__customer_id + , subq_12.country + , subq_12.customer_id__country + , subq_12.customer_third_hop_id__country + , subq_12.customers_with_other_data FROM ( -- Read Elements From Semantic Model 'customer_other_data' SELECT @@ -291,24 +291,24 @@ FROM ( , customer_other_data_src_22000.customer_third_hop_id AS customer_id__customer_third_hop_id , customer_other_data_src_22000.customer_id AS customer_third_hop_id__customer_id FROM ***************************.customer_other_data customer_other_data_src_22000 - ) subq_14 - ) subq_15 + ) subq_12 + ) subq_13 WHERE customer_id__country = 'paraguay' - ) subq_16 - ) subq_17 + ) subq_14 + ) subq_15 WHERE customer_id__country = 'paraguay' - ) subq_18 - ) subq_19 + ) subq_16 + ) subq_17 GROUP BY - subq_19.customer_id__customer_third_hop_id - ) subq_20 - ) subq_21 - ) subq_22 + subq_17.customer_id__customer_third_hop_id + ) subq_18 + ) subq_19 + ) subq_20 ON - subq_13.customer_third_hop_id = subq_22.customer_id__customer_third_hop_id - ) subq_23 - ) subq_24 + subq_11.customer_third_hop_id = subq_20.customer_id__customer_third_hop_id + ) subq_21 + ) subq_22 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 - ) subq_25 - ) subq_26 -) subq_27 + ) subq_23 + ) subq_24 +) subq_25 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/DuckDB/test_inner_query_single_hop__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/DuckDB/test_inner_query_single_hop__plan0_optimized.sql index 7c12d6cf98..4af49531fb 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/DuckDB/test_inner_query_single_hop__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/DuckDB/test_inner_query_single_hop__plan0_optimized.sql @@ -8,7 +8,7 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers'] SELECT - subq_39.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + subq_37.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers , third_hop_table_src_22000.customer_third_hop_id AS third_hop_count FROM ***************************.third_hop_table third_hop_table_src_22000 LEFT OUTER JOIN ( @@ -35,14 +35,14 @@ FROM ( , country AS customer_id__country , 1 AS customers_with_other_data FROM ***************************.customer_other_data customer_other_data_src_22000 - ) subq_32 + ) subq_30 WHERE customer_id__country = 'paraguay' - ) subq_34 + ) subq_32 WHERE customer_id__country = 'paraguay' GROUP BY customer_id__customer_third_hop_id - ) subq_39 + ) subq_37 ON - third_hop_table_src_22000.customer_third_hop_id = subq_39.customer_id__customer_third_hop_id -) subq_41 + third_hop_table_src_22000.customer_third_hop_id = subq_37.customer_id__customer_third_hop_id +) subq_39 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 diff --git a/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/DuckDB/test_dimensions_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/DuckDB/test_dimensions_with_time_constraint__plan0.sql index df768a7cba..1e42a5d726 100644 --- a/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/DuckDB/test_dimensions_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/DuckDB/test_dimensions_with_time_constraint__plan0.sql @@ -1,130 +1,130 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_9.metric_time__day - , subq_9.listing__is_lux_latest - , subq_9.user__home_state_latest + subq_7.metric_time__day + , subq_7.listing__is_lux_latest + , subq_7.user__home_state_latest FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-03T00:00:00] 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.created_at__day - , subq_8.created_at__week - , subq_8.created_at__month - , subq_8.created_at__quarter - , subq_8.created_at__year - , subq_8.created_at__extract_year - , subq_8.created_at__extract_quarter - , subq_8.created_at__extract_month - , subq_8.created_at__extract_day - , subq_8.created_at__extract_dow - , subq_8.created_at__extract_doy - , subq_8.listing__ds__day - , subq_8.listing__ds__week - , subq_8.listing__ds__month - , subq_8.listing__ds__quarter - , subq_8.listing__ds__year - , subq_8.listing__ds__extract_year - , subq_8.listing__ds__extract_quarter - , subq_8.listing__ds__extract_month - , subq_8.listing__ds__extract_day - , subq_8.listing__ds__extract_dow - , subq_8.listing__ds__extract_doy - , subq_8.listing__created_at__day - , subq_8.listing__created_at__week - , subq_8.listing__created_at__month - , subq_8.listing__created_at__quarter - , subq_8.listing__created_at__year - , subq_8.listing__created_at__extract_year - , subq_8.listing__created_at__extract_quarter - , subq_8.listing__created_at__extract_month - , subq_8.listing__created_at__extract_day - , subq_8.listing__created_at__extract_dow - , subq_8.listing__created_at__extract_doy - , subq_8.metric_time__day - , subq_8.listing - , subq_8.user - , subq_8.listing__user - , subq_8.country_latest - , subq_8.is_lux_latest - , subq_8.capacity_latest - , subq_8.listing__country_latest - , subq_8.listing__is_lux_latest - , subq_8.listing__capacity_latest - , subq_8.user__home_state_latest - , subq_8.listings - , subq_8.largest_listing - , subq_8.smallest_listing + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.created_at__day + , subq_6.created_at__week + , subq_6.created_at__month + , subq_6.created_at__quarter + , subq_6.created_at__year + , subq_6.created_at__extract_year + , subq_6.created_at__extract_quarter + , subq_6.created_at__extract_month + , subq_6.created_at__extract_day + , subq_6.created_at__extract_dow + , subq_6.created_at__extract_doy + , subq_6.listing__ds__day + , subq_6.listing__ds__week + , subq_6.listing__ds__month + , subq_6.listing__ds__quarter + , subq_6.listing__ds__year + , subq_6.listing__ds__extract_year + , subq_6.listing__ds__extract_quarter + , subq_6.listing__ds__extract_month + , subq_6.listing__ds__extract_day + , subq_6.listing__ds__extract_dow + , subq_6.listing__ds__extract_doy + , subq_6.listing__created_at__day + , subq_6.listing__created_at__week + , subq_6.listing__created_at__month + , subq_6.listing__created_at__quarter + , subq_6.listing__created_at__year + , subq_6.listing__created_at__extract_year + , subq_6.listing__created_at__extract_quarter + , subq_6.listing__created_at__extract_month + , subq_6.listing__created_at__extract_day + , subq_6.listing__created_at__extract_dow + , subq_6.listing__created_at__extract_doy + , subq_6.metric_time__day + , subq_6.listing + , subq_6.user + , subq_6.listing__user + , subq_6.country_latest + , subq_6.is_lux_latest + , subq_6.capacity_latest + , subq_6.listing__country_latest + , subq_6.listing__is_lux_latest + , subq_6.listing__capacity_latest + , subq_6.user__home_state_latest + , subq_6.listings + , subq_6.largest_listing + , subq_6.smallest_listing FROM ( -- Join Standard Outputs SELECT - subq_2.ds__day AS ds__day - , subq_2.ds__week AS ds__week - , subq_2.ds__month AS ds__month - , subq_2.ds__quarter AS ds__quarter - , subq_2.ds__year AS ds__year - , subq_2.ds__extract_year AS ds__extract_year - , subq_2.ds__extract_quarter AS ds__extract_quarter - , subq_2.ds__extract_month AS ds__extract_month - , subq_2.ds__extract_day AS ds__extract_day - , subq_2.ds__extract_dow AS ds__extract_dow - , subq_2.ds__extract_doy AS ds__extract_doy - , subq_2.created_at__day AS created_at__day - , subq_2.created_at__week AS created_at__week - , subq_2.created_at__month AS created_at__month - , subq_2.created_at__quarter AS created_at__quarter - , subq_2.created_at__year AS created_at__year - , subq_2.created_at__extract_year AS created_at__extract_year - , subq_2.created_at__extract_quarter AS created_at__extract_quarter - , subq_2.created_at__extract_month AS created_at__extract_month - , subq_2.created_at__extract_day AS created_at__extract_day - , subq_2.created_at__extract_dow AS created_at__extract_dow - , subq_2.created_at__extract_doy AS created_at__extract_doy - , subq_2.listing__ds__day AS listing__ds__day - , subq_2.listing__ds__week AS listing__ds__week - , subq_2.listing__ds__month AS listing__ds__month - , subq_2.listing__ds__quarter AS listing__ds__quarter - , subq_2.listing__ds__year AS listing__ds__year - , subq_2.listing__ds__extract_year AS listing__ds__extract_year - , subq_2.listing__ds__extract_quarter AS listing__ds__extract_quarter - , subq_2.listing__ds__extract_month AS listing__ds__extract_month - , subq_2.listing__ds__extract_day AS listing__ds__extract_day - , subq_2.listing__ds__extract_dow AS listing__ds__extract_dow - , subq_2.listing__ds__extract_doy AS listing__ds__extract_doy - , subq_2.listing__created_at__day AS listing__created_at__day - , subq_2.listing__created_at__week AS listing__created_at__week - , subq_2.listing__created_at__month AS listing__created_at__month - , subq_2.listing__created_at__quarter AS listing__created_at__quarter - , subq_2.listing__created_at__year AS listing__created_at__year - , subq_2.listing__created_at__extract_year AS listing__created_at__extract_year - , subq_2.listing__created_at__extract_quarter AS listing__created_at__extract_quarter - , subq_2.listing__created_at__extract_month AS listing__created_at__extract_month - , subq_2.listing__created_at__extract_day AS listing__created_at__extract_day - , subq_2.listing__created_at__extract_dow AS listing__created_at__extract_dow - , subq_2.listing__created_at__extract_doy AS listing__created_at__extract_doy - , subq_5.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.user AS user - , subq_2.listing__user AS listing__user - , subq_2.country_latest AS country_latest - , subq_2.is_lux_latest AS is_lux_latest - , subq_2.capacity_latest AS capacity_latest - , subq_2.listing__country_latest AS listing__country_latest - , subq_2.listing__is_lux_latest AS listing__is_lux_latest - , subq_2.listing__capacity_latest AS listing__capacity_latest - , subq_7.home_state_latest AS user__home_state_latest - , subq_2.listings AS listings - , subq_2.largest_listing AS largest_listing - , subq_2.smallest_listing AS smallest_listing + subq_0.ds__day AS ds__day + , subq_0.ds__week AS ds__week + , subq_0.ds__month AS ds__month + , subq_0.ds__quarter AS ds__quarter + , subq_0.ds__year AS ds__year + , subq_0.ds__extract_year AS ds__extract_year + , subq_0.ds__extract_quarter AS ds__extract_quarter + , subq_0.ds__extract_month AS ds__extract_month + , subq_0.ds__extract_day AS ds__extract_day + , subq_0.ds__extract_dow AS ds__extract_dow + , subq_0.ds__extract_doy AS ds__extract_doy + , subq_0.created_at__day AS created_at__day + , subq_0.created_at__week AS created_at__week + , subq_0.created_at__month AS created_at__month + , subq_0.created_at__quarter AS created_at__quarter + , subq_0.created_at__year AS created_at__year + , subq_0.created_at__extract_year AS created_at__extract_year + , subq_0.created_at__extract_quarter AS created_at__extract_quarter + , subq_0.created_at__extract_month AS created_at__extract_month + , subq_0.created_at__extract_day AS created_at__extract_day + , subq_0.created_at__extract_dow AS created_at__extract_dow + , subq_0.created_at__extract_doy AS created_at__extract_doy + , subq_0.listing__ds__day AS listing__ds__day + , subq_0.listing__ds__week AS listing__ds__week + , subq_0.listing__ds__month AS listing__ds__month + , subq_0.listing__ds__quarter AS listing__ds__quarter + , subq_0.listing__ds__year AS listing__ds__year + , subq_0.listing__ds__extract_year AS listing__ds__extract_year + , subq_0.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_0.listing__ds__extract_month AS listing__ds__extract_month + , subq_0.listing__ds__extract_day AS listing__ds__extract_day + , subq_0.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_0.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_0.listing__created_at__day AS listing__created_at__day + , subq_0.listing__created_at__week AS listing__created_at__week + , subq_0.listing__created_at__month AS listing__created_at__month + , subq_0.listing__created_at__quarter AS listing__created_at__quarter + , subq_0.listing__created_at__year AS listing__created_at__year + , subq_0.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_0.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_3.metric_time__day AS metric_time__day + , subq_0.listing AS listing + , subq_0.user AS user + , subq_0.listing__user AS listing__user + , subq_0.country_latest AS country_latest + , subq_0.is_lux_latest AS is_lux_latest + , subq_0.capacity_latest AS capacity_latest + , subq_0.listing__country_latest AS listing__country_latest + , subq_0.listing__is_lux_latest AS listing__is_lux_latest + , subq_0.listing__capacity_latest AS listing__capacity_latest + , subq_5.home_state_latest AS user__home_state_latest + , subq_0.listings AS listings + , subq_0.largest_listing AS largest_listing + , subq_0.smallest_listing AS smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -185,36 +185,36 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_2 + ) subq_0 CROSS JOIN ( -- Pass Only Elements: ['metric_time__day',] SELECT - subq_4.metric_time__day + subq_2.metric_time__day FROM ( -- Metric Time Dimension 'ds' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds__day AS metric_time__day + , subq_1.ds__week AS metric_time__week + , subq_1.ds__month AS metric_time__month + , subq_1.ds__quarter AS metric_time__quarter + , subq_1.ds__year AS metric_time__year + , subq_1.ds__extract_year AS metric_time__extract_year + , subq_1.ds__extract_quarter AS metric_time__extract_quarter + , subq_1.ds__extract_month AS metric_time__extract_month + , subq_1.ds__extract_day AS metric_time__extract_day + , subq_1.ds__extract_dow AS metric_time__extract_dow + , subq_1.ds__extract_doy AS metric_time__extract_doy FROM ( -- Time Spine SELECT @@ -230,14 +230,14 @@ FROM ( , EXTRACT(isodow FROM time_spine_src_28000.ds) AS ds__extract_dow , EXTRACT(doy FROM time_spine_src_28000.ds) AS ds__extract_doy FROM ***************************.mf_time_spine time_spine_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_1 + ) subq_2 + ) subq_3 FULL OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_6.user - , subq_6.home_state_latest + subq_4.user + , subq_4.home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT @@ -267,14 +267,14 @@ FROM ( , users_latest_src_28000.home_state_latest AS user__home_state_latest , users_latest_src_28000.user_id AS user FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 ON - subq_2.user = subq_7.user - ) subq_8 - WHERE subq_8.metric_time__day BETWEEN '2020-01-01' AND '2020-01-03' -) subq_9 + subq_0.user = subq_5.user + ) subq_6 + WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-03' +) subq_7 GROUP BY - subq_9.metric_time__day - , subq_9.listing__is_lux_latest - , subq_9.user__home_state_latest + subq_7.metric_time__day + , subq_7.listing__is_lux_latest + , subq_7.user__home_state_latest diff --git a/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/test_dimensions_with_time_constraint__plan0.xml b/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/test_dimensions_with_time_constraint__plan0.xml index e7f2570193..e81db14dc9 100644 --- a/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/test_dimensions_with_time_constraint__plan0.xml +++ b/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/test_dimensions_with_time_constraint__plan0.xml @@ -2,438 +2,431 @@ - - + + - + - - + + - + - + - + - - - - - - + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - - - - - - + + + + + + - + - + - - + + - - + + @@ -681,114 +674,114 @@ - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + @@ -856,11 +849,11 @@ - - + + - + diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql new file mode 100644 index 0000000000..8088d8d684 --- /dev/null +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql @@ -0,0 +1,563 @@ +-- Compute Metrics via Expressions +SELECT + subq_15.metric_time__day + , CAST(subq_15.average_booking_value AS DOUBLE) / CAST(NULLIF(subq_15.max_booking_value, 0) AS DOUBLE) AS instant_booking_fraction_of_max_value +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_9.metric_time__day, subq_14.metric_time__day) AS metric_time__day + , MAX(subq_9.average_booking_value) AS average_booking_value + , MAX(subq_14.max_booking_value) AS max_booking_value + FROM ( + -- Compute Metrics via Expressions + SELECT + subq_8.metric_time__day + , subq_8.average_booking_value + FROM ( + -- Aggregate Measures + SELECT + subq_7.metric_time__day + , AVG(subq_7.average_booking_value) AS average_booking_value + FROM ( + -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] + SELECT + subq_6.metric_time__day + , subq_6.average_booking_value + FROM ( + -- Constrain Output with WHERE + SELECT + subq_5.metric_time__day + , subq_5.booking__is_instant + , subq_5.average_booking_value + FROM ( + -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'metric_time__day'] + SELECT + subq_4.metric_time__day + , subq_4.booking__is_instant + , subq_4.average_booking_value + FROM ( + -- Constrain Output with WHERE + SELECT + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.ds_partitioned__day + , subq_3.ds_partitioned__week + , subq_3.ds_partitioned__month + , subq_3.ds_partitioned__quarter + , subq_3.ds_partitioned__year + , subq_3.ds_partitioned__extract_year + , subq_3.ds_partitioned__extract_quarter + , subq_3.ds_partitioned__extract_month + , subq_3.ds_partitioned__extract_day + , subq_3.ds_partitioned__extract_dow + , subq_3.ds_partitioned__extract_doy + , subq_3.paid_at__day + , subq_3.paid_at__week + , subq_3.paid_at__month + , subq_3.paid_at__quarter + , subq_3.paid_at__year + , subq_3.paid_at__extract_year + , subq_3.paid_at__extract_quarter + , subq_3.paid_at__extract_month + , subq_3.paid_at__extract_day + , subq_3.paid_at__extract_dow + , subq_3.paid_at__extract_doy + , subq_3.booking__ds__day + , subq_3.booking__ds__week + , subq_3.booking__ds__month + , subq_3.booking__ds__quarter + , subq_3.booking__ds__year + , subq_3.booking__ds__extract_year + , subq_3.booking__ds__extract_quarter + , subq_3.booking__ds__extract_month + , subq_3.booking__ds__extract_day + , subq_3.booking__ds__extract_dow + , subq_3.booking__ds__extract_doy + , subq_3.booking__ds_partitioned__day + , subq_3.booking__ds_partitioned__week + , subq_3.booking__ds_partitioned__month + , subq_3.booking__ds_partitioned__quarter + , subq_3.booking__ds_partitioned__year + , subq_3.booking__ds_partitioned__extract_year + , subq_3.booking__ds_partitioned__extract_quarter + , subq_3.booking__ds_partitioned__extract_month + , subq_3.booking__ds_partitioned__extract_day + , subq_3.booking__ds_partitioned__extract_dow + , subq_3.booking__ds_partitioned__extract_doy + , subq_3.booking__paid_at__day + , subq_3.booking__paid_at__week + , subq_3.booking__paid_at__month + , subq_3.booking__paid_at__quarter + , subq_3.booking__paid_at__year + , subq_3.booking__paid_at__extract_year + , subq_3.booking__paid_at__extract_quarter + , subq_3.booking__paid_at__extract_month + , subq_3.booking__paid_at__extract_day + , subq_3.booking__paid_at__extract_dow + , subq_3.booking__paid_at__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy + , subq_3.listing + , subq_3.guest + , subq_3.host + , subq_3.booking__listing + , subq_3.booking__guest + , subq_3.booking__host + , subq_3.is_instant + , subq_3.booking__is_instant + , subq_3.bookings + , subq_3.instant_bookings + , subq_3.booking_value + , subq_3.max_booking_value + , subq_3.min_booking_value + , subq_3.bookers + , subq_3.average_booking_value + , subq_3.referred_bookings + , subq_3.median_booking_value + , subq_3.booking_value_p99 + , subq_3.discrete_booking_value_p99 + , subq_3.approximate_continuous_booking_value_p99 + , subq_3.approximate_discrete_booking_value_p99 + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + SELECT + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + WHERE booking__is_instant + ) subq_4 + ) subq_5 + WHERE booking__is_instant + ) subq_6 + ) subq_7 + GROUP BY + subq_7.metric_time__day + ) subq_8 + ) subq_9 + FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_13.metric_time__day + , subq_13.max_booking_value + FROM ( + -- Aggregate Measures + SELECT + subq_12.metric_time__day + , MAX(subq_12.max_booking_value) AS max_booking_value + FROM ( + -- Pass Only Elements: ['max_booking_value', 'metric_time__day'] + SELECT + subq_11.metric_time__day + , subq_11.max_booking_value + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + SELECT + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_10 + ) subq_11 + ) subq_12 + GROUP BY + subq_12.metric_time__day + ) subq_13 + ) subq_14 + ON + subq_9.metric_time__day = subq_14.metric_time__day + GROUP BY + COALESCE(subq_9.metric_time__day, subq_14.metric_time__day) +) subq_15 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql new file mode 100644 index 0000000000..db345ac389 --- /dev/null +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql @@ -0,0 +1,58 @@ +-- Compute Metrics via Expressions +SELECT + metric_time__day + , CAST(average_booking_value AS DOUBLE) / CAST(NULLIF(max_booking_value, 0) AS DOUBLE) AS instant_booking_fraction_of_max_value +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , MAX(subq_23.average_booking_value) AS average_booking_value + , MAX(subq_28.max_booking_value) AS max_booking_value + FROM ( + -- Constrain Output with WHERE + -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + metric_time__day + , AVG(average_booking_value) AS average_booking_value + FROM ( + -- Constrain Output with WHERE + -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'metric_time__day'] + SELECT + metric_time__day + , booking__is_instant + , average_booking_value + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + , is_instant AS booking__is_instant + , booking_value AS average_booking_value + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_17 + WHERE booking__is_instant + ) subq_19 + WHERE booking__is_instant + GROUP BY + metric_time__day + ) subq_23 + FULL OUTER JOIN ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: ['max_booking_value', 'metric_time__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + , MAX(booking_value) AS max_booking_value + FROM ***************************.fct_bookings bookings_source_src_28000 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_28 + ON + subq_23.metric_time__day = subq_28.metric_time__day + GROUP BY + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) +) subq_29 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_multiple_categorical_dimension_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_multiple_categorical_dimension_pushdown__plan0.sql index c864c9883c..e20f1a70d6 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_multiple_categorical_dimension_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_multiple_categorical_dimension_pushdown__plan0.sql @@ -1,249 +1,48 @@ -- Compute Metrics via Expressions SELECT - subq_10.booking__is_instant - , subq_10.bookings + subq_12.user__home_state_latest + , subq_12.listings FROM ( -- Aggregate Measures SELECT - subq_9.booking__is_instant - , SUM(subq_9.bookings) AS bookings + subq_11.user__home_state_latest + , SUM(subq_11.listings) AS listings FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant'] + -- Pass Only Elements: ['listings', 'user__home_state_latest'] SELECT - subq_8.booking__is_instant - , subq_8.bookings + subq_10.user__home_state_latest + , subq_10.listings FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__is_lux_latest - , subq_7.listing__capacity_latest - , subq_7.bookings + subq_9.listing__is_lux_latest + , subq_9.listing__capacity_latest + , subq_9.user__home_state_latest + , subq_9.listings FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing__is_lux_latest', 'listing__capacity_latest'] + -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] SELECT - subq_6.booking__is_instant - , subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.bookings + subq_8.listing__is_lux_latest + , subq_8.listing__capacity_latest + , subq_8.user__home_state_latest + , subq_8.listings FROM ( -- Join Standard Outputs SELECT - subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_5.is_lux_latest AS listing__is_lux_latest - , subq_5.capacity_latest AS listing__capacity_latest - , subq_2.bookings AS bookings + subq_5.user AS user + , subq_5.listing__is_lux_latest AS listing__is_lux_latest + , subq_5.listing__capacity_latest AS listing__capacity_latest + , subq_7.home_state_latest AS user__home_state_latest + , subq_5.listings AS listings FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.bookings + subq_4.user + , subq_4.listing__is_lux_latest + , subq_4.listing__capacity_latest + , subq_4.listings FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['is_lux_latest', 'capacity_latest', 'listing', 'listing'] - SELECT - subq_4.listing - , subq_4.is_lux_latest - , subq_4.capacity_latest - FROM ( - -- Metric Time Dimension 'ds' + -- Constrain Output with WHERE SELECT subq_3.ds__day , subq_3.ds__week @@ -289,17 +88,17 @@ FROM ( , subq_3.listing__created_at__extract_day , subq_3.listing__created_at__extract_dow , subq_3.listing__created_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy , subq_3.listing , subq_3.user , subq_3.listing__user @@ -313,75 +112,183 @@ FROM ( , subq_3.largest_listing , subq_3.smallest_listing FROM ( - -- Read Elements From Semantic Model 'listings_latest' + -- Metric Time Dimension 'ds' SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing + FROM ( + -- Read Elements From Semantic Model 'listings_latest' + SELECT + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 ) subq_3 + WHERE listing__is_lux_latest OR listing__capacity_latest > 4 ) subq_4 ) subq_5 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['home_state_latest', 'user'] + SELECT + subq_6.user + , subq_6.home_state_latest + FROM ( + -- Read Elements From Semantic Model 'users_latest' + SELECT + DATE_TRUNC('day', users_latest_src_28000.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_28000.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_28000.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_28000.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_28000.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_28000.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_28000.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_28000.ds) AS ds_latest__extract_day + , EXTRACT(isodow FROM users_latest_src_28000.ds) AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_28000.ds) AS ds_latest__extract_doy + , users_latest_src_28000.home_state_latest + , DATE_TRUNC('day', users_latest_src_28000.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_28000.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_28000.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_28000.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_28000.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_28000.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_28000.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_28000.ds) AS user__ds_latest__extract_day + , EXTRACT(isodow FROM users_latest_src_28000.ds) AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_28000.ds) AS user__ds_latest__extract_doy + , users_latest_src_28000.home_state_latest AS user__home_state_latest + , users_latest_src_28000.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_28000 + ) subq_6 + ) subq_7 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_5.user = subq_7.user + ) subq_8 + ) subq_9 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 - ) subq_8 - ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_9.booking__is_instant -) subq_10 + subq_11.user__home_state_latest +) subq_12 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql index 98cc26bb70..76b28308ab 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql @@ -1,33 +1,43 @@ -- Constrain Output with WHERE --- Pass Only Elements: ['bookings', 'booking__is_instant'] +-- Pass Only Elements: ['listings', 'user__home_state_latest'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - booking__is_instant - , SUM(bookings) AS bookings + user__home_state_latest + , SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing__is_lux_latest', 'listing__capacity_latest'] + -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] SELECT - subq_13.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , subq_13.bookings AS bookings + subq_16.listing__is_lux_latest AS listing__is_lux_latest + , subq_16.listing__capacity_latest AS listing__capacity_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest + , subq_16.listings AS listings FROM ( - -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Constrain Output with WHERE + -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] SELECT - listing_id AS listing - , is_instant AS booking__is_instant - , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 + subq_14.user + , listing__is_lux_latest + , listing__capacity_latest + , listings + FROM ( + -- Read Elements From Semantic Model 'listings_latest' + -- Metric Time Dimension 'ds' + SELECT + user_id AS user + , is_lux AS listing__is_lux_latest + , capacity AS listing__capacity_latest + , 1 AS listings + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_14 + WHERE listing__is_lux_latest OR listing__capacity_latest > 4 + ) subq_16 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28000 + ***************************.dim_users_latest users_latest_src_28000 ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_18 + subq_16.user = users_latest_src_28000.user_id +) subq_20 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 GROUP BY - booking__is_instant + user__home_state_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_multiple_different_filters_on_same_measure_source_categorical_dimension__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_multiple_different_filters_on_same_measure_source_categorical_dimension__plan0.sql index eba9260f92..8088d8d684 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_multiple_different_filters_on_same_measure_source_categorical_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_multiple_different_filters_on_same_measure_source_categorical_dimension__plan0.sql @@ -1,242 +1,242 @@ -- Compute Metrics via Expressions SELECT - subq_19.metric_time__day - , CAST(subq_19.average_booking_value AS DOUBLE) / CAST(NULLIF(subq_19.max_booking_value, 0) AS DOUBLE) AS instant_booking_fraction_of_max_value + subq_15.metric_time__day + , CAST(subq_15.average_booking_value AS DOUBLE) / CAST(NULLIF(subq_15.max_booking_value, 0) AS DOUBLE) AS instant_booking_fraction_of_max_value FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) AS metric_time__day - , MAX(subq_13.average_booking_value) AS average_booking_value - , MAX(subq_18.max_booking_value) AS max_booking_value + COALESCE(subq_9.metric_time__day, subq_14.metric_time__day) AS metric_time__day + , MAX(subq_9.average_booking_value) AS average_booking_value + , MAX(subq_14.max_booking_value) AS max_booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , subq_12.average_booking_value + subq_8.metric_time__day + , subq_8.average_booking_value FROM ( -- Aggregate Measures SELECT - subq_11.metric_time__day - , AVG(subq_11.average_booking_value) AS average_booking_value + subq_7.metric_time__day + , AVG(subq_7.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] SELECT - subq_10.metric_time__day - , subq_10.average_booking_value + subq_6.metric_time__day + , subq_6.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_9.metric_time__day - , subq_9.booking__is_instant - , subq_9.average_booking_value + subq_5.metric_time__day + , subq_5.booking__is_instant + , subq_5.average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.booking__is_instant - , subq_8.average_booking_value + subq_4.metric_time__day + , subq_4.booking__is_instant + , subq_4.average_booking_value FROM ( -- Constrain Output with WHERE 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.ds_partitioned__day - , subq_7.ds_partitioned__week - , subq_7.ds_partitioned__month - , subq_7.ds_partitioned__quarter - , subq_7.ds_partitioned__year - , subq_7.ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy - , subq_7.paid_at__day - , subq_7.paid_at__week - , subq_7.paid_at__month - , subq_7.paid_at__quarter - , subq_7.paid_at__year - , subq_7.paid_at__extract_year - , subq_7.paid_at__extract_quarter - , subq_7.paid_at__extract_month - , subq_7.paid_at__extract_day - , subq_7.paid_at__extract_dow - , subq_7.paid_at__extract_doy - , subq_7.booking__ds__day - , subq_7.booking__ds__week - , subq_7.booking__ds__month - , subq_7.booking__ds__quarter - , subq_7.booking__ds__year - , subq_7.booking__ds__extract_year - , subq_7.booking__ds__extract_quarter - , subq_7.booking__ds__extract_month - , subq_7.booking__ds__extract_day - , subq_7.booking__ds__extract_dow - , subq_7.booking__ds__extract_doy - , subq_7.booking__ds_partitioned__day - , subq_7.booking__ds_partitioned__week - , subq_7.booking__ds_partitioned__month - , subq_7.booking__ds_partitioned__quarter - , subq_7.booking__ds_partitioned__year - , subq_7.booking__ds_partitioned__extract_year - , subq_7.booking__ds_partitioned__extract_quarter - , subq_7.booking__ds_partitioned__extract_month - , subq_7.booking__ds_partitioned__extract_day - , subq_7.booking__ds_partitioned__extract_dow - , subq_7.booking__ds_partitioned__extract_doy - , subq_7.booking__paid_at__day - , subq_7.booking__paid_at__week - , subq_7.booking__paid_at__month - , subq_7.booking__paid_at__quarter - , subq_7.booking__paid_at__year - , subq_7.booking__paid_at__extract_year - , subq_7.booking__paid_at__extract_quarter - , subq_7.booking__paid_at__extract_month - , subq_7.booking__paid_at__extract_day - , subq_7.booking__paid_at__extract_dow - , subq_7.booking__paid_at__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.listing - , subq_7.guest - , subq_7.host - , subq_7.booking__listing - , subq_7.booking__guest - , subq_7.booking__host - , subq_7.is_instant - , subq_7.booking__is_instant - , subq_7.bookings - , subq_7.instant_bookings - , subq_7.booking_value - , subq_7.max_booking_value - , subq_7.min_booking_value - , subq_7.bookers - , subq_7.average_booking_value - , subq_7.referred_bookings - , subq_7.median_booking_value - , subq_7.booking_value_p99 - , subq_7.discrete_booking_value_p99 - , subq_7.approximate_continuous_booking_value_p99 - , subq_7.approximate_discrete_booking_value_p99 + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.ds_partitioned__day + , subq_3.ds_partitioned__week + , subq_3.ds_partitioned__month + , subq_3.ds_partitioned__quarter + , subq_3.ds_partitioned__year + , subq_3.ds_partitioned__extract_year + , subq_3.ds_partitioned__extract_quarter + , subq_3.ds_partitioned__extract_month + , subq_3.ds_partitioned__extract_day + , subq_3.ds_partitioned__extract_dow + , subq_3.ds_partitioned__extract_doy + , subq_3.paid_at__day + , subq_3.paid_at__week + , subq_3.paid_at__month + , subq_3.paid_at__quarter + , subq_3.paid_at__year + , subq_3.paid_at__extract_year + , subq_3.paid_at__extract_quarter + , subq_3.paid_at__extract_month + , subq_3.paid_at__extract_day + , subq_3.paid_at__extract_dow + , subq_3.paid_at__extract_doy + , subq_3.booking__ds__day + , subq_3.booking__ds__week + , subq_3.booking__ds__month + , subq_3.booking__ds__quarter + , subq_3.booking__ds__year + , subq_3.booking__ds__extract_year + , subq_3.booking__ds__extract_quarter + , subq_3.booking__ds__extract_month + , subq_3.booking__ds__extract_day + , subq_3.booking__ds__extract_dow + , subq_3.booking__ds__extract_doy + , subq_3.booking__ds_partitioned__day + , subq_3.booking__ds_partitioned__week + , subq_3.booking__ds_partitioned__month + , subq_3.booking__ds_partitioned__quarter + , subq_3.booking__ds_partitioned__year + , subq_3.booking__ds_partitioned__extract_year + , subq_3.booking__ds_partitioned__extract_quarter + , subq_3.booking__ds_partitioned__extract_month + , subq_3.booking__ds_partitioned__extract_day + , subq_3.booking__ds_partitioned__extract_dow + , subq_3.booking__ds_partitioned__extract_doy + , subq_3.booking__paid_at__day + , subq_3.booking__paid_at__week + , subq_3.booking__paid_at__month + , subq_3.booking__paid_at__quarter + , subq_3.booking__paid_at__year + , subq_3.booking__paid_at__extract_year + , subq_3.booking__paid_at__extract_quarter + , subq_3.booking__paid_at__extract_month + , subq_3.booking__paid_at__extract_day + , subq_3.booking__paid_at__extract_dow + , subq_3.booking__paid_at__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy + , subq_3.listing + , subq_3.guest + , subq_3.host + , subq_3.booking__listing + , subq_3.booking__guest + , subq_3.booking__host + , subq_3.is_instant + , subq_3.booking__is_instant + , subq_3.bookings + , subq_3.instant_bookings + , subq_3.booking_value + , subq_3.max_booking_value + , subq_3.min_booking_value + , subq_3.bookers + , subq_3.average_booking_value + , subq_3.referred_bookings + , subq_3.median_booking_value + , subq_3.booking_value_p99 + , subq_3.discrete_booking_value_p99 + , subq_3.approximate_continuous_booking_value_p99 + , subq_3.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.ds_partitioned__day - , subq_6.ds_partitioned__week - , subq_6.ds_partitioned__month - , subq_6.ds_partitioned__quarter - , subq_6.ds_partitioned__year - , subq_6.ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy - , subq_6.paid_at__day - , subq_6.paid_at__week - , subq_6.paid_at__month - , subq_6.paid_at__quarter - , subq_6.paid_at__year - , subq_6.paid_at__extract_year - , subq_6.paid_at__extract_quarter - , subq_6.paid_at__extract_month - , subq_6.paid_at__extract_day - , subq_6.paid_at__extract_dow - , subq_6.paid_at__extract_doy - , subq_6.booking__ds__day - , subq_6.booking__ds__week - , subq_6.booking__ds__month - , subq_6.booking__ds__quarter - , subq_6.booking__ds__year - , subq_6.booking__ds__extract_year - , subq_6.booking__ds__extract_quarter - , subq_6.booking__ds__extract_month - , subq_6.booking__ds__extract_day - , subq_6.booking__ds__extract_dow - , subq_6.booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day - , subq_6.booking__paid_at__week - , subq_6.booking__paid_at__month - , subq_6.booking__paid_at__quarter - , subq_6.booking__paid_at__year - , subq_6.booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.listing - , subq_6.guest - , subq_6.host - , subq_6.booking__listing - , subq_6.booking__guest - , subq_6.booking__host - , subq_6.is_instant - , subq_6.booking__is_instant - , subq_6.bookings - , subq_6.instant_bookings - , subq_6.booking_value - , subq_6.max_booking_value - , subq_6.min_booking_value - , subq_6.bookers - , subq_6.average_booking_value - , subq_6.referred_bookings - , subq_6.median_booking_value - , subq_6.booking_value_p99 - , subq_6.discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -329,134 +329,134 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_6 - ) subq_7 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_4 + ) subq_5 WHERE booking__is_instant - ) subq_10 - ) subq_11 + ) subq_6 + ) subq_7 GROUP BY - subq_11.metric_time__day - ) subq_12 - ) subq_13 + subq_7.metric_time__day + ) subq_8 + ) subq_9 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_17.metric_time__day - , subq_17.max_booking_value + subq_13.metric_time__day + , subq_13.max_booking_value FROM ( -- Aggregate Measures SELECT - subq_16.metric_time__day - , MAX(subq_16.max_booking_value) AS max_booking_value + subq_12.metric_time__day + , MAX(subq_12.max_booking_value) AS max_booking_value FROM ( -- Pass Only Elements: ['max_booking_value', 'metric_time__day'] SELECT - subq_15.metric_time__day - , subq_15.max_booking_value + subq_11.metric_time__day + , subq_11.max_booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_14.ds__day - , subq_14.ds__week - , subq_14.ds__month - , subq_14.ds__quarter - , subq_14.ds__year - , subq_14.ds__extract_year - , subq_14.ds__extract_quarter - , subq_14.ds__extract_month - , subq_14.ds__extract_day - , subq_14.ds__extract_dow - , subq_14.ds__extract_doy - , subq_14.ds_partitioned__day - , subq_14.ds_partitioned__week - , subq_14.ds_partitioned__month - , subq_14.ds_partitioned__quarter - , subq_14.ds_partitioned__year - , subq_14.ds_partitioned__extract_year - , subq_14.ds_partitioned__extract_quarter - , subq_14.ds_partitioned__extract_month - , subq_14.ds_partitioned__extract_day - , subq_14.ds_partitioned__extract_dow - , subq_14.ds_partitioned__extract_doy - , subq_14.paid_at__day - , subq_14.paid_at__week - , subq_14.paid_at__month - , subq_14.paid_at__quarter - , subq_14.paid_at__year - , subq_14.paid_at__extract_year - , subq_14.paid_at__extract_quarter - , subq_14.paid_at__extract_month - , subq_14.paid_at__extract_day - , subq_14.paid_at__extract_dow - , subq_14.paid_at__extract_doy - , subq_14.booking__ds__day - , subq_14.booking__ds__week - , subq_14.booking__ds__month - , subq_14.booking__ds__quarter - , subq_14.booking__ds__year - , subq_14.booking__ds__extract_year - , subq_14.booking__ds__extract_quarter - , subq_14.booking__ds__extract_month - , subq_14.booking__ds__extract_day - , subq_14.booking__ds__extract_dow - , subq_14.booking__ds__extract_doy - , subq_14.booking__ds_partitioned__day - , subq_14.booking__ds_partitioned__week - , subq_14.booking__ds_partitioned__month - , subq_14.booking__ds_partitioned__quarter - , subq_14.booking__ds_partitioned__year - , subq_14.booking__ds_partitioned__extract_year - , subq_14.booking__ds_partitioned__extract_quarter - , subq_14.booking__ds_partitioned__extract_month - , subq_14.booking__ds_partitioned__extract_day - , subq_14.booking__ds_partitioned__extract_dow - , subq_14.booking__ds_partitioned__extract_doy - , subq_14.booking__paid_at__day - , subq_14.booking__paid_at__week - , subq_14.booking__paid_at__month - , subq_14.booking__paid_at__quarter - , subq_14.booking__paid_at__year - , subq_14.booking__paid_at__extract_year - , subq_14.booking__paid_at__extract_quarter - , subq_14.booking__paid_at__extract_month - , subq_14.booking__paid_at__extract_day - , subq_14.booking__paid_at__extract_dow - , subq_14.booking__paid_at__extract_doy - , subq_14.ds__day AS metric_time__day - , subq_14.ds__week AS metric_time__week - , subq_14.ds__month AS metric_time__month - , subq_14.ds__quarter AS metric_time__quarter - , subq_14.ds__year AS metric_time__year - , subq_14.ds__extract_year AS metric_time__extract_year - , subq_14.ds__extract_quarter AS metric_time__extract_quarter - , subq_14.ds__extract_month AS metric_time__extract_month - , subq_14.ds__extract_day AS metric_time__extract_day - , subq_14.ds__extract_dow AS metric_time__extract_dow - , subq_14.ds__extract_doy AS metric_time__extract_doy - , subq_14.listing - , subq_14.guest - , subq_14.host - , subq_14.booking__listing - , subq_14.booking__guest - , subq_14.booking__host - , subq_14.is_instant - , subq_14.booking__is_instant - , subq_14.bookings - , subq_14.instant_bookings - , subq_14.booking_value - , subq_14.max_booking_value - , subq_14.min_booking_value - , subq_14.bookers - , subq_14.average_booking_value - , subq_14.referred_bookings - , subq_14.median_booking_value - , subq_14.booking_value_p99 - , subq_14.discrete_booking_value_p99 - , subq_14.approximate_continuous_booking_value_p99 - , subq_14.approximate_discrete_booking_value_p99 + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -549,15 +549,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_14 - ) subq_15 - ) subq_16 + ) subq_10 + ) subq_11 + ) subq_12 GROUP BY - subq_16.metric_time__day - ) subq_17 - ) subq_18 + subq_12.metric_time__day + ) subq_13 + ) subq_14 ON - subq_13.metric_time__day = subq_18.metric_time__day + subq_9.metric_time__day = subq_14.metric_time__day GROUP BY - COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) -) subq_19 + COALESCE(subq_9.metric_time__day, subq_14.metric_time__day) +) subq_15 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_multiple_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_multiple_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql index 111a82caa8..db345ac389 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_multiple_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_multiple_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_27.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , MAX(subq_27.average_booking_value) AS average_booking_value - , MAX(subq_32.max_booking_value) AS max_booking_value + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , MAX(subq_23.average_booking_value) AS average_booking_value + , MAX(subq_28.max_booking_value) AS max_booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] @@ -31,13 +31,13 @@ FROM ( , is_instant AS booking__is_instant , booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_21 + ) subq_17 WHERE booking__is_instant - ) subq_23 + ) subq_19 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_27 + ) subq_23 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -50,9 +50,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_32 + ) subq_28 ON - subq_27.metric_time__day = subq_32.metric_time__day + subq_23.metric_time__day = subq_28.metric_time__day GROUP BY - COALESCE(subq_27.metric_time__day, subq_32.metric_time__day) -) subq_33 + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) +) subq_29 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_single_categorical_dimension_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_single_categorical_dimension_pushdown__plan0.sql index 5ef5778430..388b3ec95a 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_single_categorical_dimension_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_single_categorical_dimension_pushdown__plan0.sql @@ -1,244 +1,244 @@ -- Compute Metrics via Expressions SELECT - subq_17.listing__country_latest - , subq_17.bookings + subq_13.listing__country_latest + , subq_13.bookings FROM ( -- Aggregate Measures SELECT - subq_16.listing__country_latest - , SUM(subq_16.bookings) AS bookings + subq_12.listing__country_latest + , SUM(subq_12.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest'] SELECT - subq_15.listing__country_latest - , subq_15.bookings + subq_11.listing__country_latest + , subq_11.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_14.booking__is_instant - , subq_14.listing__country_latest - , subq_14.bookings + subq_10.booking__is_instant + , subq_10.listing__country_latest + , subq_10.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant'] SELECT - subq_13.booking__is_instant - , subq_13.listing__country_latest - , subq_13.bookings + subq_9.booking__is_instant + , subq_9.listing__country_latest + , subq_9.bookings FROM ( -- Join Standard Outputs SELECT - subq_9.listing AS listing - , subq_9.booking__is_instant AS booking__is_instant - , subq_12.country_latest AS listing__country_latest - , subq_9.bookings AS bookings + subq_5.listing AS listing + , subq_5.booking__is_instant AS booking__is_instant + , subq_8.country_latest AS listing__country_latest + , subq_5.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_8.listing - , subq_8.booking__is_instant - , subq_8.bookings + subq_4.listing + , subq_4.booking__is_instant + , subq_4.bookings FROM ( -- Constrain Output with WHERE 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.ds_partitioned__day - , subq_7.ds_partitioned__week - , subq_7.ds_partitioned__month - , subq_7.ds_partitioned__quarter - , subq_7.ds_partitioned__year - , subq_7.ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy - , subq_7.paid_at__day - , subq_7.paid_at__week - , subq_7.paid_at__month - , subq_7.paid_at__quarter - , subq_7.paid_at__year - , subq_7.paid_at__extract_year - , subq_7.paid_at__extract_quarter - , subq_7.paid_at__extract_month - , subq_7.paid_at__extract_day - , subq_7.paid_at__extract_dow - , subq_7.paid_at__extract_doy - , subq_7.booking__ds__day - , subq_7.booking__ds__week - , subq_7.booking__ds__month - , subq_7.booking__ds__quarter - , subq_7.booking__ds__year - , subq_7.booking__ds__extract_year - , subq_7.booking__ds__extract_quarter - , subq_7.booking__ds__extract_month - , subq_7.booking__ds__extract_day - , subq_7.booking__ds__extract_dow - , subq_7.booking__ds__extract_doy - , subq_7.booking__ds_partitioned__day - , subq_7.booking__ds_partitioned__week - , subq_7.booking__ds_partitioned__month - , subq_7.booking__ds_partitioned__quarter - , subq_7.booking__ds_partitioned__year - , subq_7.booking__ds_partitioned__extract_year - , subq_7.booking__ds_partitioned__extract_quarter - , subq_7.booking__ds_partitioned__extract_month - , subq_7.booking__ds_partitioned__extract_day - , subq_7.booking__ds_partitioned__extract_dow - , subq_7.booking__ds_partitioned__extract_doy - , subq_7.booking__paid_at__day - , subq_7.booking__paid_at__week - , subq_7.booking__paid_at__month - , subq_7.booking__paid_at__quarter - , subq_7.booking__paid_at__year - , subq_7.booking__paid_at__extract_year - , subq_7.booking__paid_at__extract_quarter - , subq_7.booking__paid_at__extract_month - , subq_7.booking__paid_at__extract_day - , subq_7.booking__paid_at__extract_dow - , subq_7.booking__paid_at__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.listing - , subq_7.guest - , subq_7.host - , subq_7.booking__listing - , subq_7.booking__guest - , subq_7.booking__host - , subq_7.is_instant - , subq_7.booking__is_instant - , subq_7.bookings - , subq_7.instant_bookings - , subq_7.booking_value - , subq_7.max_booking_value - , subq_7.min_booking_value - , subq_7.bookers - , subq_7.average_booking_value - , subq_7.referred_bookings - , subq_7.median_booking_value - , subq_7.booking_value_p99 - , subq_7.discrete_booking_value_p99 - , subq_7.approximate_continuous_booking_value_p99 - , subq_7.approximate_discrete_booking_value_p99 + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.ds_partitioned__day + , subq_3.ds_partitioned__week + , subq_3.ds_partitioned__month + , subq_3.ds_partitioned__quarter + , subq_3.ds_partitioned__year + , subq_3.ds_partitioned__extract_year + , subq_3.ds_partitioned__extract_quarter + , subq_3.ds_partitioned__extract_month + , subq_3.ds_partitioned__extract_day + , subq_3.ds_partitioned__extract_dow + , subq_3.ds_partitioned__extract_doy + , subq_3.paid_at__day + , subq_3.paid_at__week + , subq_3.paid_at__month + , subq_3.paid_at__quarter + , subq_3.paid_at__year + , subq_3.paid_at__extract_year + , subq_3.paid_at__extract_quarter + , subq_3.paid_at__extract_month + , subq_3.paid_at__extract_day + , subq_3.paid_at__extract_dow + , subq_3.paid_at__extract_doy + , subq_3.booking__ds__day + , subq_3.booking__ds__week + , subq_3.booking__ds__month + , subq_3.booking__ds__quarter + , subq_3.booking__ds__year + , subq_3.booking__ds__extract_year + , subq_3.booking__ds__extract_quarter + , subq_3.booking__ds__extract_month + , subq_3.booking__ds__extract_day + , subq_3.booking__ds__extract_dow + , subq_3.booking__ds__extract_doy + , subq_3.booking__ds_partitioned__day + , subq_3.booking__ds_partitioned__week + , subq_3.booking__ds_partitioned__month + , subq_3.booking__ds_partitioned__quarter + , subq_3.booking__ds_partitioned__year + , subq_3.booking__ds_partitioned__extract_year + , subq_3.booking__ds_partitioned__extract_quarter + , subq_3.booking__ds_partitioned__extract_month + , subq_3.booking__ds_partitioned__extract_day + , subq_3.booking__ds_partitioned__extract_dow + , subq_3.booking__ds_partitioned__extract_doy + , subq_3.booking__paid_at__day + , subq_3.booking__paid_at__week + , subq_3.booking__paid_at__month + , subq_3.booking__paid_at__quarter + , subq_3.booking__paid_at__year + , subq_3.booking__paid_at__extract_year + , subq_3.booking__paid_at__extract_quarter + , subq_3.booking__paid_at__extract_month + , subq_3.booking__paid_at__extract_day + , subq_3.booking__paid_at__extract_dow + , subq_3.booking__paid_at__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy + , subq_3.listing + , subq_3.guest + , subq_3.host + , subq_3.booking__listing + , subq_3.booking__guest + , subq_3.booking__host + , subq_3.is_instant + , subq_3.booking__is_instant + , subq_3.bookings + , subq_3.instant_bookings + , subq_3.booking_value + , subq_3.max_booking_value + , subq_3.min_booking_value + , subq_3.bookers + , subq_3.average_booking_value + , subq_3.referred_bookings + , subq_3.median_booking_value + , subq_3.booking_value_p99 + , subq_3.discrete_booking_value_p99 + , subq_3.approximate_continuous_booking_value_p99 + , subq_3.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.ds_partitioned__day - , subq_6.ds_partitioned__week - , subq_6.ds_partitioned__month - , subq_6.ds_partitioned__quarter - , subq_6.ds_partitioned__year - , subq_6.ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy - , subq_6.paid_at__day - , subq_6.paid_at__week - , subq_6.paid_at__month - , subq_6.paid_at__quarter - , subq_6.paid_at__year - , subq_6.paid_at__extract_year - , subq_6.paid_at__extract_quarter - , subq_6.paid_at__extract_month - , subq_6.paid_at__extract_day - , subq_6.paid_at__extract_dow - , subq_6.paid_at__extract_doy - , subq_6.booking__ds__day - , subq_6.booking__ds__week - , subq_6.booking__ds__month - , subq_6.booking__ds__quarter - , subq_6.booking__ds__year - , subq_6.booking__ds__extract_year - , subq_6.booking__ds__extract_quarter - , subq_6.booking__ds__extract_month - , subq_6.booking__ds__extract_day - , subq_6.booking__ds__extract_dow - , subq_6.booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day - , subq_6.booking__paid_at__week - , subq_6.booking__paid_at__month - , subq_6.booking__paid_at__quarter - , subq_6.booking__paid_at__year - , subq_6.booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.listing - , subq_6.guest - , subq_6.host - , subq_6.booking__listing - , subq_6.booking__guest - , subq_6.booking__host - , subq_6.is_instant - , subq_6.booking__is_instant - , subq_6.bookings - , subq_6.instant_bookings - , subq_6.booking_value - , subq_6.max_booking_value - , subq_6.min_booking_value - , subq_6.bookers - , subq_6.average_booking_value - , subq_6.referred_bookings - , subq_6.median_booking_value - , subq_6.booking_value_p99 - , subq_6.discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -331,86 +331,86 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_6 - ) subq_7 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_4 + ) subq_5 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_11.listing - , subq_11.country_latest + subq_7.listing + , subq_7.country_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_10.ds__day - , subq_10.ds__week - , subq_10.ds__month - , subq_10.ds__quarter - , subq_10.ds__year - , subq_10.ds__extract_year - , subq_10.ds__extract_quarter - , subq_10.ds__extract_month - , subq_10.ds__extract_day - , subq_10.ds__extract_dow - , subq_10.ds__extract_doy - , subq_10.created_at__day - , subq_10.created_at__week - , subq_10.created_at__month - , subq_10.created_at__quarter - , subq_10.created_at__year - , subq_10.created_at__extract_year - , subq_10.created_at__extract_quarter - , subq_10.created_at__extract_month - , subq_10.created_at__extract_day - , subq_10.created_at__extract_dow - , subq_10.created_at__extract_doy - , subq_10.listing__ds__day - , subq_10.listing__ds__week - , subq_10.listing__ds__month - , subq_10.listing__ds__quarter - , subq_10.listing__ds__year - , subq_10.listing__ds__extract_year - , subq_10.listing__ds__extract_quarter - , subq_10.listing__ds__extract_month - , subq_10.listing__ds__extract_day - , subq_10.listing__ds__extract_dow - , subq_10.listing__ds__extract_doy - , subq_10.listing__created_at__day - , subq_10.listing__created_at__week - , subq_10.listing__created_at__month - , subq_10.listing__created_at__quarter - , subq_10.listing__created_at__year - , subq_10.listing__created_at__extract_year - , subq_10.listing__created_at__extract_quarter - , subq_10.listing__created_at__extract_month - , subq_10.listing__created_at__extract_day - , subq_10.listing__created_at__extract_dow - , subq_10.listing__created_at__extract_doy - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.listing - , subq_10.user - , subq_10.listing__user - , subq_10.country_latest - , subq_10.is_lux_latest - , subq_10.capacity_latest - , subq_10.listing__country_latest - , subq_10.listing__is_lux_latest - , subq_10.listing__capacity_latest - , subq_10.listings - , subq_10.largest_listing - , subq_10.smallest_listing + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.created_at__day + , subq_6.created_at__week + , subq_6.created_at__month + , subq_6.created_at__quarter + , subq_6.created_at__year + , subq_6.created_at__extract_year + , subq_6.created_at__extract_quarter + , subq_6.created_at__extract_month + , subq_6.created_at__extract_day + , subq_6.created_at__extract_dow + , subq_6.created_at__extract_doy + , subq_6.listing__ds__day + , subq_6.listing__ds__week + , subq_6.listing__ds__month + , subq_6.listing__ds__quarter + , subq_6.listing__ds__year + , subq_6.listing__ds__extract_year + , subq_6.listing__ds__extract_quarter + , subq_6.listing__ds__extract_month + , subq_6.listing__ds__extract_day + , subq_6.listing__ds__extract_dow + , subq_6.listing__ds__extract_doy + , subq_6.listing__created_at__day + , subq_6.listing__created_at__week + , subq_6.listing__created_at__month + , subq_6.listing__created_at__quarter + , subq_6.listing__created_at__year + , subq_6.listing__created_at__extract_year + , subq_6.listing__created_at__extract_quarter + , subq_6.listing__created_at__extract_month + , subq_6.listing__created_at__extract_day + , subq_6.listing__created_at__extract_dow + , subq_6.listing__created_at__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.listing + , subq_6.user + , subq_6.listing__user + , subq_6.country_latest + , subq_6.is_lux_latest + , subq_6.capacity_latest + , subq_6.listing__country_latest + , subq_6.listing__is_lux_latest + , subq_6.listing__capacity_latest + , subq_6.listings + , subq_6.largest_listing + , subq_6.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -471,16 +471,16 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_9.listing = subq_12.listing - ) subq_13 - ) subq_14 + subq_5.listing = subq_8.listing + ) subq_9 + ) subq_10 WHERE booking__is_instant - ) subq_15 - ) subq_16 + ) subq_11 + ) subq_12 GROUP BY - subq_16.listing__country_latest -) subq_17 + subq_12.listing__country_latest +) subq_13 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_single_categorical_dimension_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_single_categorical_dimension_pushdown__plan0_optimized.sql index b0a46663de..e1420879c4 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_single_categorical_dimension_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_single_categorical_dimension_pushdown__plan0_optimized.sql @@ -9,9 +9,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant'] SELECT - subq_21.booking__is_instant AS booking__is_instant + subq_17.booking__is_instant AS booking__is_instant , listings_latest_src_28000.country AS listing__country_latest - , subq_21.bookings AS bookings + , subq_17.bookings AS bookings FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] @@ -27,14 +27,14 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_19 + ) subq_15 WHERE booking__is_instant - ) subq_21 + ) subq_17 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_21.listing = listings_latest_src_28000.listing_id -) subq_26 + subq_17.listing = listings_latest_src_28000.listing_id +) subq_22 WHERE booking__is_instant GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_distinct_values__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_distinct_values__plan0.sql index 4fb1321801..cd3d4c172a 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_distinct_values__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_distinct_values__plan0.sql @@ -1,195 +1,134 @@ -- Order By ['listing__country_latest'] Limit 100 SELECT - subq_5.listing__country_latest + subq_2.listing__country_latest FROM ( -- Pass Only Elements: ['listing__country_latest',] SELECT - subq_4.listing__country_latest + subq_1.listing__country_latest FROM ( -- Constrain Output with WHERE SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.created_at__day - , subq_3.created_at__week - , subq_3.created_at__month - , subq_3.created_at__quarter - , subq_3.created_at__year - , subq_3.created_at__extract_year - , subq_3.created_at__extract_quarter - , subq_3.created_at__extract_month - , subq_3.created_at__extract_day - , subq_3.created_at__extract_dow - , subq_3.created_at__extract_doy - , subq_3.listing__ds__day - , subq_3.listing__ds__week - , subq_3.listing__ds__month - , subq_3.listing__ds__quarter - , subq_3.listing__ds__year - , subq_3.listing__ds__extract_year - , subq_3.listing__ds__extract_quarter - , subq_3.listing__ds__extract_month - , subq_3.listing__ds__extract_day - , subq_3.listing__ds__extract_dow - , subq_3.listing__ds__extract_doy - , subq_3.listing__created_at__day - , subq_3.listing__created_at__week - , subq_3.listing__created_at__month - , subq_3.listing__created_at__quarter - , subq_3.listing__created_at__year - , subq_3.listing__created_at__extract_year - , subq_3.listing__created_at__extract_quarter - , subq_3.listing__created_at__extract_month - , subq_3.listing__created_at__extract_day - , subq_3.listing__created_at__extract_dow - , subq_3.listing__created_at__extract_doy - , subq_3.listing - , subq_3.user - , subq_3.listing__user - , subq_3.country_latest - , subq_3.is_lux_latest - , subq_3.capacity_latest - , subq_3.listing__country_latest - , subq_3.listing__is_lux_latest - , subq_3.listing__capacity_latest - , subq_3.listings - , subq_3.largest_listing - , subq_3.smallest_listing + 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.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Constrain Output with WHERE + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_2.ds__day - , subq_2.ds__week - , subq_2.ds__month - , subq_2.ds__quarter - , subq_2.ds__year - , subq_2.ds__extract_year - , subq_2.ds__extract_quarter - , subq_2.ds__extract_month - , subq_2.ds__extract_day - , subq_2.ds__extract_dow - , subq_2.ds__extract_doy - , subq_2.created_at__day - , subq_2.created_at__week - , subq_2.created_at__month - , subq_2.created_at__quarter - , subq_2.created_at__year - , subq_2.created_at__extract_year - , subq_2.created_at__extract_quarter - , subq_2.created_at__extract_month - , subq_2.created_at__extract_day - , subq_2.created_at__extract_dow - , subq_2.created_at__extract_doy - , subq_2.listing__ds__day - , subq_2.listing__ds__week - , subq_2.listing__ds__month - , subq_2.listing__ds__quarter - , subq_2.listing__ds__year - , subq_2.listing__ds__extract_year - , subq_2.listing__ds__extract_quarter - , subq_2.listing__ds__extract_month - , subq_2.listing__ds__extract_day - , subq_2.listing__ds__extract_dow - , subq_2.listing__ds__extract_doy - , subq_2.listing__created_at__day - , subq_2.listing__created_at__week - , subq_2.listing__created_at__month - , subq_2.listing__created_at__quarter - , subq_2.listing__created_at__year - , subq_2.listing__created_at__extract_year - , subq_2.listing__created_at__extract_quarter - , subq_2.listing__created_at__extract_month - , subq_2.listing__created_at__extract_day - , subq_2.listing__created_at__extract_dow - , subq_2.listing__created_at__extract_doy - , subq_2.listing - , subq_2.user - , subq_2.listing__user - , subq_2.country_latest - , subq_2.is_lux_latest - , subq_2.capacity_latest - , subq_2.listing__country_latest - , subq_2.listing__is_lux_latest - , subq_2.listing__capacity_latest - , subq_2.listings - , subq_2.largest_listing - , subq_2.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_2 - WHERE listing__country_latest = 'us' - ) subq_3 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 WHERE listing__country_latest = 'us' - ) subq_4 + ) subq_1 GROUP BY - subq_4.listing__country_latest -) subq_5 -ORDER BY subq_5.listing__country_latest DESC + subq_1.listing__country_latest +) subq_2 +ORDER BY subq_2.listing__country_latest DESC LIMIT 100 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_distinct_values__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_distinct_values__plan0_optimized.sql index 76e6591b6c..1653ada5bd 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_distinct_values__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_distinct_values__plan0_optimized.sql @@ -4,17 +4,11 @@ SELECT listing__country_latest FROM ( - -- Constrain Output with WHERE + -- Read Elements From Semantic Model 'listings_latest' SELECT - listing__country_latest - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - country AS listing__country_latest - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_6 - WHERE listing__country_latest = 'us' -) subq_7 + country AS listing__country_latest + FROM ***************************.dim_listings_latest listings_latest_src_28000 +) subq_3 WHERE listing__country_latest = 'us' GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_reused_measure__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_reused_measure__plan0.sql index ec68f36116..7a77ad0c8d 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_reused_measure__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_reused_measure__plan0.sql @@ -1,242 +1,242 @@ -- Compute Metrics via Expressions SELECT - subq_19.metric_time__day - , CAST(subq_19.booking_value_with_is_instant_constraint AS DOUBLE) / CAST(NULLIF(subq_19.booking_value, 0) AS DOUBLE) AS instant_booking_value_ratio + subq_15.metric_time__day + , CAST(subq_15.booking_value_with_is_instant_constraint AS DOUBLE) / CAST(NULLIF(subq_15.booking_value, 0) AS DOUBLE) AS instant_booking_value_ratio FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) AS metric_time__day - , MAX(subq_13.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint - , MAX(subq_18.booking_value) AS booking_value + COALESCE(subq_9.metric_time__day, subq_14.metric_time__day) AS metric_time__day + , MAX(subq_9.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_14.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , subq_12.booking_value AS booking_value_with_is_instant_constraint + subq_8.metric_time__day + , subq_8.booking_value AS booking_value_with_is_instant_constraint FROM ( -- Aggregate Measures SELECT - subq_11.metric_time__day - , SUM(subq_11.booking_value) AS booking_value + subq_7.metric_time__day + , SUM(subq_7.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_10.metric_time__day - , subq_10.booking_value + subq_6.metric_time__day + , subq_6.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_9.metric_time__day - , subq_9.booking__is_instant - , subq_9.booking_value + subq_5.metric_time__day + , subq_5.booking__is_instant + , subq_5.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.booking__is_instant - , subq_8.booking_value + subq_4.metric_time__day + , subq_4.booking__is_instant + , subq_4.booking_value FROM ( -- Constrain Output with WHERE 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.ds_partitioned__day - , subq_7.ds_partitioned__week - , subq_7.ds_partitioned__month - , subq_7.ds_partitioned__quarter - , subq_7.ds_partitioned__year - , subq_7.ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy - , subq_7.paid_at__day - , subq_7.paid_at__week - , subq_7.paid_at__month - , subq_7.paid_at__quarter - , subq_7.paid_at__year - , subq_7.paid_at__extract_year - , subq_7.paid_at__extract_quarter - , subq_7.paid_at__extract_month - , subq_7.paid_at__extract_day - , subq_7.paid_at__extract_dow - , subq_7.paid_at__extract_doy - , subq_7.booking__ds__day - , subq_7.booking__ds__week - , subq_7.booking__ds__month - , subq_7.booking__ds__quarter - , subq_7.booking__ds__year - , subq_7.booking__ds__extract_year - , subq_7.booking__ds__extract_quarter - , subq_7.booking__ds__extract_month - , subq_7.booking__ds__extract_day - , subq_7.booking__ds__extract_dow - , subq_7.booking__ds__extract_doy - , subq_7.booking__ds_partitioned__day - , subq_7.booking__ds_partitioned__week - , subq_7.booking__ds_partitioned__month - , subq_7.booking__ds_partitioned__quarter - , subq_7.booking__ds_partitioned__year - , subq_7.booking__ds_partitioned__extract_year - , subq_7.booking__ds_partitioned__extract_quarter - , subq_7.booking__ds_partitioned__extract_month - , subq_7.booking__ds_partitioned__extract_day - , subq_7.booking__ds_partitioned__extract_dow - , subq_7.booking__ds_partitioned__extract_doy - , subq_7.booking__paid_at__day - , subq_7.booking__paid_at__week - , subq_7.booking__paid_at__month - , subq_7.booking__paid_at__quarter - , subq_7.booking__paid_at__year - , subq_7.booking__paid_at__extract_year - , subq_7.booking__paid_at__extract_quarter - , subq_7.booking__paid_at__extract_month - , subq_7.booking__paid_at__extract_day - , subq_7.booking__paid_at__extract_dow - , subq_7.booking__paid_at__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.listing - , subq_7.guest - , subq_7.host - , subq_7.booking__listing - , subq_7.booking__guest - , subq_7.booking__host - , subq_7.is_instant - , subq_7.booking__is_instant - , subq_7.bookings - , subq_7.instant_bookings - , subq_7.booking_value - , subq_7.max_booking_value - , subq_7.min_booking_value - , subq_7.bookers - , subq_7.average_booking_value - , subq_7.referred_bookings - , subq_7.median_booking_value - , subq_7.booking_value_p99 - , subq_7.discrete_booking_value_p99 - , subq_7.approximate_continuous_booking_value_p99 - , subq_7.approximate_discrete_booking_value_p99 + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.ds_partitioned__day + , subq_3.ds_partitioned__week + , subq_3.ds_partitioned__month + , subq_3.ds_partitioned__quarter + , subq_3.ds_partitioned__year + , subq_3.ds_partitioned__extract_year + , subq_3.ds_partitioned__extract_quarter + , subq_3.ds_partitioned__extract_month + , subq_3.ds_partitioned__extract_day + , subq_3.ds_partitioned__extract_dow + , subq_3.ds_partitioned__extract_doy + , subq_3.paid_at__day + , subq_3.paid_at__week + , subq_3.paid_at__month + , subq_3.paid_at__quarter + , subq_3.paid_at__year + , subq_3.paid_at__extract_year + , subq_3.paid_at__extract_quarter + , subq_3.paid_at__extract_month + , subq_3.paid_at__extract_day + , subq_3.paid_at__extract_dow + , subq_3.paid_at__extract_doy + , subq_3.booking__ds__day + , subq_3.booking__ds__week + , subq_3.booking__ds__month + , subq_3.booking__ds__quarter + , subq_3.booking__ds__year + , subq_3.booking__ds__extract_year + , subq_3.booking__ds__extract_quarter + , subq_3.booking__ds__extract_month + , subq_3.booking__ds__extract_day + , subq_3.booking__ds__extract_dow + , subq_3.booking__ds__extract_doy + , subq_3.booking__ds_partitioned__day + , subq_3.booking__ds_partitioned__week + , subq_3.booking__ds_partitioned__month + , subq_3.booking__ds_partitioned__quarter + , subq_3.booking__ds_partitioned__year + , subq_3.booking__ds_partitioned__extract_year + , subq_3.booking__ds_partitioned__extract_quarter + , subq_3.booking__ds_partitioned__extract_month + , subq_3.booking__ds_partitioned__extract_day + , subq_3.booking__ds_partitioned__extract_dow + , subq_3.booking__ds_partitioned__extract_doy + , subq_3.booking__paid_at__day + , subq_3.booking__paid_at__week + , subq_3.booking__paid_at__month + , subq_3.booking__paid_at__quarter + , subq_3.booking__paid_at__year + , subq_3.booking__paid_at__extract_year + , subq_3.booking__paid_at__extract_quarter + , subq_3.booking__paid_at__extract_month + , subq_3.booking__paid_at__extract_day + , subq_3.booking__paid_at__extract_dow + , subq_3.booking__paid_at__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy + , subq_3.listing + , subq_3.guest + , subq_3.host + , subq_3.booking__listing + , subq_3.booking__guest + , subq_3.booking__host + , subq_3.is_instant + , subq_3.booking__is_instant + , subq_3.bookings + , subq_3.instant_bookings + , subq_3.booking_value + , subq_3.max_booking_value + , subq_3.min_booking_value + , subq_3.bookers + , subq_3.average_booking_value + , subq_3.referred_bookings + , subq_3.median_booking_value + , subq_3.booking_value_p99 + , subq_3.discrete_booking_value_p99 + , subq_3.approximate_continuous_booking_value_p99 + , subq_3.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.ds_partitioned__day - , subq_6.ds_partitioned__week - , subq_6.ds_partitioned__month - , subq_6.ds_partitioned__quarter - , subq_6.ds_partitioned__year - , subq_6.ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy - , subq_6.paid_at__day - , subq_6.paid_at__week - , subq_6.paid_at__month - , subq_6.paid_at__quarter - , subq_6.paid_at__year - , subq_6.paid_at__extract_year - , subq_6.paid_at__extract_quarter - , subq_6.paid_at__extract_month - , subq_6.paid_at__extract_day - , subq_6.paid_at__extract_dow - , subq_6.paid_at__extract_doy - , subq_6.booking__ds__day - , subq_6.booking__ds__week - , subq_6.booking__ds__month - , subq_6.booking__ds__quarter - , subq_6.booking__ds__year - , subq_6.booking__ds__extract_year - , subq_6.booking__ds__extract_quarter - , subq_6.booking__ds__extract_month - , subq_6.booking__ds__extract_day - , subq_6.booking__ds__extract_dow - , subq_6.booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day - , subq_6.booking__paid_at__week - , subq_6.booking__paid_at__month - , subq_6.booking__paid_at__quarter - , subq_6.booking__paid_at__year - , subq_6.booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.listing - , subq_6.guest - , subq_6.host - , subq_6.booking__listing - , subq_6.booking__guest - , subq_6.booking__host - , subq_6.is_instant - , subq_6.booking__is_instant - , subq_6.bookings - , subq_6.instant_bookings - , subq_6.booking_value - , subq_6.max_booking_value - , subq_6.min_booking_value - , subq_6.bookers - , subq_6.average_booking_value - , subq_6.referred_bookings - , subq_6.median_booking_value - , subq_6.booking_value_p99 - , subq_6.discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -329,134 +329,134 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_6 - ) subq_7 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_4 + ) subq_5 WHERE booking__is_instant - ) subq_10 - ) subq_11 + ) subq_6 + ) subq_7 GROUP BY - subq_11.metric_time__day - ) subq_12 - ) subq_13 + subq_7.metric_time__day + ) subq_8 + ) subq_9 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_17.metric_time__day - , subq_17.booking_value + subq_13.metric_time__day + , subq_13.booking_value FROM ( -- Aggregate Measures SELECT - subq_16.metric_time__day - , SUM(subq_16.booking_value) AS booking_value + subq_12.metric_time__day + , SUM(subq_12.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_15.metric_time__day - , subq_15.booking_value + subq_11.metric_time__day + , subq_11.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_14.ds__day - , subq_14.ds__week - , subq_14.ds__month - , subq_14.ds__quarter - , subq_14.ds__year - , subq_14.ds__extract_year - , subq_14.ds__extract_quarter - , subq_14.ds__extract_month - , subq_14.ds__extract_day - , subq_14.ds__extract_dow - , subq_14.ds__extract_doy - , subq_14.ds_partitioned__day - , subq_14.ds_partitioned__week - , subq_14.ds_partitioned__month - , subq_14.ds_partitioned__quarter - , subq_14.ds_partitioned__year - , subq_14.ds_partitioned__extract_year - , subq_14.ds_partitioned__extract_quarter - , subq_14.ds_partitioned__extract_month - , subq_14.ds_partitioned__extract_day - , subq_14.ds_partitioned__extract_dow - , subq_14.ds_partitioned__extract_doy - , subq_14.paid_at__day - , subq_14.paid_at__week - , subq_14.paid_at__month - , subq_14.paid_at__quarter - , subq_14.paid_at__year - , subq_14.paid_at__extract_year - , subq_14.paid_at__extract_quarter - , subq_14.paid_at__extract_month - , subq_14.paid_at__extract_day - , subq_14.paid_at__extract_dow - , subq_14.paid_at__extract_doy - , subq_14.booking__ds__day - , subq_14.booking__ds__week - , subq_14.booking__ds__month - , subq_14.booking__ds__quarter - , subq_14.booking__ds__year - , subq_14.booking__ds__extract_year - , subq_14.booking__ds__extract_quarter - , subq_14.booking__ds__extract_month - , subq_14.booking__ds__extract_day - , subq_14.booking__ds__extract_dow - , subq_14.booking__ds__extract_doy - , subq_14.booking__ds_partitioned__day - , subq_14.booking__ds_partitioned__week - , subq_14.booking__ds_partitioned__month - , subq_14.booking__ds_partitioned__quarter - , subq_14.booking__ds_partitioned__year - , subq_14.booking__ds_partitioned__extract_year - , subq_14.booking__ds_partitioned__extract_quarter - , subq_14.booking__ds_partitioned__extract_month - , subq_14.booking__ds_partitioned__extract_day - , subq_14.booking__ds_partitioned__extract_dow - , subq_14.booking__ds_partitioned__extract_doy - , subq_14.booking__paid_at__day - , subq_14.booking__paid_at__week - , subq_14.booking__paid_at__month - , subq_14.booking__paid_at__quarter - , subq_14.booking__paid_at__year - , subq_14.booking__paid_at__extract_year - , subq_14.booking__paid_at__extract_quarter - , subq_14.booking__paid_at__extract_month - , subq_14.booking__paid_at__extract_day - , subq_14.booking__paid_at__extract_dow - , subq_14.booking__paid_at__extract_doy - , subq_14.ds__day AS metric_time__day - , subq_14.ds__week AS metric_time__week - , subq_14.ds__month AS metric_time__month - , subq_14.ds__quarter AS metric_time__quarter - , subq_14.ds__year AS metric_time__year - , subq_14.ds__extract_year AS metric_time__extract_year - , subq_14.ds__extract_quarter AS metric_time__extract_quarter - , subq_14.ds__extract_month AS metric_time__extract_month - , subq_14.ds__extract_day AS metric_time__extract_day - , subq_14.ds__extract_dow AS metric_time__extract_dow - , subq_14.ds__extract_doy AS metric_time__extract_doy - , subq_14.listing - , subq_14.guest - , subq_14.host - , subq_14.booking__listing - , subq_14.booking__guest - , subq_14.booking__host - , subq_14.is_instant - , subq_14.booking__is_instant - , subq_14.bookings - , subq_14.instant_bookings - , subq_14.booking_value - , subq_14.max_booking_value - , subq_14.min_booking_value - , subq_14.bookers - , subq_14.average_booking_value - , subq_14.referred_bookings - , subq_14.median_booking_value - , subq_14.booking_value_p99 - , subq_14.discrete_booking_value_p99 - , subq_14.approximate_continuous_booking_value_p99 - , subq_14.approximate_discrete_booking_value_p99 + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -549,15 +549,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_14 - ) subq_15 - ) subq_16 + ) subq_10 + ) subq_11 + ) subq_12 GROUP BY - subq_16.metric_time__day - ) subq_17 - ) subq_18 + subq_12.metric_time__day + ) subq_13 + ) subq_14 ON - subq_13.metric_time__day = subq_18.metric_time__day + subq_9.metric_time__day = subq_14.metric_time__day GROUP BY - COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) -) subq_19 + COALESCE(subq_9.metric_time__day, subq_14.metric_time__day) +) subq_15 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_reused_measure__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_reused_measure__plan0_optimized.sql index f0def82955..b3f811ac19 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_reused_measure__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_reused_measure__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_27.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , MAX(subq_27.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint - , MAX(subq_32.booking_value) AS booking_value + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , MAX(subq_23.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_28.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value', 'metric_time__day'] @@ -31,13 +31,13 @@ FROM ( , is_instant AS booking__is_instant , booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_21 + ) subq_17 WHERE booking__is_instant - ) subq_23 + ) subq_19 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_27 + ) subq_23 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -50,9 +50,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_32 + ) subq_28 ON - subq_27.metric_time__day = subq_32.metric_time__day + subq_23.metric_time__day = subq_28.metric_time__day GROUP BY - COALESCE(subq_27.metric_time__day, subq_32.metric_time__day) -) subq_33 + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) +) subq_29 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_single_expr_and_alias__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_single_expr_and_alias__plan0.sql index 8e811be580..917ad2f2e1 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_single_expr_and_alias__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_single_expr_and_alias__plan0.sql @@ -1,236 +1,236 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day + subq_9.metric_time__day , delayed_bookings * 2 AS double_counted_delayed_bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , subq_12.bookings AS delayed_bookings + subq_8.metric_time__day + , subq_8.bookings AS delayed_bookings FROM ( -- Aggregate Measures SELECT - subq_11.metric_time__day - , SUM(subq_11.bookings) AS bookings + subq_7.metric_time__day + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_10.metric_time__day - , subq_10.bookings + subq_6.metric_time__day + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_9.metric_time__day - , subq_9.booking__is_instant - , subq_9.bookings + subq_5.metric_time__day + , subq_5.booking__is_instant + , subq_5.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.booking__is_instant - , subq_8.bookings + subq_4.metric_time__day + , subq_4.booking__is_instant + , subq_4.bookings FROM ( -- Constrain Output with WHERE 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.ds_partitioned__day - , subq_7.ds_partitioned__week - , subq_7.ds_partitioned__month - , subq_7.ds_partitioned__quarter - , subq_7.ds_partitioned__year - , subq_7.ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy - , subq_7.paid_at__day - , subq_7.paid_at__week - , subq_7.paid_at__month - , subq_7.paid_at__quarter - , subq_7.paid_at__year - , subq_7.paid_at__extract_year - , subq_7.paid_at__extract_quarter - , subq_7.paid_at__extract_month - , subq_7.paid_at__extract_day - , subq_7.paid_at__extract_dow - , subq_7.paid_at__extract_doy - , subq_7.booking__ds__day - , subq_7.booking__ds__week - , subq_7.booking__ds__month - , subq_7.booking__ds__quarter - , subq_7.booking__ds__year - , subq_7.booking__ds__extract_year - , subq_7.booking__ds__extract_quarter - , subq_7.booking__ds__extract_month - , subq_7.booking__ds__extract_day - , subq_7.booking__ds__extract_dow - , subq_7.booking__ds__extract_doy - , subq_7.booking__ds_partitioned__day - , subq_7.booking__ds_partitioned__week - , subq_7.booking__ds_partitioned__month - , subq_7.booking__ds_partitioned__quarter - , subq_7.booking__ds_partitioned__year - , subq_7.booking__ds_partitioned__extract_year - , subq_7.booking__ds_partitioned__extract_quarter - , subq_7.booking__ds_partitioned__extract_month - , subq_7.booking__ds_partitioned__extract_day - , subq_7.booking__ds_partitioned__extract_dow - , subq_7.booking__ds_partitioned__extract_doy - , subq_7.booking__paid_at__day - , subq_7.booking__paid_at__week - , subq_7.booking__paid_at__month - , subq_7.booking__paid_at__quarter - , subq_7.booking__paid_at__year - , subq_7.booking__paid_at__extract_year - , subq_7.booking__paid_at__extract_quarter - , subq_7.booking__paid_at__extract_month - , subq_7.booking__paid_at__extract_day - , subq_7.booking__paid_at__extract_dow - , subq_7.booking__paid_at__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.listing - , subq_7.guest - , subq_7.host - , subq_7.booking__listing - , subq_7.booking__guest - , subq_7.booking__host - , subq_7.is_instant - , subq_7.booking__is_instant - , subq_7.bookings - , subq_7.instant_bookings - , subq_7.booking_value - , subq_7.max_booking_value - , subq_7.min_booking_value - , subq_7.bookers - , subq_7.average_booking_value - , subq_7.referred_bookings - , subq_7.median_booking_value - , subq_7.booking_value_p99 - , subq_7.discrete_booking_value_p99 - , subq_7.approximate_continuous_booking_value_p99 - , subq_7.approximate_discrete_booking_value_p99 + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.ds_partitioned__day + , subq_3.ds_partitioned__week + , subq_3.ds_partitioned__month + , subq_3.ds_partitioned__quarter + , subq_3.ds_partitioned__year + , subq_3.ds_partitioned__extract_year + , subq_3.ds_partitioned__extract_quarter + , subq_3.ds_partitioned__extract_month + , subq_3.ds_partitioned__extract_day + , subq_3.ds_partitioned__extract_dow + , subq_3.ds_partitioned__extract_doy + , subq_3.paid_at__day + , subq_3.paid_at__week + , subq_3.paid_at__month + , subq_3.paid_at__quarter + , subq_3.paid_at__year + , subq_3.paid_at__extract_year + , subq_3.paid_at__extract_quarter + , subq_3.paid_at__extract_month + , subq_3.paid_at__extract_day + , subq_3.paid_at__extract_dow + , subq_3.paid_at__extract_doy + , subq_3.booking__ds__day + , subq_3.booking__ds__week + , subq_3.booking__ds__month + , subq_3.booking__ds__quarter + , subq_3.booking__ds__year + , subq_3.booking__ds__extract_year + , subq_3.booking__ds__extract_quarter + , subq_3.booking__ds__extract_month + , subq_3.booking__ds__extract_day + , subq_3.booking__ds__extract_dow + , subq_3.booking__ds__extract_doy + , subq_3.booking__ds_partitioned__day + , subq_3.booking__ds_partitioned__week + , subq_3.booking__ds_partitioned__month + , subq_3.booking__ds_partitioned__quarter + , subq_3.booking__ds_partitioned__year + , subq_3.booking__ds_partitioned__extract_year + , subq_3.booking__ds_partitioned__extract_quarter + , subq_3.booking__ds_partitioned__extract_month + , subq_3.booking__ds_partitioned__extract_day + , subq_3.booking__ds_partitioned__extract_dow + , subq_3.booking__ds_partitioned__extract_doy + , subq_3.booking__paid_at__day + , subq_3.booking__paid_at__week + , subq_3.booking__paid_at__month + , subq_3.booking__paid_at__quarter + , subq_3.booking__paid_at__year + , subq_3.booking__paid_at__extract_year + , subq_3.booking__paid_at__extract_quarter + , subq_3.booking__paid_at__extract_month + , subq_3.booking__paid_at__extract_day + , subq_3.booking__paid_at__extract_dow + , subq_3.booking__paid_at__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy + , subq_3.listing + , subq_3.guest + , subq_3.host + , subq_3.booking__listing + , subq_3.booking__guest + , subq_3.booking__host + , subq_3.is_instant + , subq_3.booking__is_instant + , subq_3.bookings + , subq_3.instant_bookings + , subq_3.booking_value + , subq_3.max_booking_value + , subq_3.min_booking_value + , subq_3.bookers + , subq_3.average_booking_value + , subq_3.referred_bookings + , subq_3.median_booking_value + , subq_3.booking_value_p99 + , subq_3.discrete_booking_value_p99 + , subq_3.approximate_continuous_booking_value_p99 + , subq_3.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.ds_partitioned__day - , subq_6.ds_partitioned__week - , subq_6.ds_partitioned__month - , subq_6.ds_partitioned__quarter - , subq_6.ds_partitioned__year - , subq_6.ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy - , subq_6.paid_at__day - , subq_6.paid_at__week - , subq_6.paid_at__month - , subq_6.paid_at__quarter - , subq_6.paid_at__year - , subq_6.paid_at__extract_year - , subq_6.paid_at__extract_quarter - , subq_6.paid_at__extract_month - , subq_6.paid_at__extract_day - , subq_6.paid_at__extract_dow - , subq_6.paid_at__extract_doy - , subq_6.booking__ds__day - , subq_6.booking__ds__week - , subq_6.booking__ds__month - , subq_6.booking__ds__quarter - , subq_6.booking__ds__year - , subq_6.booking__ds__extract_year - , subq_6.booking__ds__extract_quarter - , subq_6.booking__ds__extract_month - , subq_6.booking__ds__extract_day - , subq_6.booking__ds__extract_dow - , subq_6.booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day - , subq_6.booking__paid_at__week - , subq_6.booking__paid_at__month - , subq_6.booking__paid_at__quarter - , subq_6.booking__paid_at__year - , subq_6.booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.listing - , subq_6.guest - , subq_6.host - , subq_6.booking__listing - , subq_6.booking__guest - , subq_6.booking__host - , subq_6.is_instant - , subq_6.booking__is_instant - , subq_6.bookings - , subq_6.instant_bookings - , subq_6.booking_value - , subq_6.max_booking_value - , subq_6.min_booking_value - , subq_6.bookers - , subq_6.average_booking_value - , subq_6.referred_bookings - , subq_6.median_booking_value - , subq_6.booking_value_p99 - , subq_6.discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -323,15 +323,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_6 - ) subq_7 + ) subq_2 + ) subq_3 WHERE NOT booking__is_instant - ) subq_8 - ) subq_9 + ) subq_4 + ) subq_5 WHERE NOT booking__is_instant - ) subq_10 - ) subq_11 + ) subq_6 + ) subq_7 GROUP BY - subq_11.metric_time__day - ) subq_12 -) subq_13 + subq_7.metric_time__day + ) subq_8 +) subq_9 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql index 33436b83b6..31360941eb 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql @@ -25,10 +25,10 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_15 + ) subq_11 WHERE NOT booking__is_instant - ) subq_17 + ) subq_13 WHERE NOT booking__is_instant GROUP BY metric_time__day -) subq_21 +) subq_17 diff --git a/tests_metricflow/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_constrained_metric_not_combined__dfp_0.xml b/tests_metricflow/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_constrained_metric_not_combined__dfp_0.xml index 28a5df6cca..19903be4cd 100644 --- a/tests_metricflow/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_constrained_metric_not_combined__dfp_0.xml +++ b/tests_metricflow/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_constrained_metric_not_combined__dfp_0.xml @@ -46,7 +46,7 @@ - + @@ -101,7 +101,7 @@ - + diff --git a/tests_metricflow/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_constrained_metric_not_combined__dfpo_0.xml b/tests_metricflow/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_constrained_metric_not_combined__dfpo_0.xml index f82040cddd..b4930a1a05 100644 --- a/tests_metricflow/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_constrained_metric_not_combined__dfpo_0.xml +++ b/tests_metricflow/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_constrained_metric_not_combined__dfpo_0.xml @@ -46,7 +46,7 @@ - + @@ -88,7 +88,7 @@ - + @@ -101,7 +101,7 @@ - +